Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux mkdir 提示「Read-only file system」三階段排查:掛載權限、檔案系統錯誤、硬體故障

編輯:關於 Linux

在 /opt 執行 mkdir test 報 mkdir: cannot create directory 'test': Read-only file system,但 mount 顯示掛載選項含 rw。經典三大可能:掛載選項實際為 ro、檔案系統髒位/錯誤需 fsck、底層儲存硬體故障。本文提供由輕到重的三階段排查流程。

Read-only file system 錯誤畫面

階段一:確認掛載選項真實狀態

mount | grep /opt
# 輸出應含 rw
/dev/sda10 on /opt type ext3 (rw,acl,user_xattr)
  • 若顯示 ro → 檢查 /etc/fstab 對應行是否為 defaults 或明確 rw,修正後 mount -o remount,rw /opt。
  • 若顯示 rw 仍報錯 → 進入階段二。

階段二:檔案系統錯誤修復

  1. 確認無進程佔用:
    fuser -m /dev/sda10
    若有進程(如 httpd),先停止服務:
    systemctl stop httpd
  2. 卸載分區:
    umount /opt
  3. 執行 fsck 自動修復(ext3/ext4):
    fsck -V -a /dev/sda10
    -V 顯示版本,-a 自動確認修復(非互動)。
  4. 掛載回並驗證:
    mount /opt
    mkdir test
    應成功。

階段三:硬體層面排查

若 fsck 修復後短期內再次變 ro,或 dmesg / /var/log/messages 出現 I/O error、Buffer I/O error、FAILED Result: hostbyte=DID_ERROR,極大機率為磁碟/控制器/纜線故障。

廠商診斷工具關鍵指標
HPhpacucli / ssacliPhysical Drive Status: OK / Predictive Failure / Failed
Delldelldset / omreportState: Ready / Failed / Foreign
IBM/Lenovostorcli / MegaCLIFirmware State: Online / Unconfigured Bad
通用smartctl -a /dev/sdXReallocated_Sector_Ct > 0、Current_Pending_Sector > 0、SMART overall: FAILED

排除非本議題的鎖定機制

  • chattr +i:報錯為 Operation not permitted,非 Read-only file system。
  • 磁碟配額:報錯為 Disk quota exceeded 或 Quota exceeded。

總結流程圖

mkdir 失敗 Read-only
    │
    ├─ mount 顯示 ro? ──是──→ 修正 fstab + remount,rw
    │           │
    │           否
    │           │
    │           ├─ fsck 修復? ──是──→ 觀察是否復發
    │           │           │
    │           │           否
    │           │           │
    │           │           └─ 硬體診斷 (smartctl / 廠商工具) → 更換故障磁碟
    │           │
    │           否
    │           │
    │           └─ 檢查 chatr/quota → 對症處理

按圖索驥,從掛載選項 → 檔案系統修復 → 硬體診斷,三階段精準定位「Read-only file system」根因。

Copyright © Windows教程網 All Rights Reserved