免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1259 | 回复: 0
打印 上一主题 下一主题

mount umount Linux 命令参考 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-23 10:51 |只看该作者 |倒序浏览

mount umount Linux
命令参考
辅助信息
磁针石
联系方式: gmail
and gtalk: xurongzhong#gmail.com

mount 安装文件系统
redhat 9 语法:
      
mount [-lhV]

      
mount -a [-fFnrsvw] [-t vfstype] [-O optlist]
      
mount [-fnrsvw] [-o options [,...]] device | dir
      
mount [-fnrsvw] [-t vfstype] [-o options] device dir

描述:

       标准格式:    mount -t type device dir
       使用该命令一般要求使用root用户,如果设备有在/etc/fstab列出并有对应的用户设置,普通用户也可以使用。比如:/dev/cdrom  /cd  iso9660
ro,user,noauto,unhide。 一般只有mount的用户可以unmount,要使所有的用户可以unmount,使用在/etc/fstab 添加users。
       如果您没有加上 -t 的参数,那么系统会预设尝试以
/etc/filesystems 内的档案系统格式来测试一下是否可以将装置挂载上来,如果仍然不行,则从内核中查找,/proc/filesystems
       mount
之后的 partition 就已经被设定在使用了,不可以使用 fsck 检查该,否则可能会造成 filesystem 的损毁,必须要将该 partition 给卸载才行!
       帮助如下:
# mount -h
Usage: mount -V                 : print version
      
mount -h                 : print
this help
      
mount                    : list
mounted filesystems
      
