Linux 常用命令指南 - mount命令 挂载Linux系统内外的文件

Linux 常用命令指南 - mount命令 挂载Linux系统内外的文件



一、mount是什么?

Linux mount命令是经常会使用到的命令,它用于挂载Linux系统内外的文件。常用的外设(USB、DVD/CD、硬盘等)都可以通过它直接挂载。

二、mount help 中文指南

以下是 mount --help 输出的中文指南:

$ mount --help 

用法:
 mount [-lhV]
 mount -a [选项]
 mount [选项] [--source] <> | [--target] <目录>
 mount [选项] <> <目录>
 mount <操作> <挂载点> [<目标>]

挂载文件系统。

选项:
 -a, --all               挂载 fstab 中的所有文件系统
 -c, --no-canonicalize   不对路径规范化
 -f, --fake              空运行;跳过 mount(2) 系统调用
 -F, --fork              对每个设备禁用 fork(-a 选项一起使用)
 -T, --fstab <路径>      /etc/fstab 的替代文件
 -i, --internal-only     不调用 mount.<type> 辅助程序
 -l, --show-labels       也显示文件系统标签
 -m, --mkdir[=<mode>]    alias to '-o X-mount.mkdir[=<mode>]'
 -n, --no-mtab           不写 /etc/mtab
     --options-mode <mode>
                         what to do with options loaded from fstab
     --options-source <source>
                         mount options source
     --options-source-force
                         force use of options from fstab/mtab
 -o, --options <列表>    挂载选项列表,以英文逗号分隔
 -O, --test-opts <列表>  限制文件系统集合(-a 选项一起使用)
 -r, --read-only         以只读方式挂载文件系统(-o ro)
 -t, --types <列表>      限制文件系统类型集合
     --source <>       指明源(路径、标签、uuid)
     --target <目标>     指明挂载点
     --target-prefix <path>
                         specifies path used for all mountpoints
 -v, --verbose           打印当前进行的操作
 -w, --rw, --read-write  以读写方式挂载文件系统(默认)
 -N, --namespace <ns>    perform mount in another namespace

 -h, --help              display this help
 -V, --version           display version

Source:
 -L, --label <label>     synonym for LABEL=<label>
 -U, --uuid <uuid>       synonym for UUID=<uuid>
 LABEL=<label>           specifies device by filesystem label
 UUID=<uuid>             specifies device by filesystem UUID
 PARTLABEL=<label>       specifies device by partition label
 PARTUUID=<uuid>         specifies device by partition UUID
 ID=<id>                 specifies device by udev hardware ID
 <设备>                  按路径指定设备
 <目录>                  绑定式挂载的挂载点(参阅 --bind/rbind)
 <文件>                  用于设置回环设备的常规文件

操作:
 -B, --bind              挂载其他位置的子树(-o bind)
 -M, --move              将子树移动到其他位置
 -R, --rbind             挂载其他位置的子树及其包含的所有子挂载(submount)
 --make-shared           将子树标记为 共享
 --make-slave            将子树标记为 从属
 --make-private          将子树标记为 私有
 --make-unbindable       将子树标记为 不可绑定
 --make-rshared          递归地将整个子树标记为 共享
 --make-rslave           递归地将整个子树标记为 从属
 --make-rprivate         递归地将整个子树标记为 私有
 --make-runbindable      递归地将整个子树标记为 不可绑定

更多信息请参阅 mount(8)

三、mount 常用场景

将硬盘 /dev/hda1 挂在 /mnt 之下。

$ mount /dev/hda1 /mnt

将硬盘 /dev/hda1 用只读模式挂在 /mnt 之下。

$ mount -o ro /dev/hda1 /mnt

将 image.iso 这个使用 loop 模式挂在 /mnt/cdrom之下。可以在不烧录成光碟的情况下查看iso内容。

$ mount -o loop ./image.iso /mnt/cdrom

当系统不能开机,硬盘未损坏时,可以借助一个usb启动盘进入到“只尝试不安装"的系统初始界面,进行拷贝硬盘数据。

# 前提: 借助usb启动盘进入到“只尝试不安装"的系统初始界面
$ sudo su - # 进入root用户
$ fdisk -l # 找到之前硬盘需要拷贝数据的硬盘,假设是/dev/nvme0n1p1
$ mount /dev/nvme0n1p1 /mnt # 挂载硬盘到本机的/mnt
$ cp -pr /mnt /media/xxx # 另一个插上的usb路径,用于拷贝数据

四、总结

mount命令除了可以挂载常用的外设(如USB、DVD/CD、硬盘等),还可以挂载不同的文件系统(udf, iso9660等)。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yusq77

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值