llinux--mount指令使用

文章目录

    • [1. 背景](#1. 背景)
    • [2. 命令选项](#2. 命令选项)
    • [3. 举例](#3. 举例)

1. 背景

在日常嵌入式开发中,经常需要对一些外插设备和网络设备进行挂载,常用的挂载指令为mount,现在对此指令进行记录总结。

2. 命令选项

  • 命令参数
bash 复制代码
# mount --help
BusyBox v1.37.0 (2025-12-05 18:01:56 CST) multi-call binary.

Usage: mount [OPTIONS] [-o OPT] DEVICE NODE

Mount a filesystem. Filesystem autodetection requires /proc.

        -a              Mount all filesystems in fstab
        -r              Read-only mount
        -t FSTYPE[,...] Filesystem type(s)
        -T FILE         Read FILE instead of /etc/fstab
        -O OPT          Mount only filesystems with option OPT (-a only)
-o OPT:
        loop            Ignored (loop devices are autodetected)
        [a]sync         Writes are [a]synchronous
        [no]atime       Disable/enable updates to inode access times
        [no]diratime    Disable/enable atime updates to directories
        [no]relatime    Disable/enable atime updates relative to modification time
        [no]dev         (Dis)allow use of special device files
        [no]exec        (Dis)allow use of executable files
        [no]suid        (Dis)allow set-user-id-root programs
        [r]shared       Convert [recursively] to a shared subtree
        [r]slave        Convert [recursively] to a slave subtree
        [r]private      Convert [recursively] to a private subtree
        [un]bindable    Make mount point [un]able to be bind mounted
        [r]bind         Bind a file or directory [recursively] to another location
        move            Relocate an existing mount point
        remount         Remount a mounted filesystem, changing flags
        ro              Same as -r

There are filesystem-specific -o flags.
  • 其中 mount [OPTIONS] [-o OPT] DEVICE NODE 为使用方法, DEVICE就是我们设备里面dev目录下的设备节点,NODE就是我们要挂载到的目录。

其中最主要的是-t 挂载系统和 -o挂载选项。

  • -t(type)用于显式声明要挂载的文件系统类型。如果不指定,mount 会自动探测(但有时会失败)。

常见文件系统类型:

类型 说明
ext4 Linux 标准日志文件系统
ext3 / ext2 旧版 Linux 文件系统
xfs 高性能日志文件系统(常用于服务器)
btrfs 支持快照、压缩等高级功能
vfat / msdos FAT16/FAT32(U盘、SD卡常用)
ntfs Windows NTFS(需 ntfs-3g 驱动)
iso9660 光盘镜像(.iso 文件)
tmpfs 基于内存的临时文件系统
proc 内核虚拟文件系统(/proc
sysfs 设备与驱动信息(/sys
nfs 网络文件系统
cifs / smbfs Windows 共享(SMB/CIFS)
  • -o 用于指定挂载时的行为参数,多个选项用逗号分隔(无空格)
选项 作用
ro 只读挂载(read-only)
rw 读写挂载(默认)
noexec 禁止执行该分区上的程序
nosuid 忽略 set-user-identifier / set-group-identifier 位
nodev 忽略设备文件(安全加固常用)
sync 同步写入(数据立即刷盘,安全但慢)
async 异步写入(默认,性能好)

3. 举例

  • 重新挂载根分区为读写(救援模式常用)
bash 复制代码
mount -o remount,rw /
  • 创建内存临时目录
bash 复制代码
sudo mount -t tmpfs -o size=100m tmpfs /tmp/mytmp
  • 挂载 ext4 分区
bash 复制代码
sudo mount -t ext4 /dev/sdb1 /mnt/data`
  • 挂载 U 盘(FAT32)
bash 复制代码
sudo mount -t vfat /dev/sdc1 /mnt/usb
  • 挂载 ISO 镜像
bash 复制代码
sudo mount -t iso9660 -o loop ubuntu.iso /mnt/iso
  • 挂载 nfs
bash 复制代码
sudo mount -t nfs -o nolock 192.168.100.100:/data/ /mnt/nfs
相关推荐
SHolmes185410 分钟前
Python all函数 判断是否同时满足多个条件
java·服务器·python
inksci10 分钟前
Python 中使用 SQL 连接池
服务器·数据库·python
fiveym15 分钟前
持续交付与持续部署(CD)深度解析:定义差异、流程架构与交付模式对比
运维·ci/cd·架构
PascalMing17 分钟前
ubuntu 24.04安装dotnet 10日志
linux·运维·ubuntu·dotnet10
optimistic_chen22 分钟前
【Docker入门】容器技术
linux·运维·服务器·docker·容器
Lueeee.23 分钟前
2.智梯云枢・全维管控广告系统——解决串口卡顿 + 优化稳定性
linux·运维·服务器
海清河晏11124 分钟前
Linux进阶篇:HTTP协议
linux·运维·http
June`26 分钟前
IO模型全解析:从阻塞到异步(高并发的reactor模型)
linux·服务器·网络·c++
AI_567833 分钟前
零基础学Linux:21天从“命令小白”到独立部署服务器
linux·服务器·人工智能·github
江湖有缘34 分钟前
Fenrus + Docker 实战:构建简洁高效的浏览器新标签页
运维·docker·容器