一 查询与自动挂载
mount
查询系统中已经挂载的设备
mount -a
依据配置文件/etc/fatab的内容,自动挂载
二 实战
[root@localhost ~]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=494100k,nr_inodes=123525,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/sda3 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda5 on /usr type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=29,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
/dev/sda7 on /mydata type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda2 on /var type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=101688k,mode=700)
[root@localhost ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Oct 26 22:38:33 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=7cd0e1c5-af95-4c66-a583-e7c0acd07ae7 / xfs defaults 0 0
UUID=a8da90cd-5ae5-4bdd-bdcf-389791fb52ab /boot xfs defaults 0 0
UUID=f19d115c-d8fd-4cdc-ba8c-bb9a6dc81383 /mydata xfs defaults 0 0
UUID=bd582cea-8cd3-45b6-87d0-5fcdb75202e2 /usr xfs defaults 0 0
UUID=c173cef0-b9f0-4758-ae54-73adbd162d93 /var xfs defaults 0 0
UUID=b2959ca7-662b-486a-92fd-c83982f27400 swap swap defaults 0 0
[root@localhost ~]# mount -a
三 挂载命令格式
mount [-t 文件系统] [-o 特殊选项] 设备文件名 挂载点
选项:
-t 文件系统:加入文件系统类型来指定挂载的类型,可以ext3、ext4、iso9660等文件系统
-o 特殊选项:可以指定挂载的额外选项。
四 特殊文件选项
五 特殊文件选项实战
[root@localhost home]# cp hello.sh /mydata/hello.sh
[root@localhost home]# cd /mydata
[root@localhost mydata]#
[root@localhost mydata]#
[root@localhost mydata]#
[root@localhost mydata]# ls
hello.sh
[root@localhost mydata]# ./hello.sh
Hello
[root@localhost mydata]# mount -o remount,noexec /mydata/
[root@localhost mydata]# ./hello.sh
-bash: ./hello. sh: Permission denied
[root@localhost mydata]# whoami
root
[root@localhost mydata]# mount -o remount,exec /mydata/
[root@localhost mydata]# ./hello.sh
Hello
六 挂载光盘
1、建立挂载点
mkdir /mnt/cdrom
2、挂载光盘
mount -t iso9660 /dev/cdrom /mnt/cdrom
mount /dev/sr0 /mnt/cdrom
七 挂载光盘实战
[root@localhost dev]# cd /media/
[root@localhost media]#
[root@localhost media]# mount -t iso9660 /dev/sr0 /media
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost media]# ll /dev/cdrom
lrwxrwxrwx. 1 root root 3 Jul 15 10:57 /dev/cdrom -> sr0
[root@localhost media]# ls /media/
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
八 卸载光盘命令
unmount 设备文件名或挂载点
九 卸载光盘实战
[root@localhost media]# umount /media
[root@localhost media]# ll
total 0
十 挂载U盘