Fsck on low RAM devices oom

I have an OpenWRT 21.02 device on remote location, its Asus RT-AC51U with MediaTek MT7620A CPU and 64MB RAM. There is 4TB 2.5'' HDD attached to it via USB, and it got corrupted after interrupted rsync session. This is not extroot device, as router had enough internal space for required packages. Unmounting drive and running fsck.ext4 fails:

root@openwrt:~# fsck.ext4 -yv /dev/sda1
e2fsck 1.45.6 (20-Mar-2020)
openwrt contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes

This is because of OOM. There is Serverfault topic about similar case, where lack of memory is culprit, however I do not have other external device attached where I could dump scratch files, and the only way to fsck is by attaching drive to another, more powerful machine, however I dont have physical access to machine right now.

Out of memory: Killed process 3498 (fsck.ext4) total-vm:42572kB, anon-rss:23656kB, file-rss:912kB, shmem-rss:0kB, UID:0 pgtables:44kB oom_score_adj:0
oom_reaper: reaped process 3498 (fsck.ext4), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

Go through the processes and shut down any services that are unnecessary (uhhtpd if not using LuCI, etc).

If you left any unallocated space on the drive, set up a swap partition. If not, next time you can connect the drive to a big computer, shrink the data partition slightly to make room for a swap.

1 Like

Thank you for suggestions, tried to squeeze RAM, but this did not resolve. Unfortunately no unallocated space.
Agree, using swap partition, not swap file is optimal in these cases.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.