将文件系统与目录结合就成为挂载。挂载点一定是目录,且该目录是空目录,该目录就是这个文件系统的入口。
使用命令mount命令,取消挂载umount命令
首先man mount查看技术文档。
mount - mount a filesystem 挂载文件系统
语法:The standard form of the mount command, is mount -t type -o options device dir
选项:
-t :指定要挂载的文件系统类型,ext2/ext3/ext4/vfat/iso9660...
-o :额外的参数,如ro/rw,async/sync,auto/noauto...
device:是一个文件的名称或一个特殊的块设备,比如/dev/sda1,也可能是一个特殊的NFS设备名称可能是knuth.cwi.nl:/dir,这样就需要使用它的LABEL或UUID进行自动0挂载。
dir:挂载的目录
[root@www ~]# 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 One can change the type of mount containing the directory dir: mount --make-shared dir mount --make-slave dir mount --make-private dir mount --make-unbindable dir One can change the type of all the mounts in a mount subtree containing the directory dir: mount --make-rshared dir mount --make-rslave dir mount --make-rprivate dir mount --make-runbindable dir 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] [-p passwdfd]. For many more details, say man 8 mount .
查看所有挂载信息4个方法:
[root@www ~]# mount #直接输入mount命令查看 /dev/sda5 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) /dev/sda2 on /usr type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sdb1 on /home type ext4 (rw) /dev/sr0 on /mnt type iso9660 (ro) [root@www ~]# [root@www ~]# mount -v #查看所有挂载的详细信息 /dev/sda5 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) /dev/sda2 on /usr type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) [root@www ~]# e2label /dev/sdb1 myhome #设置卷标 [root@www ~]# dumpe2fs /dev/sdb1 | grep "volume" #查看卷标 dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: myhome [root@www ~]# umount /dev/sdb1 #取消挂载 [root@www ~]# mount -L myhome /home #使用-L 指定卷标来挂载 [root@www ~]# mount -l #可显示额外参数rw ro的信息以及卷标的信息,如本命令的最后一行 myhome /dev/sda5 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) /dev/sda2 on /usr type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sdb1 on /home type ext4 (rw) [myhome] [root@www ~]# cat /proc/mounts #显示详细的参数信息 rootfs / rootfs rw 0 0 proc /proc proc rw,relatime 0 0 sysfs /sys sysfs rw,seclabel,relatime 0 0 devtmpfs /dev devtmpfs rw,seclabel,relatime,size=500880k,nr_inodes=125220,mode=755 0 0 devpts /dev/pts devpts rw,seclabel,relatime,gid=5,mode=620,ptmxmode=000 0 0 tmpfs /dev/shm tmpfs rw,seclabel,relatime 0 0 /dev/sda5 / ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0 none /selinux selinuxfs rw,relatime 0 0 devtmpfs /dev devtmpfs rw,seclabel,relatime,size=500880k,nr_inodes=125220,mode=755 0 0 /proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0 /dev/sda1 /boot ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0 /dev/sda2 /usr ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0 none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
-t选项实例:-t +文件系统类型,如ext4,ext3,光盘格式iso9660,vfat格式
[root@www ~]# mount -t iso9660 /dev/sr0 /mnt/ #挂载光盘的实例 mount: block device /dev/sr0 is write-protected, mounting read-only [root@www ~]#
-a选项实例:
[root@www ~]# mount -a 依据/etc/fstab文件信息进行挂载所有
-o 选项额外参数介绍:
rw,ro 此文件系统成为只读或可写
async,sync 此文件系统是否使用同步写入或异步写入的内存机制(参考文件系统运行方式---重点)
auto,noauto 允许分区被mount -a 自动挂载
dev,nodev是否允许分区上可创建设备文件
suid,nosuid是否允许分区上含有suid/sgid的文件格式
exec,noexec 是否允许此分区上拥有可执行bin文件
user,nouser是否允许次分区让任何用户执行mount
defaults:默认值是rw,suid,dev,exec auto nouser,async
-remount 重新挂载,尤其是单人模式下,/目录会以只读模式挂载。