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
相关推荐
南山十一少几秒前
docker的安装及使用
运维·docker·容器
Willliam_william9 分钟前
CentOS 7系统中进行时间/时区设置
linux·运维·centos
李白的天不白10 分钟前
linux安装MongoDB
linux·运维·服务器
BioRunYiXue14 分钟前
从现象到机制:蛋白降解调控研究的系统策略与实验设计
java·linux·运维·服务器·网络·人工智能·eclipse
supersolon18 分钟前
OpenClaw安装碰到的一些问题和解决方法
linux·运维·ai·openclaw·龙虾
sdm07042737 分钟前
linux权限
linux·运维·服务器
yuezhilangniao38 分钟前
大白话AI运维K8S整体思路和相关名词-结合腾讯云
运维·人工智能·kubernetes
piepis1 小时前
Linux 下升级 Python 3.7 → 3.9(离线)并内网安装本地python-packages
linux·运维·python
SP八岐大兔1 小时前
Ollama安装及运行模型
linux·服务器·ollama
深念Y1 小时前
Nginx和Spring Cloud Gateway
运维·服务器·网络·网关·nginx·spring cloud·微服务