我有一些samba驱动器,每天都有多个用户访问。我已经有了识别共享驱动器(从SQL表)的代码,并将它们挂载到所有用户都可以访问它们的特殊目录中。
我想知道,如果我从我的SQL表中删除驱动器(有效地使其脱机)如何,甚至是,有一种方法来卸载繁忙的设备?到目前为止,我发现任何形式的umount都不起作用。
忽略破坏数据的可能性-是否有可能卸载当前正在读取的设备?
我有一些samba驱动器,每天都有多个用户访问。我已经有了识别共享驱动器(从SQL表)的代码,并将它们挂载到所有用户都可以访问它们的特殊目录中。
我想知道,如果我从我的SQL表中删除驱动器(有效地使其脱机)如何,甚至是,有一种方法来卸载繁忙的设备?到目前为止,我发现任何形式的umount都不起作用。
忽略破坏数据的可能性-是否有可能卸载当前正在读取的设备?
当前回答
众答:
如果该设备上有一个zfs池,至少当它是一个基于文件的池时,lsof将不会显示使用情况。但你可以简单地跑步
sudo zpool export mypool
然后卸载。
其他回答
当您尝试卸载时,请确保您不在已安装的设备中。
尝试下面的操作,但在运行之前请注意-k标志将终止所有使设备处于繁忙状态的正在运行的进程。
-i标志使fuser在kill前询问。
fuser -kim /address # kill any processes accessing file
unmount /address
以防有人和你一样。:
我无法卸载chroot监狱的挂载点(here /mnt)。
下面是我输入的命令:
$ umount /mnt
umount: /mnt: target is busy.
$ df -h | grep /mnt
/dev/mapper/VGTout-rootFS 4.8G 976M 3.6G 22% /mnt
$ fuser -vm /mnt/
USER PID ACCESS COMMAND
/mnt: root kernel mount /mnt
$ lsof +f -- /dev/mapper/VGTout-rootFS
$
您可以注意到,即使lsof也没有返回任何内容。
然后我有了这样的想法:
$ df -ah | grep /mnt
/dev/mapper/VGTout-rootFS 4.8G 976M 3.6G 22% /mnt
dev 2.9G 0 2.9G 0% /mnt/dev
$ umount /mnt/dev
$ umount /mnt
$ df -ah | grep /mnt
$
这里是一个/mnt/dev绑定到/dev,我创建它是为了能够从chroot监狱中修复我的系统。
在umounting之后,我的pb。现在解决了。
看看umount2:
Linux 2.1.116 added the umount2() system call, which, like umount(), unmounts a target, but allows additional flags controlling the behaviour of the operation: MNT_FORCE (since Linux 2.1.116) Force unmount even if busy. (Only for NFS mounts.) MNT_DETACH (since Linux 2.4.11) Perform a lazy unmount: make the mount point unavailable for new accesses, and actually perform the unmount when the mount point ceases to be busy. MNT_EXPIRE (since Linux 2.6.8) Mark the mount point as expired. If a mount point is not currently in use, then an initial call to umount2() with this flag fails with the error EAGAIN, but marks the mount point as expired. The mount point remains expired as long as it isn't accessed by any process. A second umount2() call specifying MNT_EXPIRE unmounts an expired mount point. This flag cannot be specified with either MNT_FORCE or MNT_DETACH. Return Value On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
在我的例子中,我无法卸载挂载到AFP共享目录的分区。(分享到Apple bonjour/avahi mdns世界) 我把服务器上的所有登录都移动到它们的主目录;我把所有远程连接的mac电脑都移到了其他目录下。 即使使用umount -f,我仍然无法卸载分区 所以我重启了服务器上的netatalk守护进程。 (/etc/netatalk/afp.conf中有共享分配) 日志含义重启netatalk后,不带-f参数,umount成功。