Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a computer with very little memory (128MB) - for my application I need to format large drives (4TB)

I'm able to format greater than 2TB disks, up to about 2.5TB, but beyond that I'm given the below

mke2fs 1.42-WIP (16-Oct-2011)
/dev/sda1: Memory allocation failed while setting up superblock

I realize I'm really out there in terms of reasonable - are there any tricks? (block sizes, etc)

any idea how I can get very large disks to format?

share|improve this question
Put some more RAM in it. – Michael Hampton Sep 28 '12 at 0:39

Add some swap:

dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
mkswap /swapfile1
swapon /swapfile1

That'll make 512MB of swap and enable it. You'll need to edit your /etc/fstab to make it stay after a reboot, though.

share|improve this answer

An even better approach would be to use the -D flag. From the man pages:

 Use direct I/O when writing to the  disk.   This  avoids  mke2fs
 dirtying  a  lot  of buffer cache memory, which may impact other
 applications running on a busy server.  This option  will  cause
 mke2fs  to run much more slowly, however, so there is a tradeoff
 to using direct I/O.

Worked for me with an initramfs and 512MB.

share|improve this answer
Better than what? This is unlikely to solve the problem shown in the question. – Michael Hampton Aug 20 '15 at 23:09
This is better than adding swap space. Also, it's better than "Put some more RAM in it." :-) (albeit probably slower) – Nate Aug 26 '15 at 16:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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