fsck.ext4 消耗所有内存并被杀死

fsck.ext4 消耗所有内存并被杀死

我的外部硬盘可能已损坏,我需要检查错误并修复它们。我无法在其上创建任何新目录并收到以下错误:

2216505.217508] EXT4-fs (sda1): warning: mounting unchecked fs, running e2fsck is recommended                                                                   │
└Feb  7 17:31:18 Ganymed kernel: [2216505.326946] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)                                                                         │
┌Feb  7 17:31:18 Ganymed kernel: [2216505.217508] EXT4-fs (sda1): warning: mounting unchecked fs, running e2fsck is recommended                                                                   │
│Feb  7 17:31:18 Ganymed kernel: [2216505.326946] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)                                                                         │
│Feb  7 17:31:34 Ganymed kernel: [2216521.379474] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 3920, block bitmap and bg descriptor inconsistent: 24031 vs 24544 free clusters  │
│Feb  7 17:31:34 Ganymed kernel: [2216521.391046] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 3936, block bitmap and bg descriptor inconsistent: 24031 vs 24544 free clusters  │
│Feb  7 17:31:34 Ganymed kernel: [2216521.405316] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 3952, block bitmap and bg descriptor inconsistent: 23991 vs 24544 free clusters  │
│Feb  7 17:31:34 Ganymed kernel: [2216521.417718] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 3968, block bitmap and bg descriptor inconsistent: 23991 vs 24544 free clusters  │
│Feb  7 17:31:34 Ganymed kernel: [2216521.429068] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 3984, block bitmap and bg descriptor inconsistent: 23991 vs 24544 free clusters  │
│Feb  7 17:31:34 Ganymed kernel: [2216521.433767] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 4000, block bitmap and bg descriptor inconsistent: 24248 vs 24544 free clusters  │
│Feb  7 17:31:34 Ganymed kernel: [2216521.447223] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 4016, block bitmap and bg descriptor inconsistent: 3 vs 24544 free clusters      │
│Feb  7 17:31:34 Ganymed kernel: [2216521.459589] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 4032, block bitmap and bg descriptor inconsistent: 24055 vs 24544 free clusters  │
│Feb  7 17:31:34 Ganymed kernel: [2216521.463687] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 4048, block bitmap and bg descriptor inconsistent: 0 vs 24544 free clusters      │
└Feb  7 17:31:34 Ganymed kernel: [2216521.467055] EXT4-fs error (device sda1): ext4_mb_generate_buddy:805: group 4064, block bitmap and bg descriptor inconsistent: 24029 vs 24544 free clusters 

于是我尝试着逃跑fsck -f /dev/sda1。正如这里推荐的:https://access.redhat.com/solutions/155873。但经过相当长的一段时间后,它不断中止signal 9

sudo fsck -f /dev/sda1
fsck from util-linux 2.33.1
e2fsck 1.44.5 (15-Dec-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts                                                
Pass 5: Checking group summary information
fsck: Warning... fsck.ext4 for device /dev/sda1 exited with signal 9. 

我试了几次。有人可以给我一个提示,fsck 失败的原因可能是什么。还有其他方法可以尝试修复磁盘吗?

更新:起初我认为这可能是一个错误e2fsck并更新到了新版本 - 从e2fsck 1.44(Raspbian Buster)到e2fsck 1.46.2 (28-Feb-2021)(Raspbian Bullseye)。但由于新版本出现了同样的错误,我开始认为这可能是唯一的解决方案:https://serverfault.com/questions/9218/running-out-of-memory-running-fsck-on-large-filesystems 这里建议创建/etc/e2fsck.conf以下内容:

[scratch_files]
directory = /var/cache/e2fsck

我尝试过这个,但我的 4GB 系统上仍然运行着我们的内存。实际上,在 95% 时,进程开始消耗所有内存并因此被终止:

pi@Ganymed ~ $ sudo e2fsck -fp /dev/sda1
Signal (6) SIGABRT si_code=SI_TKILL =============================   | 95.0%       
pi@Ganymed ~ $ sudo e2fsck -fp /dev/sda1
Signal (6) SIGABRT si_code=SI_TKILL =============================   \ 95.0%    
pi@Ganymed ~ $

更新2:我将外部硬盘连接到具有 16 GB 内存和多核 AMD64 处理器的功能更强大的机器。修复过程顺利进行:

  sudo e2fsck -fp /dev/sde1
/dev/sde1: Journal wird wiederhergestellt
/dev/sde1: Auffüllbyte am Ende der Inode-Bitmap ist nicht gesetzt. REPARIERT.  
/dev/sde1: 3451100/244187136 Dateien (0.4% nicht zusammenhängend), 163473991/976745984 Blöcke

不幸的是我没有记录过程中的内存使用情况...也许这是 ARM 版本中的一个错误?

答案1

请注意消息:-

EXT4-fs (sda1): warning: mounting unchecked fs, running e2fsck is recommended
EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null) 

这是非常强烈建议e2fsck仅在未挂载的文件系统上运行。

相关内容