Linux从设备本身中运行的脚本中卸载设备 [英] Linux umount a device from a script running in the device itself

查看:125
本文介绍了Linux从设备本身中运行的脚本中卸载设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在路径中有一个已装载的iso映像:

I've a mounted iso image in the path:

/mnt/iso

在这个iso里面,我有一个安装脚本install.sh 我从iso运行安装脚本,最后该脚本询问用户是否要卸载iso本身. 如果用户按下"y",脚本将执行以下代码:

Inside this iso I've an install script install.sh I run the installation script from the iso and at the end the script ask to the user if he want to umount the iso itself. If the user press "y" the script execute the following code:

cd /
umount /mnt/iso
echo "Installation completed!"

不幸的是,当脚本尝试执行umount时出现错误

Unfortunately when the script tries to execute the umount there's an error

umount: /mnt/iso: device is busy

我想这是由于虚拟设备正因脚本本身而忙碌. 如何使其工作? Tnx

I suppose it's due to the fact that the virtual device is busy from the script itself. How can make it work? Tnx

推荐答案

使用-l--lazy开关切换到umount,这将执行惰性卸载,仅在不再使用时将其完全卸载.使用.手册页(这是特定于linux的选项)中的完整描述是:

Use the -l or --lazy switch to umount which will do a lazy umount, where it is only fully unmounted once it is no longer in use. The full description in the manual page (this is a linux specific option) is:

懒惰卸载.从文件系统层次结构中分离文件系统 现在,并在不存在时立即清除对文件系统的所有引用 忙了. (需要内核2.4.11或更高版本.)

Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)

这篇关于Linux从设备本身中运行的脚本中卸载设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