/ 啟動時只讀,但不明白為什麼。如何排查並修復?

/ 啟動時只讀,但不明白為什麼。如何排查並修復?

根檔案系統在擠壓下安裝得很好,在我升級到喘息後。我已經忍受了一段時間了,所以我不太確定,但我認為它是在對 wheezy 進行 dist 升級之後開始的,但這可能是巧合。該機器是聯想 T400 FWIW。

開機畫面照片1顯示有​​關唯讀檔案系統的第一個警告;顯然沒有記錄任何內容

fsck 沒有發現問題2

mount -o remount,rw /

以上工作正常

(但我必須重新啟動網路管理員和 gdm3 才能獲得可用的系統;我不確定它是否相關,但我似乎無法連接到本地主機上運行的服務,例如 python -m SimpleHTTPServer 8080 和另一個終端w3m 向本地主機連接埠8080 發送請求逾時)

我沒有註意到 fstab 有什麼問題

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# / was on /dev/sda1 during installation
UUID=2934c627-6f1a-438b-a877-1544108c7418 /               ext3 errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=39b1f59e-6193-4c46-8b4d-80b183f0b19c none            swap    sw           0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/sdb1       /media/usb0     auto    rw,user,noauto  0       0

任何指示將不勝感激。希望我正在做一些明顯錯誤且可以修復的事情,但如果沒有任何關於如何調試的提示?

tune2fs -l /dev/sda1

輸出

tune2fs 1.42.2 (27-Mar-2012)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          2934c627-6f1a-438b-a877-1544108c7418
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file
Filesystem flags:         signed_directory_hash 
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              14893056
Block count:              59547904
Reserved block count:     2977395
Free blocks:              50391869
Free inodes:              14576981
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1009
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Filesystem created:       Tue May  3 01:44:56 2011
Last mount time:          Wed Apr 18 13:11:25 2012
Last write time:          Tue Apr 17 23:51:46 2012
Mount count:              5
Maximum mount count:      25
Last checked:             Tue Apr 17 23:51:46 2012
Check interval:           15552000 (6 months)
Next check after:         Sun Oct 14 23:51:46 2012
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:           256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
First orphan inode:       9145036
Default directory hash:   half_md4
Directory Hash Seed:      af8ca7f0-bcad-49f3-98c0-9b19a531a885
Journal backup:           inode blocks

看來 /etc/init.d/checkroot.sh 並未在啟動時運行,而該腳本最終將 root 重新安裝為 rw(如果我在啟動後運行它,它就會執行此操作)。我正在使用 Debian 測試/喘息。 /etc/init.d 檔案中有依賴項註釋,但除此之外,我不確定如何告訴有關 init 系統的更多資訊。

已修復,但不知道它是如何發生的,也不知道修復是否正是系統應有的樣子。我注意到 /etc/rcS.d 中有 checkfs 和 mtab,但沒有 checkroot,所以我添加了它:

cd /etc/rcS.d
ln -s ../init.d/checkroot.sh S06checkroot.sh

重新啟動兩次後(第一次可能是我的困惑,但我在它們之間向checkroot.sh 添加了一些進一步的工具),我在啟動時使用rw 進行備份(並且從本地主機監聽/請求的問題消失了,所以我猜測是相關的)。

(我在擠壓系統上看到我可以訪問它的 S07checkroot.sh;我可能已經很接近了。)

答案1

您的 /root 檔案系統上有錯誤,並且 fstab 將 /root 重新掛載為唯讀。

fstab 中的行

UUID=2934c627-6f1a-438b-a877-1544108c7418 / ext3 errors=remount-ro 0 1

是什麼導致 /root 以只讀方式掛載。

mount (8)手冊頁

errors={continue|remount-ro|panic}
Define the behaviour when an error is encountered.  (Either ignore errors
and just  mark  the  filesystem  erroneous and continue, or remount the
filesystem read-only, or panic and halt the system.)  The default is set in
the  filesystem superblock, and can be changed using tune2fs(8).

您最終應該找出 /root 檔案系統出了什麼問題。您可以輕鬆地從救援磁碟啟動並在 /root 上執行 fsck。如果您選擇忽略潛在錯誤,只需將 fstab 中的行變更為errors=continue.

答案2

我遇到了這個問題,這是由於 /etc/fstab 中設定的根 FS 的 UUID 錯誤引起的。我猜某些升級會自動檢測到它並出錯。

重新掛載 / 分割區 rw,使用blkid取得正確的 UUID 並取代 /etc/fstab 為我修復它。

答案3

你的根檔案系統沒有被掛載為讀/寫,因為你沒有告訴它。

UUID=2934c627-6f1a-438b-a877-1544108c7418 /               ext3 errors=remount-ro 0       1

您的安裝選項只有errors=remount-ro,其中沒有關於讀/寫的內容。標準做法是defaults在您的安裝選項中包含此內容。defaults提供了其他幾個安裝選項,其中之一是rw,從而提供讀取/寫入。

因此,您需要將defaults或新增rw至 fstab 的選項欄位中。

編輯:
如果再多思考一下(以及下面評論中的討論),defaultsrw選項可能無法修復它。原因是重新安裝行為完全取決於發行版的初始化腳本。我看過發行版在啟動時從 fstab 中提取掛載設置,但也有可能 init 腳本在重新掛載 root 時完全忽略 fstab 選項(並在腳本中使用一些硬編碼設定)。

相關內容