mount -l                 : idem,
including volume labels
So far the informational part. Next the
mounting.
The command is `mount [-t fstype] something
somewhere'.
Details found in /etc/fstab may be omitted.
      
mount -a [-t|-O] ...     : mount
all stuff from /etc/fstab
      
mount device             : mount
device at the known place
      
mount directory          : mount
known device here
      
mount -t type dev dir    :
ordinary mount command
Note that one does not really mount a
device, one mounts
a filesystem (of the given type) found on
the device.
One can also mount an already visible
directory tree elsewhere:
      
mount --bind olddir newdir
or move a subtree:
      
mount --move olddir newdir
A device can be given by name, say
/dev/hda1 or /dev/cdrom,
or by label, using  -L label
or by uuid, using  -U uuid .
Other options: [-nfFrsvw] [-o options].
For many more details, say  man 8 mount .


常用参数:
mount -V                 : 查看版本
mount -h                 : 查看帮助
mount                    : 查看安装的文件系统
mount -l                 :
idem, including volume labels

-a  :依照 /etc/fstab 的内容将所有相关的磁盘都挂上来!
-n  :一般来说,当我们挂载档案系统到 Linux 上头时, Linux
会主动的将
      目前的 partition 与 filesystem 还有对应的挂载点,都记录到 /etc/mtab
      那个档案中。不过,有些时刻 (例如不正常关机导致一些问题,而进入单人模式)
      系统无法写入 /etc/mtab 时,就可以加上 -n 这个参数来略过写入 mtab 的动作。
-L  :系统除了利用装置名称代号 (例如 /dev/hda1) 之外,还可以利用 partition
      的表头名称 ( Label ) 来进行挂载喔!所以,最好为您的
partition 取一个
      在您系统当中独一无二的名称吧!
-t  :您的 Linux 支持的档案格式,就写在这里吧!举例来说,我们在上面建立
      /dev/hdb5 是 ext3 档案系统,那么要挂载时,就得要加上 -t ext3
      来告知系统,用 ext3 的档案格式来挂载该 partition 呢!
      至于系统支持的 filesystem 类型在
/lib/modules/`uname -r`/kernel/fs 当中。
      常见的有:
         ext2, ext3,
reiserfs, 等 Linux 惯用
filesystem
         vfat,
msdos 等 Windows 常见
filesystem
         iso9660 为光盘片的格式
         nfs, smbfs
等为网络相关档案系统。这部分未来我们会在网络方面提及!
      若 mount 后面没有加 -t 档案系统格式时,则 Linux 在预设的情况下,
      会主动以 /etc/filesystems 这个档案内规范的档案系统格式
      来尝试主动的挂载喔!
-o  :后面可以接一些挂载时,额外加上的参数喔!比方说账号、密码、读写权限等:
      ro, rw:       此
partition 为只读(ro) 或可擦写(rw)
      async,
sync:  此 partition 为同步写入 (sync) 或异步 (async),这个与我们
                  
之前提到的
档案系统运作方式
有关,预设是 async
      auto, noauto:
允许此 partition 被以
mount -a 自动挂载(auto)
      dev,
nodev:   是否允许此 partition 上,可建立装置档案? dev 为可允许
      suid, nosuid:
是否允许此 partition 含有 suid/sgid 的档案格式?
      exec, noexec:
是否允许此 partition 上拥有可执行 binary 档案?
      user, nouser:
是否允许此 partition 让 user 执行 mount ?一般来说,
                  
mount 仅有 root 可以进行,但下达 user 参数,则可让
                  
一般 user 也能够对此
partition 进行 mount 。
     
defaults:     默认值为:rw, suid, dev, exec, auto, nouser, and async
      remount:      重新挂载,这在系统出错,或重新更新参数时,很有用!

实例:
*挂载ext3类型
mount /dev/md0  /home/meil/software
这里省略了-t ext3,系统能自动识别这个类型
*查看结果:# mount -l
/dev/hda1 on / type ext3 (rw) [/]
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type
usbdevfs (rw)
none on /dev/pts type devpts
(rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
/dev/sda1 on /mnt/sda1 type ext3
(rw) []
/dev/hda3 on /opt type ext3 (rw)
[]
/dev/md0 on /home/meil/software
type ext3 (rw) []
*   
按类型查看mount结果
# mount -l -t ext3
/dev/hda1 on / type ext3 (rw) [/]
/dev/sda1 on /mnt/sda1 type ext3 (rw) []
/dev/hda3 on /opt type ext3 (rw) []
/dev/md0 on /home/meil/software type ext3 (rw) []

*   
加载软盘
mount -t msdos /dev/fd0 /mntMS-DOS 是指老的dos格式,现在一般是vfat格式了。mount -t vfat /dev/fd0 /mnt/floppy
*   
挂载目录
mount -t ext3 /dev/hda2 /mnt将 /home 这个目录暂时挂载到 /tmp/home 底下:mount --bind /home /tmp/home
*   
挂载光驱

# mount /dev/cdrom
只读方式:mount -t iso9660 -r /dev/cdrom /mnt


*   
将 / 重新挂载,并加入参数为 rw
!:
mount -o remount,rw /
*   
将 Label 名为 logical 的 partition 挂载到 /mnt/hdb5 中:
# mount -t ext3 -L logical /mnt/hdb5
*   
自动转换MS-DOS(CR-LF在每行结尾) 和unix格式  
mount -o conv=auto -t msdos /dev/fd0 /mnt

相关命令:umount(2), mount(8), losetup(8).
AIX 参考:
http://www.kuqin.com/aixcmds/aixcmds3/mount.htm


umount 卸载文件系统
redhat 9 语法:
       umount [-hV]

       umount -a [-dflnrv] [-t vfstype] [-O
options]
       umount [-dflnrv] dir | device [...]

帮助:
# umount -h
Usage: umount [-hV]
       umount -a [-f] [-r] [-n] [-v] [-t
vfstypes] [-O opts]
       umount [-f] [-r] [-n] [-v] special |
node...

重要参数:
   
       -a  删除fstab中所有的文件系统
       -f  强制umount,主要针对不可达的NFS。

       -l
懒惰模式,先删除文件系统层次。等文件系统不忙的时候清空所有连接。
实例
umount /dev/fd0
umount /mnt
    umount的时候可以使用目录名,或者设备名,但是要注意一个设备用可能mount到了多个目录。

相关命令:umount(2), mount(8), losetup(8).

               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/21908/showart_1089473.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP