当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > 讨论一下:mount 时会不会提示本地目录已经mount了一个了?

Unix/Linux
linux查看内存的大小
在linux下写的代码,用的是utf-8,结果拿到XP下运行的时候,所有的中文都成乱码
linux su和sudo命令的区别
linux cron 下的定时执行工具使用技巧
linux 查找进程及终止进程操作的相关命令
redhat linux 安装 gcc编译器
Linux Mplayer播放各种格式的电影
一起回顾一下linux常用命令
Linux 网站项目发布要做哪些配置
linux SSH配合SecureCRT的密匙完美使用方法
GD 编译出错解决方法
Facebook Open Platform编译FAQ
Linux 系统硬盘 优化
linux 挂载详解
linux crontab定时命令
Linux 系统中确保访问三级域名畅通的方法
Linux 特权帐号VS普通帐号
确保Linux系统安全的前提条件 漏洞防护
Linux 监视系统资源使用率
Red Hat Linux上使用BIND建立DNS服务器

Unix/Linux 中的 讨论一下:mount 时会不会提示本地目录已经mount了一个了?


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-01   浏览: 45 ::
收藏到网摘: n/a


昨天mount 了一张光盘在光驱里(/mnt/cdrom)。早上来了不记得了。
mount 了一个 win2000的共享目录在/mnt/cdrom,用完了umount 了。
无意中df -h 了一下,发现有 /dev/cdrom /mnt/cdrom 在,有650M。
按光驱,不开门,eject cdrom 后,弹出一张光盘。
不知道有没有什么办法可以防止在本地目录上 mount 两次呀?
platinum 回复于:2004-02-24 12:45:34 我也是,有的时候自己MOUNT了还不知道,又来了一遍
我觉得编个SHELL,检查ps -ax|grep "mount xxx",如果存在,就放弃,这样可行嘛?
ripenabc 回复于:2004-02-24 13:22:12 那是光盘没有锁定,可以考虑用SHELL来解决,改装一个mount和umout
零二年的夏天 回复于:2004-02-24 14:06:19 那为什么不多建一个目录呢?
q1208c 回复于:2004-02-24 17:09:16 不是没多建,而是忘了已经mount 过一个了。
零二年的夏天 回复于:2004-02-24 23:32:03 试试这个脚本。 [code:1:c6c686ca9d] #!/bin/bash # #Name : MyMount #Author : PopZslam #Descript : To avoid mount a device twice or more # #--------------- _MOUNTTABLENOPATH=`mount|awk -F"/" '{ print $3; }'` _MOUNTTABLED=`mount|awk '{ print $3"/"; }'` # Check if the device is used or not. # If you needn't the path echo "$_MOUNTTABLENOPATH"|grep $1 1>/dev/null if [ $? -eq 0 ] ; then printf "\n\tThe device that you want mount is USED !\n\n" exit 0 fi # Check if the directory is used or not.This situation will effect # when you want to mount a floppy disk or a CD device. echo $_MOUNTTABLED|grep $1 1>/dev/null if [ $? -eq 0 ] ; then printf "\n\tThe directory that you want mount is USED !\n\n" exit 0 fi # Check if the directory is used or not. echo $2|grep "mnt" 1>/dev/null if [ $? -eq 0 ] ; then echo $_MOUNTTABLED|grep $2 1>/dev/null if [ $? -eq 0 ] ; then printf "\n\tThe directory that you want mount is USED !\n\n" exit 0 fi fi # Exec the command mount $1 $2 #------------------ #End [/code:1:c6c686ca9d] 如在使用时有问题请指正! 想再简化些,可是不会了。 :D