Chinaunix

标题: 讨论一下:mount 时会不会提示本地目录已经mount了一个了? [打印本页]

作者: q1208c    时间: 2004-02-24 12:40
标题: 讨论一下:mount 时会不会提示本地目录已经mount了一个了?
昨天mount 了一张光盘在光驱里(/mnt/cdrom)。早上来了不记得了。
mount 了一个 win2000的共享目录在/mnt/cdrom,用完了umount 了。
无意中df -h 了一下,发现有 /dev/cdrom /mnt/cdrom 在,有650M。
按光驱,不开门,eject cdrom 后,弹出一张光盘。

不知道有没有什么办法可以防止在本地目录上 mount 两次呀?
作者: platinum    时间: 2004-02-24 12:45
标题: 讨论一下:mount 时会不会提示本地目录已经mount了一个了?
我也是,有的时候自己MOUNT了还不知道,又来了一遍
我觉得编个SHELL,检查ps -ax|grep "mount xxx",如果存在,就放弃,这样可行嘛?
作者: ripenabc    时间: 2004-02-24 13:22
标题: 讨论一下:mount 时会不会提示本地目录已经mount了一个了?
那是光盘没有锁定,可以考虑用SHELL来解决,改装一个mount和umout
作者: 零二年的夏天    时间: 2004-02-24 14:06
标题: 讨论一下:mount 时会不会提示本地目录已经mount了一个了?
那为什么不多建一个目录呢?
作者: q1208c    时间: 2004-02-24 17:09
标题: 讨论一下:mount 时会不会提示本地目录已经mount了一个了?
不是没多建,而是忘了已经mount 过一个了。
作者: 零二年的夏天    时间: 2004-02-24 23:32
标题: 讨论一下:mount 时会不会提示本地目录已经mount了一个了?
试试这个脚本。

  1. #!/bin/bash
  2. #
  3. #Name : MyMount
  4. #Author : PopZslam
  5. #Descript : To avoid mount a device twice or more
  6. #
  7. #---------------
  8. _MOUNTTABLENOPATH=`mount|awk -F"/" '{ print $3; }'`
  9. _MOUNTTABLED=`mount|awk '{ print $3"/"; }'`

  10. # Check if the device is used or not.
  11. # If you needn't the path
  12. echo "$_MOUNTTABLENOPATH"|grep $1 1>;/dev/null
  13.         if [ $? -eq 0 ] ; then
  14.         printf "\n\tThe device that you want mount is USED !\n\n"
  15.         exit 0
  16.         fi
  17. # Check if the directory is used or not.This situation will effect
  18. # when you want to mount a floppy disk or a CD device.
  19. echo $_MOUNTTABLED|grep $1 1>;/dev/null
  20. if [ $? -eq 0 ] ; then
  21.         printf "\n\tThe directory that you want mount is USED !\n\n"
  22.         exit 0
  23. fi
  24. # Check if the directory is used or not.
  25. echo $2|grep "mnt" 1>;/dev/null
  26. if [ $? -eq 0 ] ; then
  27.         echo $_MOUNTTABLED|grep $2 1>;/dev/null
  28.         if [ $? -eq 0 ] ; then
  29.         printf "\n\tThe directory that you want mount is USED !\n\n"
  30.         exit 0
  31.         fi
  32. fi

  33. # Exec the command
  34. mount $1 $2

  35. #------------------
  36. #End
复制代码


如在使用时有问题请指正!
想再简化些,可是不会了。

作者: ulovko    时间: 2012-04-25 14:57
这玩意确实会覆盖!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2