mount 掛載檔案系統,umount 卸載。本文整理常用參數、檔案系統類型、掛載選項、中文亂碼處理、權限控制、自動掛載、Samba/ISO/Loop 掛載、--bind 目錄綁定、device busy 解決方案。
mount [-參數] [裝置名稱] [掛載點]
-a:依 /etc/fstab 掛載所有-t:指定檔案系統類型 (ext4, vfat, ntfs, iso9660, nfs, auto...)-o:掛載選項(多選項以逗號分隔)| 選項 | 說明 |
|---|---|
defaults | 預設值 (rw, suid, dev, exec, auto, nouser, async) |
ro / rw | 唯讀 / 讀寫 |
remount | 重新掛載已掛載系統 (常用於修改參數後生效) |
loop | 掛載映像檔 (ISO) |
codepage=936,iocharset=cp936 | 解決 FAT/NTFS 中文檔名亂碼 (簡體中文) |
umask=000 | 允許一般用戶讀寫 |
mkdir /mnt/win_d
mount -t vfat -o codepage=936,iocharset=cp936 /dev/sda5 /mnt/win_d
mkdir /mnt/iso
mount -o loop ubuntu.iso /mnt/iso
mount -t cifs -o username=user,password=pass,iocharset=utf8 //192.168.1.100/share /mnt/share
mount --bind /source/dir /target/dir
# 取消綁定
umount /target/dir
# 寫入 fstab
/source/dir /target/dir none bind 0 0
/dev/sda5 /mnt/win_d vfat defaults,codepage=936,iocharset=cp936,rw 0 0
原因:有程序正在存取該掛載點。
umount -l /mnt/point (lazy unmount,待閒置再卸載)lsof /mnt/point 或 fuser -mv /mnt/point 找出佔用 PID → kill -9 PID → umount