虚拟机上的文件系统错误:调整 inode 大小无效。fsck 退出,状态代码为 4

虚拟机上的文件系统错误:调整 inode 大小无效。fsck 退出,状态代码为 4

总结

我正在尝试修复由于硬关闭虚拟机而损坏的磁盘。我所能做的最多就是使用fsck.ext4备份超级块来允许我再次安装磁盘。完成后,我可以看到系统文件,但没有/home文件夹。我想知道这是否是因为该文件夹已加密而导致的,这使得恢复更加困难。


我一直在使用 VirtualBox 5.2.14 运行 Ubuntu 18.04 作为客户操作系统。昨天我关闭了虚拟机,当我尝试再次打开它时,我得到了控制台initramfs,输入后exit我得到了:

BusyBox v1.27.2 (ubuntu 1:1.27.2-2ubuntu3) built-in shell (ash)
enter 'help' for a list of built-in commands.
(initramfs)

(initramfs) exit

/dev/mapper/ubuntu--vg-root contains a file system with errors, check forced.
/dev/mapper/ubuntu--vg-root: Resize inode not valid.

/dev/mapper/ubuntu--vg-root: UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY.
        (i.e., without -a or -p options)
fsck exited with status code 4
The root filesystem on /dev/mapper/ubuntu--vg-root requires a manual fsck

initramfs fsck -y

因此,我继续尝试:

fsck /dev/mapper/ubuntu--vg-root -y

看起来“磁盘”变得更加混乱了fskc -y

...
Free inodes count wrong for group #160 (1334, counted=479). Fix? yes
/dev/mapper/ubuntu--vg-root: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/ubuntu--vg-root: 151456/1790544 files (0.1% non-contiguous), 1416234/7161856 blocks

退出initramfs返回:

Target filesystem doesn't have requested /sbin/init
run-init: opening console: No such file or directory
No init found. Try passing init= bootarg.

执行后reboot结果为:

CPU: 3 PID: 1 Comm: init Not tainted 4.15.0-23-generic #25-Ubuntu
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
...
end Kernel panic - not syncing: Attempted to kill init! exit code=0x00000100

好消息是,我已经克隆了虚拟机,所以没有任何东西“丢失”(目前:p)。

现场 CD

我使用实时 CD 启动了虚拟机,当我尝试从 Nautilus(文件管理器)安装磁盘时,出现一个弹出窗口,其中显示一些数字:

抱歉,无法显示“...”的所有内容:获取文件“/media/ubuntu/.../dev”的信息时出错:结构需要清理

e2fsck -n

在新的 VM 克隆上,执行e2fsck -n显示:

Inode 392498 passes checks, but checksum does not match inode.  Fix? no

Inode 392499 seems to contain garbage.  Clear? no

Inode 392499 has INLINE_DATA_FL flag on filesystem without inline data support.
Clear? no

Inode 392499 is in use, but has dtime set.  Fix? no

Inode 392499 has imagic flag set.  Clear? no

Inode 392499 has a extra size (50685) which is invalid
Fix? no

Error while iterating over blocks in inode 392499: Cannot iterate data blocks of an inode containing inline data

/dev/dm-1: ********** WARNING: Filesystem still has errors **********

部分日志:https://pastebin.com/5HBTe9KL(完整日志长达 35 万行)

文件系统

在新的 VM 克隆上:

sudo mkfs.ext4 -S /dev/dm-1
mke2fs 1.44.1 (24-Mar-2018)
/dev/dm-1 contains a ext4 file system
    last mounted on / on Sun Jul 22 16:59:28 2018
Proceed anyway? (y,N) y
Creating filesystem with 7161856 4k blocks and 1790544 inodes
Filesystem UUID: f1c6b504-984a-4a14-980e-c70bd309ec8a
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000

Allocating group tables: done                            
/dev/dm-1 may be further corrupted by superblock rewrite
Proceed anyway? (y,N) y
Skipping journal creation in super-only mode
Writing superblocks and filesystem accounting information: done

然后我尝试通过 Nautilus 安装磁盘并弹出:

Unable to access location
Error mounting /dev/dm-1 at /media/ubuntu/...: mount(2) system call failed: Structure needs cleaning 

文件系统检查

获得备份超级块的列表:

# first one
Backup superblock at 32768, Group descriptors at 32769-32772
  ...
Backup superblock at 4096000, Group descriptors at 4096001-4096004
# last one

然后我尝试使用备份块。每次尝试都对虚拟机进行新的克隆。

fsck.ext4 -b 32768 /dev/dm-1 # in new vm
fsck.ext4 -b 4096000 /dev/dm-1 # in new vm

在这两种情况下,结果都是我能够安装驱动器!而且它似乎有大多数系统文件(/bin、、等)。不幸的是,没有文件夹。/etc/opt/home

/home文件夹已加密,但在我开始上述任何调试/恢复步骤之前,我总是必须先解密它。但是,现在我想知道这是否会妨碍成功的fsck.ext4

相关内容