我的电脑安装了 ubuntu 后,硬盘红色 LED 一直亮着,然后熄灭几秒钟,然后又亮了很长时间。在此期间,系统基本上处于空闲状态(没有执行任何特殊操作)。
我参考了这个答案https://askubuntu.com/a/422151安装 perf ,结果如下:
+ 27,70% 0,00% swapper [kernel.kallsyms] [k] secondary_startup_64
+ 27,70% 0,00% swapper [kernel.kallsyms] [k] cpu_startup_entry
+ 27,65% 0,04% swapper [kernel.kallsyms] [k] do_idle
+ 26,09% 0,02% swapper [kernel.kallsyms] [k] call_cpuidle
+ 26,06% 0,00% swapper [kernel.kallsyms] [k] cpuidle_enter
+ 26,04% 0,07% swapper [kernel.kallsyms] [k] cpuidle_enter_state
+ 24,89% 0,00% swapper [kernel.kallsyms] [k] start_secondary
+ 24,45% 24,37% swapper [kernel.kallsyms] [k] intel_idle
+ 5,93% 0,00% gnome-shell [unknown] [.] 0000000000000000
+ 3,03% 0,00% Xorg [unknown] [k] 0000000000000000
+ 2,96% 0,08% Xorg [kernel.kallsyms] [k] entry_SYSCALL_64_after_hwframe
+ 2,84% 0,51% Xorg [kernel.kallsyms] [k] do_syscall_64
+ 2,81% 0,00% swapper [kernel.kallsyms] [k] x86_64_start_kernel
+ 2,81% 0,00% swapper [kernel.kallsyms] [k] x86_64_start_reservations
+ 2,81% 0,00% swapper [kernel.kallsyms] [k] start_kernel
+ 2,81% 0,00% swapper [kernel.kallsyms] [k] arch_call_rest_init
+ 2,81% 0,00% swapper [kernel.kallsyms] [k] rest_init
+ 2,76% 0,04% chrome chrome [.] free
我还是不明白是什么导致了这个问题。
有人可以提供一些关于如何调试和修复这个问题的提示吗?
更新:
free -m 的输出
➜ free -m
total used free shared buff/cache available
Mem: 15932 5797 7010 639 3124 9168
Swap: 2047 1456 591
的输出/proc/meminfo
是:
MemTotal: 16314684 kB
MemFree: 7078640 kB
MemAvailable: 9293936 kB
Buffers: 183180 kB
Cached: 2849624 kB
SwapCached: 163900 kB
Active: 5521352 kB
Inactive: 3009000 kB
Active(anon): 4687400 kB
Inactive(anon): 1461260 kB
Active(file): 833952 kB
Inactive(file): 1547740 kB
Unevictable: 64 kB
Mlocked: 64 kB
SwapTotal: 2097148 kB
SwapFree: 607576 kB
Dirty: 21520 kB
Writeback: 0 kB
AnonPages: 5334264 kB
Mapped: 1207368 kB
Shmem: 654420 kB
KReclaimable: 171680 kB
Slab: 417120 kB
SReclaimable: 171680 kB
SUnreclaim: 245440 kB
KernelStack: 23328 kB
PageTables: 67608 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 10254488 kB
Committed_AS: 19727368 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 59852 kB
VmallocChunk: 0 kB
Percpu: 7392 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 536284 kB
DirectMap2M: 7770112 kB
DirectMap1G: 10485760 kB
输出如下:
root@servlus:/home/serv/~# iotop -o -b | grep -i kworker
13830 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.30 % [kworker/u16:3-events_power_efficient]
30898 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.22 % [kworker/u16:2-events_freezable_power_]
21605 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.15 % [kworker/u16:1-events_freezable_power_]
32089 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.07 % [kworker/u16:6-events_freezable_power_]
30898 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/u16:2-events_power_efficient]
13830 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.29 % [kworker/u16:3-events_unbound]
21605 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.22 % [kworker/u16:1-events_power_efficient]
32089 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.15 % [kworker/u16:6-events_freezable_power_]
30898 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.08 % [kworker/u16:2-events_freezable_power_]
13830 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/u16:3-events_freezable_power_]
13830 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.23 % [kworker/u16:3-events_unbound]
21605 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.22 % [kworker/u16:1-events_power_efficient]
30898 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.29 % [kworker/u16:2-events_power_efficient]
13830 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.22 % [kworker/u16:3-events_freezable_power_]
32089 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.15 % [kworker/u16:6-events_freezable_power_]
21605 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.07 % [kworker/u16:1-events_freezable_power_]
30898 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/u16:2-events_power_efficient]
13830 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.30 % [kworker/u16:3-events_power_efficient]
32089 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.23 % [kworker/u16:6-events_freezable_power_]
21605 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.16 % [kworker/u16:1-events_freezable_power_]
30898 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.08 % [kworker/u16:2-events_freezable_power_]
输出如下sysctl vm.swappiness
:
root@servlus:/home/serv/~# sysctl vm.swappiness
vm.swappiness = 60
输出grep -i swap /etc/fstab
root@servlus:/home/serv/~# grep -i swap /etc/fstab
/swapfile none swap sw 0 0
顶部输出:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16404 serv 20 0 18,9g 400084 122388 S 69,8 2,5 94:04.24 chrome
33283 root 20 0 35780 18768 7352 R 23,6 0,1 2:29.60 iotop
9275 serv 20 0 766204 367428 102656 S 22,6 2,3 32:53.18 chrome
2685 serv 20 0 4840508 223616 83896 R 20,9 1,4 30:58.12 gnome-shell
9279 serv 20 0 378864 57876 26924 S 8,3 0,4 11:27.19 chrome
2462 root 20 0 339976 72568 60504 S 8,0 0,4 11:40.55 Xorg
1803 root -51 0 0 0 0 S 6,3 0,0 8:55.88 irq/56-nvidia
9236 serv 20 0 1496608 283636 101768 S 3,7 1,7 8:07.33 chrome
14029 serv 20 0 909164 61992 40180 S 3,3 0,4 1:07.76 gnome-terminal-
2384 serv 20 0 3146556 10232 7456 S 2,7 0,1 4:12.82 pulseaudio
15548 serv 20 0 596624 48368 34760 S 2,7 0,3 2:10.61 gnome-disks
4118 serv 20 0 8220884 1,3g 20704 S 2,0 8,1 16:40.11 java
8666 serv 20 0 1201020 42848 6168 S 1,3 0,3 3:48.64 gulp watch
7898 serv 20 0 4671616 1,3g 63440 S 1,0 8,6 7:00.56 telegram-deskto
727 root 20 0 0 0 0 S 0,7 0,0 1:33.70 nvidia-modeset/
1387 root 20 0 2540 0 0 S 0,7 0,0 0:16.40 acpid
16517 serv 20 0 833012 62304 50708 S 0,7 0,4 1:09.02 chrome
1 root 20 0 169564 9516 4852 S 0,3 0,1 0:11.53 systemd
18 root 20 0 0 0 0 S 0,3 0,0 0:00.57 ksoftirqd/1
1393 message+ 20 0 10172 4456 2124 S 0,3 0,0 0:14.11 dbus-daemon
1423 root 20 0 253936 8472 4920 S 0,3 0,1 0:26.11 polkitd
1429 root 20 0 16948 2852 2508 S 0,3 0,0 0:06.74 systemd-logind
1431 root 20 0 822648 12328 5452 S 0,3 0,1 0:15.40 udisksd
1805 root 20 0 0 0 0 S 0,3 0,0 0:06.25 nv_queue
2580 serv 20 0 397828 5724 3860 S 0,3 0,0 0:12.85 ibus-daemon
9401 serv 20 0 14,5g 80024 41064 S 0,3 0,5 0:30.50 chrome
10876 serv 20 0 23,2g 250692 65600 S 0,3 1,5 0:51.70 slack
20110 serv 20 0 4763912 167396 86664 S 0,3 1,0 1:55.58 chrome
33186 root 20 0 0 0 0 I 0,3 0,0 0:00.21 kworker/6:0-events
34619 root 20 0 20972 4244 3284 R 0,3 0,0 0:00.11 top
输出:
root@servlus:/home/serv/~# ls -al ~/.local/share/gnome-shell/extensions
ls: cannot access '/root/.local/share/gnome-shell/extensions': No such file or directory
root@servlus:/home/serv/~# ls -al /usr/share/gnome-shell/extensions
total 20
drwxr-xr-x 5 root root 4096 avril 23 09:35 .
drwxr-xr-x 7 root root 4096 avril 23 09:38 ..
drwxr-xr-x 2 root root 4096 avril 23 09:35 desktop-icons@csoriano
drwxr-xr-x 3 root root 4096 avril 23 09:35 [email protected]
drwxr-xr-x 3 root root 4096 avril 23 09:35 [email protected]
从根开始:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
36402 serv 20 0 18,8g 360672 119280 S 79,4 2,2 5:06.82 chrome
35817 serv 20 0 572632 288120 134216 S 23,3 1,8 2:15.15 chrome
2685 serv 20 0 4850620 234440 83980 S 20,9 1,4 34:00.83 gnome-shell
35820 serv 20 0 359148 87784 67416 S 9,6 0,5 0:38.56 chrome
2462 root 20 0 335368 74732 62640 S 7,0 0,5 12:40.14 Xorg
1803 root -51 0 0 0 0 S 6,3 0,0 9:42.38 irq/56-nvidia
35781 serv 20 0 886848 243528 133180 S 3,3 1,5 0:43.22 chrome
2384 serv 20 0 2687792 10020 7244 S 3,0 0,1 4:35.63 pulseaudio
14029 serv 20 0 909224 62204 40432 S 2,3 0,4 1:15.19 gnome-terminal-
4118 serv 20 0 8220884 1,3g 20704 S 2,0 8,1 17:04.28 java
8666 serv 20 0 1201020 42848 6168 S 1,7 0,3 4:04.97 gulp watch
7898 serv 20 0 4671616 1,3g 63568 S 1,3 8,6 7:12.28 telegram-deskto
1387 root 20 0 2540 0 0 S 1,0 0,0 0:19.16 acpid
727 root 20 0 0 0 0 S 0,7 0,0 1:40.64 nvidia-modeset/
36487 serv 20 0 824816 61368 49868 S 0,7 0,4 0:03.52 chrome
1 root 20 0 169564 9516 4852 S 0,3 0,1 0:12.70 systemd
11 root 20 0 0 0 0 I 0,3 0,0 0:15.38 rcu_sched
354 root 20 0 0 0 0 S 0,3 0,0 0:02.53 jbd2/sda2-8
1684 root 20 0 1363284 412 0 S 0,3 0,0 0:15.74 teamviewerd
10876 serv 20 0 23,1g 250020 65600 S 0,3 1,5 0:54.34 slack
30898 root 20 0 0 0 0 I 0,3 0,0 0:00.17 kworker/u16:2-events_power_efficient
35942 serv 20 0 4601424 83936 63396 S 0,3 0,5 0:00.57 chrome
36457 serv 20 0 4696756 131380 81088 S 0,3 0,8 0:02.60 chrome
37788 root 20 0 20972 4368 3408 R 0,3 0,0 0:00.06 top
杀死 chrome 后从 root 获取 top 的输出
答案1
根据您通常运行的应用程序的数量/种类,您当前的 2G /swapfile 正在被蚕食。
free -h
通过使用命令并观察,确保没有某个特定的应用程序正在消耗交换空间swap used
。Chrome、一千个打开的标签页及其附加组件是已知的内存消耗大户。
我们将扩大/swapfile......
笔记:命令使用不当dd
可能导致数据丢失。建议复制/粘贴。
sudo swapoff -a # turn off swap
sudo rm -i /swapfile # remove old /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
sudo chmod 600 /swapfile # set proper file protections
sudo mkswap /swapfile # init /swapfile
sudo swapon /swapfile # turn on swap
free -h # confirm 16G RAM and 4G swap
reboot # reboot and verify operation