# initramfs out of memory error [solved]

## Timmer

This is the end result of a long story, and I'm going to tell as much as it as possible, because I'm not sure I actually have the problem figured out.  So maybe with information, someone will be able to help me, even if I'm barking up the wrong tree.

I needed to repartition my harddrive, so I backed the whole thing up on an external, and repartitioned, and then decided to take the opportunity to format it to ext4.

Then I copied everything back on, reinstalled grub2 on the drive, and rebooted.  Computer didn't boot, because I forgot that I didn't have ext4 built into my old kernel.  So I tried rebuilding the kernel.  But it ran out of memory while it was building initramfs (which has never happened before).  So I decided to skip that, and just put an init parameter in my kernel boot line.

Grub worked then, but now my kernel panics immediately, without an error messages, like it can't load the init files.  So I'm trying to figure out how to get the initramfs to build again, thinking that it has something to do with that.

Any ideas on why it might be running out of memory (I have 6 gigs, so it's certainly not a shortage of ram - does it have something to do with chrooting?)Last edited by Timmer on Fri Feb 03, 2012 5:11 am; edited 1 time in total

----------

## Hu

Please post the exact failure message when it runs out of memory, and at least 20 lines of context before that.  How do you create your initramfs?  Is it managed for you by genkernel, by a personal script, or by the kernel build process?

----------

## Timmer

There aren't 20 lines before that...  When I get home I'll re-run it and put it in here, but since it's the only thing that's building (because there were no other changes to the kernel) it happens at something like line 3.

The initramfs is created by the kernel build process.

----------

## Timmer

Here's the output, in its entirety:

```

# make

  CHK     include/linux/version.h

  CHK     include/generated/utsrelease.h

  CALL    scripts/checksyscalls.sh

  CHK     include/generated/compile.h

  GEN     usr/initramfs_data.cpio.lzma

out of memory

 line 11

make[1]: *** [usr/initramfs_data.cpio.lzma] Error 255

make: *** [usr] Error 2

```

----------

## Hu

Why are you building the kernel as root?  What is the output of ulimit -a ; free?

----------

## Timmer

I thought I mentioned that this was in a chrooted environment.  To my knowledge, once you chroot, you're root whether you want to be or not.  You don't have the option to chroot as a non-privileged user.

ulimit -a will have to wait until I get home, but I ran free several times the other day, in another terminal while this was happening.

I start with about 4.5 GB of free memory (guessing the LiveDVD is using the other 1.5), and between "out of memory  line 11" and "make[1]: *** [usr/initramfs_data.cpio.lzma] Error 255 " the memory shrinks until I have roughly 31 KB.  Then make exits, and gives it all back.

----------

## frostschutz

You could su to a normal user once inside the chroot, I guess. I build kernel as root myself though, I don't think there's a problem with it really.

There is very little reason for initramfs creation to run out of memory. You probably have a bad file in your initramfs setup, for example trying to integrate /proc/* into the initramfs is bound to fail.

Sometimes also the kernel make fails to build the initramfs properly, in such a case you have to make clean / mrproper or manually delete the usr/initramfs_data.cpio

----------

## Timmer

I figured it out.  Thanks for the help.  It turns out that after repartitioning the drive, I forgot to recopy /dev/sda3 (my root partition) into the initramfs, so it was trying to use the old one and failing.

Fixed that, and have a seg fault problem, but I haven't given up on solving that one myself yet.  Original problem is solved though, so marking the thread as such.

----------

