mount命令应用和umount命令应用
创始人
2024-02-26 13:35:21
0

记录:348

场景:在CentOS 7.9操作系统上,使用mount命令挂载镜像到指定目录、挂载磁盘到指定目录;使用umount命令卸载已挂载到指定目录的磁盘或者镜像。

版本:

操作系统:CentOS 7.9

1.mount命令应用

(1)把iso镜像挂载到指定目录

命令:mount -o loop /home/apps/software/CentOS-7-x86_64-Everything-2009.iso /mnt/local_iso/

解析:把CentOS-7-x86_64-Everything-2009.iso镜像挂载到指定的/mnt/local_iso/目录;loop是挂载loop设备类型。

(2)把磁盘挂载到指定目录

命令:mount /dev/sdb  /mnt/data

解析:/dev/sdb是磁盘在系统中的设备路径,系统新加的一个磁盘,需要创建文件系统和挂载到指定目录后,才能使用其存储空间。

(3)把磁盘分区挂载到指定目录

场景:磁盘/dev/sdb划分了两个分区,/dev/sdb1和/dev/sdb2,挂载时候,就直接使用分区挂载。

挂载磁盘分区1到目录:mount /dev/sdb1 /mnt/hz_data01

挂载磁盘分区2到目录:mount /dev/sdb2 /mnt/hz_data02

解析:/dev/sdb是磁盘在系统中的设备路径,/dev/sdb1和/dev/sdb2是磁盘在系统中两个分区的路径。

2.umount命令应用

(1)卸载已挂载到目录的iso镜像

卸载命令:umount /mnt/local_iso/

解析:卸载后,需要使用,必须重新挂载。

(2)卸载已挂载到目录的磁盘

卸载目录已挂载的磁盘:umount /dev/sdb

解析:执行umount后,目录就不可用了,也就无法使用磁盘空间了,如需使用,需重新挂载。

(3)卸载已挂载到目录的磁盘分区

卸载目录已挂载的磁盘分区sdb1:umount /dev/sdb1

卸载目录已挂载的磁盘分区sdb2:umount /dev/sdb2

解析:执行umount后,目录就不可用了,也就无法使用磁盘空间了,如需使用,需重新挂载。

3.命令帮助手册

(1)mount命令帮助手册

命令:mount --help

解析:查看mount支持的全部命令和选项,在实际工作中,查看这个手册应该是必备之选。

Usage:mount [-lhV]mount -a [options]mount [options] [--source]  | [--target] mount [options]  mount   []Options:-a, --all               mount all filesystems mentioned in fstab-c, --no-canonicalize   don't canonicalize paths-f, --fake              dry run; skip the mount(2) syscall-F, --fork              fork off for each device (use with -a)-T, --fstab       alternative file to /etc/fstab-h, --help              display this help text and exit-i, --internal-only     don't call the mount. helpers-l, --show-labels       lists all mounts with LABELs-n, --no-mtab           don't write to /etc/mtab-o, --options     comma-separated list of mount options-O, --test-opts   limit the set of filesystems (use with -a)-r, --read-only         mount the filesystem read-only (same as -o ro)-t, --types       limit the set of filesystem types--source       explicitly specifies source (path, label, uuid)--target    explicitly specifies mountpoint-v, --verbose           say what is being done-V, --version           display version information and exit-w, --rw, --read-write  mount the filesystem read-write (default)-h, --help     display this help and exit-V, --version  output version information and exitSource:-L, --label 

(2)umount命令帮助手册

命令:umount --help

解析:查看umount支持的全部命令和选项,在实际工作中,查看这个手册应该是必备之选。

Usage:umount [-hV]umount -a [options]umount [options]  | Options:-a, --all               unmount all filesystems-A, --all-targets       unmount all mountpoins for the given devicein the current namespace-c, --no-canonicalize   don't canonicalize paths-d, --detach-loop       if mounted loop device, also free this loop device--fake              dry run; skip the umount(2) syscall-f, --force             force unmount (in case of an unreachable NFS system)-i, --internal-only     don't call the umount. helpers-n, --no-mtab           don't write to /etc/mtab-l, --lazy              detach the filesystem now, and cleanup all later-O, --test-opts   limit the set of filesystems (use with -a)-R, --recursive         recursively unmount a target with all its children-r, --read-only         In case unmounting fails, try to remount read-only-t, --types       limit the set of filesystem types-v, --verbose           say what is being done-h, --help     display this help and exit-V, --version  output version information and exitFor more details see umount(8).

以上,感谢。

2022年11月28日

相关内容

热门资讯

喜欢穿一身黑的男生性格(喜欢穿... 今天百科达人给各位分享喜欢穿一身黑的男生性格的知识,其中也会对喜欢穿一身黑衣服的男人人好相处吗进行解...
发春是什么意思(思春和发春是什... 本篇文章极速百科给大家谈谈发春是什么意思,以及思春和发春是什么意思对应的知识点,希望对各位有所帮助,...
网络用语zl是什么意思(zl是... 今天给各位分享网络用语zl是什么意思的知识,其中也会对zl是啥意思是什么网络用语进行解释,如果能碰巧...
为什么酷狗音乐自己唱的歌不能下... 本篇文章极速百科小编给大家谈谈为什么酷狗音乐自己唱的歌不能下载到本地?,以及为什么酷狗下载的歌曲不是...
家里可以做假山养金鱼吗(假山能... 今天百科达人给各位分享家里可以做假山养金鱼吗的知识,其中也会对假山能放鱼缸里吗进行解释,如果能碰巧解...
华为下载未安装的文件去哪找(华... 今天百科达人给各位分享华为下载未安装的文件去哪找的知识,其中也会对华为下载未安装的文件去哪找到进行解...
四分五裂是什么生肖什么动物(四... 本篇文章极速百科小编给大家谈谈四分五裂是什么生肖什么动物,以及四分五裂打一生肖是什么对应的知识点,希...
怎么往应用助手里添加应用(应用... 今天百科达人给各位分享怎么往应用助手里添加应用的知识,其中也会对应用助手怎么添加微信进行解释,如果能...
苏州离哪个飞机场近(苏州离哪个... 本篇文章极速百科小编给大家谈谈苏州离哪个飞机场近,以及苏州离哪个飞机场近点对应的知识点,希望对各位有...
客厅放八骏马摆件可以吗(家里摆... 今天给各位分享客厅放八骏马摆件可以吗的知识,其中也会对家里摆八骏马摆件好吗进行解释,如果能碰巧解决你...