我有一个VirtualBox的进程一直挂着,我试图结束它(KILL
/ABORT
),但是没有成功。该进程的父进程id是1(init)。
top
显示该进程为D
状态,文档中描述为“不可中断的休眠”状态。
strace
没有显示任何信息。
我该如何处理这个问题?这阻止了我卸载VirtualBox内核驱动程序以加载更新版本。
我有一个VirtualBox的进程一直挂着,我试图结束它(KILL
/ABORT
),但是没有成功。该进程的父进程id是1(init)。
top
显示该进程为D
状态,文档中描述为“不可中断的休眠”状态。
strace
没有显示任何信息。
我该如何处理这个问题?这阻止了我卸载VirtualBox内核驱动程序以加载更新版本。
简单回答:你不能。
更长的回答:不间断睡眠意味着进程将不会被信号唤醒。它只能被等待的事物唤醒。当我遇到这种情况,例如光盘驱动器时,通常会使用挂起到磁盘并恢复来重置计算机。
个人而言,在使用VirtualBox上的Windows,甚至是Wine时,我经常遇到由于CDROM I/O未能完成(我猜测这是某种光盘存在检查)而导致的问题。ATA设备可以被重置,这可能会解除进程阻塞。例如,我正在使用以下小脚本来重置我的两个光驱,解除它们所阻塞的进程:
echo 1 > /sys/block/sr0/delete
echo 1 > /sys/block/sr1/delete
echo "- - -" > /sys/class/scsi_host/host7/scan
/sys/block/srX/device/delete
而不是仅仅使用/sys/block/srX/delete
,但这个方法很有效! - genpfaultD状态基本上意味着进程正在等待磁盘I/O或其他无法中断的块I/O。有时这意味着内核或设备正在疯狂地尝试读取坏块(特别是来自光盘)。有时它意味着还有其他问题。
在进程退出D状态之前,无法将其终止。找出它正在等待什么并解决该问题。简单的方法是重新启动。有时删除相关的磁盘可以帮助解决问题,但这可能相当危险:如果不知道自己在做什么(即:冒烟),则会导致无法修复的灾难性硬件故障。
D
状态的进程,并且想要澄清,需要进行 硬重启 或者断电操作来移除该进程。kill -9 {process_id}
sync
echo 3 | sudo tee /proc/sys/vm/drop_caches
这似乎不会影响系统稳定性,但我不是系统程序员,也不确定可能会产生什么意外后果。
编辑:
根据内核文档,drop_caches
在开发环境中似乎相对安全。
drop_caches
Writing to this will cause the kernel to drop clean caches, as well as reclaimable slab objects like dentries and inodes. Once dropped, their memory becomes free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
echo 3 > /proc/sys/vm/drop_caches
This is a non-destructive operation and will not free any dirty objects. To increase the number of objects freed by this operation, the user may run `sync' prior to writing to /proc/sys/vm/drop_caches. This will minimize the number of dirty objects on the system and create more candidates to be dropped.
This file is not a means to control the growth of the various kernel caches (inodes, dentries, pagecache, etc...) These objects are automatically reclaimed by the kernel when memory is needed elsewhere on the system.
Use of this file can cause performance problems. Since it discards cached objects, it may cost a significant amount of I/O and CPU to recreate the dropped objects, especially if they were under heavy use. Because of this, use outside of a testing or debugging environment is not recommended.
You may see informational messages in your kernel log when this file is used:
cat (1234): drop_caches: 3
These are informational only. They do not mean that anything is wrong with your system. To disable them, echo 4 (bit 3) into drop_caches.
我在这里是新手,经验不丰富。但我遇到了相同的问题,当我使用htop检查进程状态时,我可以看到它们进入了不可中断的睡眠状态(D状态)。
由于某种原因,kill -9 <pid>
对我有用。也许你可以尝试一下。
编辑:详细的答案已经由ostrokach提供(我没有看到)。