系统崩溃和硬重置后退出只读文件系统(20.04.2 服务器、虚拟机)

系统崩溃和硬重置后退出只读文件系统(20.04.2 服务器、虚拟机)

昨天我的系统崩溃了,迫使我在运行 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

我已经检查了来自主机的磁盘映像文件,在本例中是一个与 KVM 一起使用的 qcow2 文件。

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

相关内容