系統崩潰和硬重置後退出唯讀檔案系統(20.04.2 伺服器、VM)

系統崩潰和硬重置後退出唯讀檔案系統(20.04.2 伺服器、VM)

昨天,我的系統崩潰了,迫使我在運行 2 個虛擬機器的同時在主機上進行硬重置。第一台機器倖存下來,第二台機器已進入唯讀模式。登入虛擬機器後,我會看到以下訊息。

Unable to setup logging. [Errno 30] Read-only file system: '/var/log/landscape/sysinfo.log' run-parts: /etc/update-mot.d/50-landscape-sysinfo exited with return code 1 /usr/lib/ubuntu-release-upgrader/release-upgrade-motd: 31: cannot create /var/lib/ubuntu-release-upgrader/release-upgrade-available: Read-only file system mktemp: failedd to create file via template '/var/lib/update-notifier/tmp.XXXXXXXXXX': Read-only file system run-parts: /etc/update-motd.d/95-hwe-eol exited with return code 1 /usr/lib/update-notifier/update-motd-fsck-at-reboot: 38: cannot create /var/lib/update-notifier/fsck-at-reboot: Read-only file system

我已經從主機檢查了磁碟映像文件,在本例中是一個 qcow2 文件,我與 KVM 一起使用。

sudo qemu-img check ubuntu204.qcow2

結果是:

No errors were found on the image. 245760/245760 = 100.00% allocated, 0.00% fragmented, 0.00% compressed clusters Image end offset: 16108814336

我讀到這是保護檔案系統的強制狀態,如果我掃描磁碟並且一切正常,我可以退出只讀模式,我將如何在只讀模式下使用 tty 上的以下分割區表來做到這一點?

loop0                         0
loop1                         0
loop2                         0
loop3                         0
loop4                         0
loop5                         0
|-sda                         0   15G    0 disk
  |-sda1                      0   1M     0 part
  |-sda2                      0   1G     0 part /boot
  |-sda3                      0   14G    0 part
    |-ubuntu--vg-ubuntu--lv   0   14G    0 lvm /
|-sr0                         1   1024M  0 rom

從警告中,我懷疑可能存在問題,unattended-upgrades我也對有關您建議的進一步檢查的任何進一步輸入感興趣,以確保兩台機器的完整性。

答案1

如何使用 fsck 從主機復原 qcow2 磁碟映像文件

載入網路塊設備模組:

sudo modprobe nbd max_part=8

斷電機器:

sudo virsh destroy virtual-machine

連接磁碟映像:

sudo qemu-nbd --connect=/dev/nbd0 /var/lib/libvirt/images/virtual-machine.qcow2

檢查磁碟:(磁碟現在已安裝在主機上,您可以在 nautilus/explorer 中看到它)

sudo fsck /dev/nbd0p2

對我來說,我安裝了兩個額外的驅動器,我剛剛掃描了 nbd-dm3 和 nbd0p2,這是一個預期輸出的範例,我只是對所有人回答「是」。

fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/dev/nbd0p1: recovering journal
/dev/nbd0p1 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found.  Fix<y>? yes
Inode 274 was part of the orphaned inode list.  FIXED.
Inode 132276 was part of the orphaned inode list.  FIXED.
Deleted inode 142248 has zero dtime.  Fix<y>? yes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences:  -603674 -623174 +(689342--689343)
Fix<y>? yes
Free blocks count wrong for group #18 (15076, counted=15077).
Fix<y>? yes
Free blocks count wrong for group #19 (11674, counted=11675).
Fix<y>? yes
Free blocks count wrong (632938, counted=670871).
Fix<y>? yes
Inode bitmap differences:  -274 -132276 -142248
Fix<y>? yes
Free inodes count wrong for group #0 (52, counted=53).
Fix<y>? yes
Free inodes count wrong for group #16 (99, counted=100).
Fix<y>? yes
Free inodes count wrong for group #17 (519, counted=520).
Fix<y>? yes
Free inodes count wrong (204392, counted=204599).
Fix<y>? yes

/dev/nbd0p1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/nbd0p1: 101833/306432 files (0.2% non-contiguous), 553321/1224192 blocks

斷開設備:

sudo qemu-nbd --disconnect /dev/nbd0

/dev/nbd0 已斷開連接

啟動你的機器並檢查它是否工作:

virsh start virtual-machine

來源:https://gist.github.com/islander/8517685e3a9f7e0e1d458033710f0893

相關內容