Raspbian上snapd狂吃CPU问题
To get rid of snapd on Raspbian/RaspberryPi OS Buster, since it eats lots of cpu power, especially on the old hardware, like a Pi 2B.
一台年迈的Pi 2B,运行着时时更新的Raspbian Buster,兢兢业业给娃做文件服务器,不亦乐乎。
一天apt dist-upgrade之后,就发现system load频繁升高,系统空载就能吃掉大致一个核的性能。top后画风大致是这样的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
➜ ~ top top - 22:26:04 up 2 days, 13:44, 3 users, load average: 0.96, 0.99, 0.93 Tasks: 143 total, 1 running, 142 sleeping, 0 stopped, 0 zombie %Cpu(s): 8.4 us, 2.7 sy, 0.0 ni, 82.4 id, 6.3 wa, 0.0 hi, 0.2 si, 0.0 st MiB Mem : 926.1 total, 222.2 free, 171.1 used, 532.7 buff/cache MiB Swap: 100.0 total, 100.0 free, 0.0 used. 693.0 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 345 root 20 0 968804 21248 13064 S 37.3 2.2 1065:41 snapd 84 root 20 0 0 0 0 S 1.0 0.0 28:27.25 jbd2/mmcblk0p2- 15049 pi 20 0 10440 3096 2540 R 1.0 0.3 0:00.09 top 346 root 20 0 2968 2060 1564 S 0.7 0.2 2:17.19 dhcpcd 17101 root 0 -20 0 0 0 I 0.7 0.0 2:49.94 kworker/0:1H-mmc_complete 10 root 20 0 0 0 0 I 0.3 0.0 7:00.05 rcu_sched 18 root 0 -20 0 0 0 I 0.3 0.0 4:21.89 kworker/1:0H-kblockd 83 root 0 -20 0 0 0 I 0.3 0.0 4:24.37 kworker/2:1H-kblockd 412 root 20 0 31976 9496 8068 S 0.3 1.0 0:29.19 nmbd |
于是很想了解这货在干嘛,消耗这么多脑力,思考人生么?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
➜ ~ sudo lsof -p 345 lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs Output information may be incomplete. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME snapd 345 root cwd DIR 179,2 4096 2 / snapd 345 root rtd DIR 179,2 4096 2 / snapd 345 root txt REG 7,0 13421332 7147 /snap/core/9291/usr/lib/snapd/snapd snapd 345 root mem REG 179,2 1296004 2022 /lib/arm-linux-gnueabihf/libc-2.28.so snapd 345 root mem REG 179,2 130416 2085 /lib/arm-linux-gnueabihf/libpthread-2.28.so snapd 345 root mem REG 179,2 17708 10917 /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so snapd 345 root mem REG 179,2 138604 1945 /lib/arm-linux-gnueabihf/ld-2.28.so snapd 345 root 0r CHR 1,3 0t0 1028 /dev/null snapd 345 root 1u unix 0xf31a5a4c 0t0 14576 type=STREAM snapd 345 root 2u unix 0xf31a5a4c 0t0 14576 type=STREAM snapd 345 root 3u IPv4 152109 0t0 TCP 192.168.50.127:48604->api.snapcraft.io:https (ESTABLISHED) snapd 345 root 4u IPv4 233503 0t0 TCP 192.168.50.127:40786->api.snapcraft.io:https (ESTABLISHED) snapd 345 root 6u a_inode 0,11 0 5804 [eventpoll] snapd 345 root 7u unix 0x5b752603 0t0 14350 /run/snapd.socket type=STREAM snapd 345 root 8u unix 0xfebd686d 0t0 14353 /run/snapd-snap.socket type=STREAM snapd 345 root 9u REG 179,2 0 386387 /var/lib/snapd/snaps/core_9668.snap.partial snapd 345 root 12u netlink 0t0 18728 KOBJECT_UEVENT snapd 345 root 13r FIFO 0,10 0t0 18729 pipe snapd 345 root 14w FIFO 0,10 0t0 18729 pipe |
看起来是想回家拉点什么私货回来(api.snapcraft.io),但还是搞不懂,走io就走io,连续几天24小时一直吃那么多cpu是什么鬼?
不管目的如何,不说清楚就不能一直忍你容你;先看这货名下有啥app,有没有不得不用的。
1 2 3 |
➜ ~ snap list Name Version Rev Tracking Publisher Notes core 16-2.45 9291 latest/stable canonical✓ core |
除了core没有任何app,也就是说卵用没有,可见应该立即滚犊子。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
➜ ~ sudo apt purge snapd Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: rpi-eeprom-images squashfs-tools Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: snapd* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 48.3 MB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 101570 files and directories currently installed.) Removing snapd (2.37.4-1+rpi1) ... Processing triggers for mime-support (3.62) ... Processing triggers for gnome-menus (3.31.4-3) ... Processing triggers for man-db (2.8.5-2) ... Processing triggers for desktop-file-utils (0.23-4) ... (Reading database ... 101520 files and directories currently installed.) Purging configuration files for snapd (2.37.4-1+rpi1) ... Stopping snap-core-9069.mount Stopping unit snap-core-9069.mount Waiting until unit snap-core-9069.mount is stopped [attempt 1] snap-core-9069.mount is stopped. Removing snap core and revision 9069 Removing snap-core-9069.mount Stopping snap-core-9291.mount Stopping unit snap-core-9291.mount Waiting until unit snap-core-9291.mount is stopped [attempt 1] snap-core-9291.mount is stopped. Removing snap core and revision 9291 Removing snap-core-9291.mount Final directory cleanup Discarding preserved snap namespaces Removing extra snap-confine apparmor rules Removing snapd cache rm: cannot remove '/var/cache/snapd/aux': Is a directory dpkg: error processing package snapd (--purge): installed snapd package post-removal script subprocess returned error exit status 1 Errors were encountered while processing: snapd E: Sub-process /usr/bin/dpkg returned an error code (1) |
某个目录不干净,需要手工删一下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
➜ ~ sudo rm -rf /var/cache/snapd ➜ ~ sudo apt purge snapd Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: rpi-eeprom-images squashfs-tools Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: snapd* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Y (Reading database ... 101516 files and directories currently installed.) Purging configuration files for snapd (2.37.4-1+rpi1) ... Final directory cleanup Discarding preserved snap namespaces Removing extra snap-confine apparmor rules Removing snapd cache Removing snapd state ➜ ~ |
是否重启都没关系,总之整个世界清静了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
➜ ~ top top - 23:17:59 up 20 min, 3 users, load average: 0.00, 0.01, 0.04 Tasks: 138 total, 1 running, 137 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.6 us, 0.9 sy, 0.0 ni, 98.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 926.8 total, 464.1 free, 112.3 used, 350.4 buff/cache MiB Swap: 100.0 total, 100.0 free, 0.0 used. 751.5 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3503 pi 20 0 10436 3036 2484 R 1.0 0.3 0:00.11 top 356 root 20 0 2904 2120 1692 S 0.3 0.2 0:00.99 dhcpcd 1 root 20 0 15320 7976 6396 S 0.0 0.8 0:06.58 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd 3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp 7 root 20 0 0 0 0 I 0.0 0.0 0:06.48 kworker/u8:0-phy0 8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq 9 root 20 0 0 0 0 S 0.0 0.0 0:00.50 ksoftirqd/0 10 root 20 0 0 0 0 I 0.0 0.0 0:00.95 rcu_sched |
空载嘛就应该是空载,load average只要突破0.1就应当搞搞清楚。知根知底的明白你是被力挺的未来app platform,不知道的还以为你偷摸挖矿呢…… anyway, Raspbian Buster移除snapd成功。
【注】要觉得这货还能留着过年,disable一下应该也是可以的;我主要是cpu被吃个把月了,不卸掉气难平。年轻人莫要学我,须知“戒急用忍”,雍正他老爹给他留下的金玉之言,共勉,共勉。
文章的脚注信息由WordPress的wp-posturl插件自动生成
暂无评论
引用