当我尝试从 Windows 8.1 系统上的 Vagrant CentOS Virtual box 内部访问 SMB 安装文件夹时,我的 shell 被锁定

当我尝试从 Windows 8.1 系统上的 Vagrant CentOS Virtual box 内部访问 SMB 安装文件夹时,我的 shell 被锁定

我在 Windows 8.1 上运行 Oracle VirtualBox 4.3.10,里面运行的是 CentOS 6.5。我的 Windows 机器上通过 SMB 挂载了一个 /windows。通常我使用 /vagrant vboxfs 文件系统,但当我尝试查看 /windows 目录时,它会锁定我的 shell。我无法使用 ^C、^Z,也无法从 Putty 发送 SIGKILL 或任何其他信号。

[vagrant@localhost BK-Development]$ mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
//10.0.2.2/aidc on /windows type cifs (rw)
/vagrant on /vagrant type vboxsf (uid=500,gid=500,rw)

这是 ls 的 strace。

[vagrant@localhost ~]$ strace ls /windows
execve("/bin/ls", ["ls", "/windows"], [/* 39 vars */]) = 0
brk(0)                                  = 0x857000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63abd79000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=39412, ...}) = 0
mmap(NULL, 39412, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f63abd6f000
close(3)                                = 0
open("/lib64/libselinux.so.1", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0PX\200\270>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=124624, ...}) = 0
mmap(0x3eb8800000, 2221912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3eb8800000
mprotect(0x3eb881d000, 2093056, PROT_NONE) = 0
mmap(0x3eb8a1c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x3eb8a1c000
mmap(0x3eb8a1e000, 1880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3eb8a1e000
close(3)                                = 0
open("/lib64/librt.so.1", O_RDONLY)     = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@!\0\270>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=47064, ...}) = 0
mmap(0x3eb8000000, 2128816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3eb8000000
mprotect(0x3eb8007000, 2093056, PROT_NONE) = 0
mmap(0x3eb8206000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x3eb8206000
close(3)                                = 0
open("/lib64/libcap.so.2", O_RDONLY)    = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\23@\275>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19016, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63abd6e000
mmap(0x3ebd400000, 2111776, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3ebd400000
mprotect(0x3ebd404000, 2093056, PROT_NONE) = 0
mmap(0x3ebd603000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x3ebd603000
close(3)                                = 0
open("/lib64/libacl.so.1", O_RDONLY)    = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\36\300\273>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=33816, ...}) = 0
mmap(0x3ebbc00000, 2126416, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3ebbc00000
mprotect(0x3ebbc07000, 2093056, PROT_NONE) = 0
mmap(0x3ebbe06000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x3ebbe06000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\356A\267>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1926800, ...}) = 0
mmap(0x3eb7400000, 3750152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3eb7400000
mprotect(0x3eb758b000, 2093056, PROT_NONE) = 0
mmap(0x3eb778a000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18a000) = 0x3eb778a000
mmap(0x3eb778f000, 18696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3eb778f000
close(3)                                = 0
open("/lib64/libdl.so.2", O_RDONLY)     = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\300\267>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=22536, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63abd6d000
mmap(0x3eb7c00000, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3eb7c00000
mprotect(0x3eb7c02000, 2097152, PROT_NONE) = 0
mmap(0x3eb7e02000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x3eb7e02000
close(3)                                = 0
open("/lib64/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340]\200\267>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=145896, ...}) = 0
mmap(0x3eb7800000, 2212848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3eb7800000
mprotect(0x3eb7817000, 2097152, PROT_NONE) = 0
mmap(0x3eb7a17000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x3eb7a17000
mmap(0x3eb7a19000, 13296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3eb7a19000
close(3)                                = 0
open("/lib64/libattr.so.1", O_RDONLY)   = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\23\200\273>\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=21152, ...}) = 0
mmap(0x3ebb800000, 2113888, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3ebb800000
mprotect(0x3ebb804000, 2093056, PROT_NONE) = 0
mmap(0x3ebba03000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x3ebba03000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63abd6c000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63abd6a000
arch_prctl(ARCH_SET_FS, 0x7f63abd6a7a0) = 0
mprotect(0x3eb8a1c000, 4096, PROT_READ) = 0
mprotect(0x3eb8206000, 4096, PROT_READ) = 0
mprotect(0x3ebbe06000, 4096, PROT_READ) = 0
mprotect(0x3eb778a000, 16384, PROT_READ) = 0
mprotect(0x3eb7e02000, 4096, PROT_READ) = 0
mprotect(0x3eb6e1f000, 4096, PROT_READ) = 0
mprotect(0x3eb7a17000, 4096, PROT_READ) = 0
mprotect(0x3ebba03000, 4096, PROT_READ) = 0
munmap(0x7f63abd6f000, 39412)           = 0
set_tid_address(0x7f63abd6aa70)         = 20555
set_robust_list(0x7f63abd6aa80, 0x18)   = 0
futex(0x7fff8e671fec, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7fff8e671fec, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 7f63abd6a7a0) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0x3eb7805c60, [], SA_RESTORER|SA_SIGINFO, 0x3eb780f710}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x3eb7805cf0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x3eb780f710}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
statfs("/selinux", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=2242612, f_bfree=557842, f_bavail=443922, f_files=570080, f_ffree=265231, f_fsid={1226513072, 1470288141}, f_namelen=255, f_frsize=4096}) = 0
brk(0)                                  = 0x857000
brk(0x878000)                           = 0x878000
open("/proc/filesystems", O_RDONLY)     = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63abd78000
read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tb"..., 1024) = 328
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0x7f63abd78000, 4096)            = 0
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=99158576, ...}) = 0
mmap(NULL, 99158576, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f63a5ed9000
close(3)                                = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=46, ws_col=142, ws_xpixel=0, ws_ypixel=0}) = 0
stat("/windows",

这就是它被锁定的地方。这是完整版本。

[vagrant@localhost BK-Development]$ uname -a
Linux localhost.localdomain 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

答案1

我在 Windows 7 上遇到了同样的问题。Windows 会切断被视为不活动的连接,例如没有打开文件句柄的连接。

Linux VM 锁定,因为 CIFS 驱动程序不喜欢断开连接并且无法恢复。

它会影响进程,因为它们处于中断状态,等待 CIFS 文件系统驱动程序返回,但驱动程序永远不会返回。您无法终止它们,因为要终止它们需要发送中断信号,但它们在等待驱动程序时已经处于中断状态。更多详细信息请点击此处

您可以通过关闭 Windows 中的自动断开连接功能来防止出现此问题,这对我很有用。只需在命令提示符中运行:

net config server /autodisconnect:-1

相关内容