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
相关推荐
EasyGBS5 小时前
摄像头还在线,画面已经不能用了?国标GB28181视频平台EasyGBS视频质量诊断怎么用
服务器·安全·音视频
程序员-Benothing5 小时前
Vim编辑器从入门到精通:模式、快捷键、配置、插件
linux·运维·服务器
m0_646429975 小时前
Docker 完整核心知识点总结(超通俗易懂版)
运维·docker·容器
wdfk_prog5 小时前
LWIP教程 09:从 `tcp_slowtmr()` 到 Fast Retransmit——TCP 超时重传与重复 ACK
服务器·网络·数据库·网络协议·tcp/ip
‎ദ്ദിᵔ.˛.ᵔ₎5 小时前
linux 进程信号 (上)
linux·服务器
亚川楼宇自控系统数据中心厂家5 小时前
IBMS 集成管理系统:如何打通楼宇自控实现建筑一体化管控
运维
迪康Defender5 小时前
终端安全审批体系设计:如何平衡安全管控与业务连续性
运维·服务器·安全·运维开发·学习方法·业界资讯·远程工作
liulilittle6 小时前
Linux 下 select 测试函数
linux·服务器·网络·数据库·c++·select·c