为什么“ df”挂起?


22

我最近在运行时遇到了问题df,它只是在那里。这是strace输出,在其中,您将看到我被杀了,因为它只是坐在那里:

$ strace /bin/df
execve("/bin/df", ["/bin/df"], [/* 35 vars */]) = 0
brk(0)                                  = 0x8d03000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7840000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=90781, ...}) = 0
mmap2(NULL, 90781, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7829000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/i686/cmov/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240o\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1401000, ...}) = 0
mmap2(NULL, 1415544, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb76cf000
mprotect(0xb7822000, 4096, PROT_NONE)   = 0
mmap2(0xb7823000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x153) = 0xb7823000
mmap2(0xb7826000, 10616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7826000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb76ce000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb76ce8d0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb7823000, 8192, PROT_READ)   = 0
mprotect(0xb785e000, 4096, PROT_READ)   = 0
munmap(0xb7829000, 90781)               = 0
brk(0)                                  = 0x8d03000
brk(0x8d24000)                          = 0x8d24000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1534656, ...}) = 0
mmap2(NULL, 1534656, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7557000
close(3)                                = 0
open("/etc/mtab", O_RDONLY)             = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=708, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb783f000
read(3, "/dev/sda6 / ext4 rw,errors=remou"..., 4096) = 708
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0xb783f000, 4096)                = 0
statfs64("/", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=4805813, f_bfree=3325193, f_bavail=3081072, f_files=1220608, f_ffree=1007617, f_fsid={-1624337824, -871214780}, f_namelen=255, f_frsize=4096}) = 0
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb783f000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2570
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0xb783f000, 4096)                = 0
open("/usr/share/locale/en_ZA.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_ZA/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
statfs64("/lib/init/rw", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=1280, f_bfree=1280, f_bavail=1280, f_files=215959, f_ffree=215956, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/run", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=102000, f_bfree=101823, f_bavail=101823, f_files=215959, f_ffree=215559, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/sys", 84, {f_type="SYSFS_MAGIC", f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/dev", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=508762, f_bfree=508762, f_bavail=508762, f_files=213490, f_ffree=213031, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/run/shm", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=203999, f_bfree=203816, f_bavail=203816, f_files=215959, f_ffree=215955, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/dev/pts", 84, {f_type="DEVPTS_SUPER_MAGIC", f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/boot", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=1024, f_blocks=188403, f_bfree=150550, f_bavail=140822, f_files=48768, f_ffree=48525, f_fsid={-655942775, 1382872797}, f_namelen=255, f_frsize=1024}) = 0
statfs64("/home", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=66535124, f_bfree=6683145, f_bavail=3303357, f_files=16900096, f_ffree=16633097, f_fsid={-515912651, 307591087}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/sys/fs/fuse/connections", 84, {f_type=0x65735543, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
statfs64("/home/wena/temp/mount", 84, ^C <unfinished ...>

另一个失败的工具是gnome-system-monitor,启动后似乎也立即挂起。


我的coreutils版本是8.13-2,在Debian Unstable中运行。
tshepang 2011年

还有其他矮人要塞吗?
科里·克莱因

@CoryKlein:那是什么?
tshepang 2011年

1
处于alpha开发阶段的游戏,这是Minecraft的灵感来源。偶尔会挂起。在谷歌上搜索解决这种问题的方法导致我在这里。
科里·克莱因

Answers:


23

我曾经sshfs从某些ssh服务器挂载目录,但网络连接丢失。似乎df是试图列出该安装,而不是正常失败,它只是卡住了:(


2
您可以执行一个懒惰卸载umount -l /path-to/mount来解决此问题。
ewwhite

12
它不会因为没有失败而优雅地失败:它耐心地等待服务器回复。
吉尔(Gilles)“所以,别再邪恶了”,

18
df -l工作?
Abhishek

1
@吉尔斯:停顿问题的经典例子。
Casualunixer 2011年

顺便说一下,SMB挂载也会发生这种情况。非常相关:安装问题。和统计系统调用
大卫Tonhofer

8

诸如df挂起之类的软件的最常见原因是当他们试图从响应不正确的磁盘读取数据时。

检查来自的输出dmesg以查看是否是这种情况-不稳定的驱动器会抛出很多错误。

不幸的是,这往往是硬件问题,您可能正在考虑必须更换整个驱动器。我建议您尽可能备份所有内容。


4

此处不是这种情况,但为了记录在案,请注意,某些GNU实现的df版本(自7.3版本起,已在8.29中修复(带有此commit))挂在没有编写器的可读fifo /命名管道文件上,因为它们试图打开它们,如https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29038中所示

$ mkfifo fifo
$ strace df fifo
[...]
open("fifo", O_RDONLY|O_NOCTTY  # hanging there

解决此问题的方法是什么?
karthik101 '18

@ karthik101,请参见编辑:升级到8.29或不要在fifos上使用df。
斯特凡Chazelas

从源代码安装,效果很好。
karthik101 '18

2

我的根本原因是不寻常的,但无论如何我都会提到这一点,以防有人犯同样的错误。我是用cifs/etc/auto.directUbuntu上16.04.4(最近从16.04升级到)。我没有加vers=1.0

向后兼容性-软件最大的神话之一。



0

我遇到了同样的问题,重启下面的服务为我工作。

$ systemctl重新启动proc-sys-fs-binfmt_misc.mount


0

上述答案未涵盖的另一种情况:

以我为例,使用时strace df,我发现df在尝试文件系统时它挂起statfskeybase

$ strace df
...   # many lines omitted for brevity
statfs("/run/user/1000/keybase/kbfs", <--- hangs here
^Cstrace: Process 17510 detached

注销(然后重新登录)以keybase解决此特定问题:

$ keybase logout
$ df  # doesn't hang anymore
...

$ keybase login
$ df  # still ok
...
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.