I have a box running Ubuntu 11.10 with 512MB RAM and no swap. It has a 1TB USB HDD with ext3 filesystem attached. Sitting idle, it's only using about 60MB. When I run e2fsck, it runs out of memory, the OOM killer kicks in, and e2fsck dies.

Is there any trick to running e2fsck so that it uses less memory?

I ran:

sudo e2fsck -n /dev/sdb1

[Please don't tell me to enable swap or add memory -- I can't enable swap, and adding memory is the obvious long-term fix. I'd like a way to run fsck now.]


I'm not sure which version of e2utils Ubuntu 11.10 has, however if it's fairly recent you can create /etc/e2fsck.conf file with something like this:

directory = /tmp/e2fs_scratch

Create that directory first, then run e2fsck. Using scratch file will greatly reduce memory use, however e2fsck will run very very slowly.

Of course if you need to check your root fs, you'll need to boot into another root, as the scratch directory will need to be writable.

| improve this answer | |
  • Thanks, I'll try that. I figured there'd be a speed-memory tradeoff, so that should be ok. I'll kick it off tonight. – bstpierre Nov 30 '11 at 19:17

I realize this is a really old topic, but since I had issues myself.. and the scratch file didn't work.. I figured I'd offer up how I got around it.

I manage a 12 tb file server and the way I got around this was to create a 12gb swap file on an external drive .. it was slower, but it managed to get through it.

# dd if=/dev/zero of=/mnt/external/swapfile1 bs=1024 count=12582912
# mkswap /mnt/external/swapfile1
# swapon /mnt/external/swapfile1

I named it swapfile1 so if it still wasn't enough I could create a second swapfile2 with the same steps..

To have the swapfile mount automtically you can add this line to /etc/fstab

/mnt/external/swapfile1 swap swap defaults 0 0

Of course the drive will need to be mounted before that line =)

| improve this answer | |
  • It is not an answer, but a question. This site is very rigorous about this. I suggest to copy-paste this "answer" and ask this as a new question, until you can (it will be surely deleted). – peterh - Reinstate Monica May 9 '14 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.