• mount命令应用和umount命令应用


    记录: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支持的全部命令和选项,在实际工作中,查看这个手册应该是必备之选。

    1. Usage:
    2. mount [-lhV]
    3. mount -a [options]
    4. mount [options] [--source] <source> | [--target]
    5. mount [options] <source>
    6. mount []
    7. Options:
    8. -a, --all mount all filesystems mentioned in fstab
    9. -c, --no-canonicalize don't canonicalize paths
    10. -f, --fake dry run; skip the mount(2) syscall
    11. -F, --fork fork off for each device (use with -a)
    12. -T, --fstab alternative file to /etc/fstab
    13. -h, --help display this help text and exit
    14. -i, --internal-only don't call the mount.<type> helpers
    15. -l, --show-labels lists all mounts with LABELs
    16. -n, --no-mtab don't write to /etc/mtab
    17. -o, --options comma-separated list of mount options
    18. -O, --test-opts limit the set of filesystems (use with -a)
    19. -r, --read-only mount the filesystem read-only (same as -o ro)
    20. -t, --types limit the set of filesystem types
    21. --source explicitly specifies source (path, label, uuid)
    22. --target explicitly specifies mountpoint
    23. -v, --verbose say what is being done
    24. -V, --version display version information and exit
    25. -w, --rw, --read-write mount the filesystem read-write (default)
    26. -h, --help display this help and exit
    27. -V, --version output version information and exit
    28. Source:
    29. -L, --label
    30. -U, --uuid synonym for UUID=
    31. LABEL=
    32. UUID= specifies device by filesystem UUID
    33. PARTLABEL=
    34. PARTUUID= specifies device by partition UUID
    35. specifies device by path
    36. mountpoint for bind mounts (see --bind/rbind)
    37. regular file for loopdev setup
    38. Operations:
    39. -B, --bind mount a subtree somewhere else (same as -o bind)
    40. -M, --move move a subtree to some other place
    41. -R, --rbind mount a subtree and all submounts somewhere else
    42. --make-shared mark a subtree as shared
    43. --make-slave mark a subtree as slave
    44. --make-private mark a subtree as private
    45. --make-unbindable mark a subtree as unbindable
    46. --make-rshared recursively mark a whole subtree as shared
    47. --make-rslave recursively mark a whole subtree as slave
    48. --make-rprivate recursively mark a whole subtree as private
    49. --make-runbindable recursively mark a whole subtree as unbindable
    50. For more details see mount(8).
    51. [root@hadoop200 ~]#

    (2)umount命令帮助手册

    命令:umount --help

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

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

    以上,感谢。

    2022年11月28日

  • 相关阅读:
    深入理解Python中的Lambda(匿名函数)
    Stable Diffusion 模型下载:Comic Babes(漫画宝贝)
    【C++基础】公有继承,保护继承,私有继承
    关于使用template时的错误注意
    sql靶场
    带约束条件的运筹规划问题求解(模拟退火算法实现)
    可视化学习:如何使用噪声生成纹理
    城市三维地理信息可视化 技术解析
    修改文件名后Git仓上面并没有修改
    YOLO V5 使用
  • 原文地址:https://blog.csdn.net/zhangbeizhen18/article/details/128085858