日期:2014-05-16  浏览次数:20684 次

详细介绍Linux mount命令使用

Linux mount命令是经常会使用到的命令,它用于挂载Linux系统外的文件,此命令的最常用于挂载cdrom,使我们可以访问cdrom中的数据,因为你将光盘插入cdrom中,Linux并不会自动挂载,必须使用Linux mount命令来手动完成挂载。

Linux显示所有的目录都在一个目录树下,而于他们位于哪一个驱动器/硬件无关。在Linux下的磁盘内容作为子目录形式出现的。

用Linux mount命令来挂载cdrom.

命令:
mount -t auto /dev/cdrom /mnt/cdrom

这命令就是把cdrom挂载在/mnt/cdrom目录中,这里我就可以访问里面的内容了。

学习操作过程:
[OK_008@CentOS4 ~]$ mount -t auto /dev/cdrom /mnt/cdrom
mount: only root can do that? --一般用户无法挂载cdrom,只有root用户才可以操作。
[OK_008@CentOS4 ~]$

--切换用户操作:
[root@CentOS4 /]# mount -t auto /dev/cdrom /mnt/cdrom
mount: mount point /mnt/cdrom does not exist --/mnt/cdrom目录不存在,需要先创建。
[root@CentOS4 /]# cd /mnt
-bash: cd: /mnt: No such file or directory
[root@CentOS4 /]#?
[root@CentOS4 /]# mkdir -p /mnt/cdrom? --创建/mnt/cdrom目录
[root@CentOS4 /]# ls
bin?? dev? home??? lib???????? media? mnt? proc? sbin???? srv? tmp? var
boot? etc? initrd? lost+found? misc?? opt? root? selinux? sys? usr
[root@CentOS4 /]# mount -t auto /dev/cdrom /mnt/cdrom? --挂载cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only --挂载成功
[root@CentOS4 /]# ls -l /mnt/cdrom --查看cdrom里面内容
total 859
dr-xr-xr-x? 4 root root?? 2048 Sep? 4? 2005 CentOS
-r--r--r--? 2 root root?? 8859 Mar 19? 2005 centosdocs-man.css
-r--r--r--? 9 root root? 18009 Mar? 1? 2005 GPL
dr-xr-xr-x? 2 root root 241664 May? 7 02:32 headers
dr-xr-xr-x? 4 root root?? 2048 May? 7 02:23 images
dr-xr-xr-x? 2 root root?? 4096 May? 7 02:23 isolinux
dr-xr-xr-x? 2 root root? 18432 May? 2 18:50 NOTES
-r--r--r--? 2 root root?? 5443 May? 7 01:49 RELEASE-NOTES-en.html
dr-xr-xr-x? 2 root root?? 2048 May? 7 02:34 repodata
-r--r--r--? 9 root root?? 1795 Mar? 1? 2005 RPM-GPG-KEY
-r--r--r--? 2 root root?? 1795 Mar? 1? 2005 RPM-GPG-KEY-centos4
-r--r--r--? 1 root root 571730 May? 7 01:39 yumgroups.xml
[root@CentOS4 /]#?
[root@CentOS4 /]# umount /mnt/cdrom? --卸载cdrom,很容易,直接使用umount /mnt/cdrom 即可。

另mount命令其他参数说明可以参考如下:

名称 : mount?
使用权限 : 系统管理者或/etc/fstab中允许的使用者?
使用方式 :?
mount [-hV]?
mount -a [-fFnrsvw] [-t vfstype]?