# [SOLVED]kernel -> error: out of memory with dm-crypt enabled

## archenroot

Hi guys,

I went trough https://wiki.gentoo.org/wiki/Full_Disk_Encryption_From_Scratch_Simplified tutorial about how to enable encryption on root partition. 

I have initramfs built-in within kernel image (not 2 separate files).

After enabling all required configuration when I try to boot from grub I get error:

```
Loading kernel 4.18.10

error: out of memory
```

after this it returns me to grub2 menu. I wasn't able to find such error anywhere over internet (via google). Any idea whats wrong here?

----------

## khayyam

archenroot ...

how are you supplying the INITRAMFS_SOURCE? Sounds as though you may be providing a compressed cpio image (which I think is what genkernel outputs by default), when it should either be an uncompressed cpio or a directory tree.

best ... khay

----------

## archenroot

Ok, nice catch, make sense to me.

When I check content of /usr/src/linux/.config file I get:

```
CONFIG_INITRAMFS_SOURCE="/var/tmp/genkernel/initramfs-4.18.11-gentoo.cpio"
```

Additionally there is config regarding compression:

```
CONFIG_INITRAMFS_COMPRESSION_NONE=y
```

Strange I use genkernel for ages already...

But you are right, at genkernel level there is compression enabled:

```
COMPRESS_INITRD="yes"

COMPRESS_INITRD_TYPE="best"
```

I changed it to:

```
COMPRESS_INITRD="no"

#COMPRESS_INITRD_TYPE="best"
```

And compiling now... will update later.

----------

## khayyam

 *archenroot wrote:*   

> Additionally there is config regarding compression:
> 
> ```
> CONFIG_INITRAMFS_COMPRESSION_NONE=y
> ```
> ...

 

archenroot ... that should be =y (and an INITRAMFS_COMPRESSION selected) as it will then compress your cpio/directory, and more importantly be able to decompress.

best ... khay

----------

## archenroot

Thanks for hints, but I think you interpret COMPRESSION_NONE wrong or I don't understand your statement. NONE means no compression will be used, so I cannot sellect any compression method.

Additionally I just compared my 2 machines. I have workstation with 64GB ram and this Dell XPS 15 laptop 32GB ram which I am now installing, but that one with encrypted ROOT partition.

Workstation is configured as:

1. genkernel.conf

```
# Build the generated initramfs into the kernel instead of

# keeping it as a separate file

INTEGRATED_INITRAMFS="1"

# Compress generated initramfs

COMPRESS_INITRD="yes"

# Types of compression: best, xz, lzma, bzip2, gzip, lzop, fastest

# "best" selects the best available compression method

# "fastest" selects the fastest available compression method

COMPRESS_INITRD_TYPE="best"
```

And kernel config:

```
zangetsu@andromeda /usr/src/linux $ cat .config |grep COMPRESSION

CONFIG_INITRAMFS_COMPRESSION_NONE=y

# CONFIG_INITRAMFS_COMPRESSION_XZ is not set

CONFIG_INITRAMFS_COMPRESSION=""

```

On this machine (without compression) all works just fine. I don't think separating the init and kernel will make any big difference, but will try as well. It is just something with this compression, etc.

----------

## archenroot

Not sure if that is the case, but I found following issue on other cpu platform:

https://bugzilla.redhat.com/show_bug.cgi?id=1615969

Also noticed my kernel on laptop is quite big, about 200MB vs about 60MB on workstation.

----------

## khayyam

 *archenroot wrote:*   

> Also noticed my kernel on laptop is quite big, about 200MB vs about 60MB on workstation.

 

archenroot ... both of those are unusually large, what are you including in your initramfs?

```
# mount /boot

# ls -lh /boot/efi/linux/vmlinuz.efi

-rwxr-xr-x 1 root root 4.5M 2018-04-28 19:46 /boot/efi/linux/vmlinuz.efi

# du -hs /usr/src/initramfs/sourceroot

2.9M    /usr/src/initramfs/sourceroot
```

vmlinuz.efi (3.12.x) includes initramfs, and 'sourceroot' is the (uncompressed) tree provided as INITRAMFS_SOURCE.

I'm fairly certain that will be the cause of your "out of memory" error.

best ... khay

----------

## archenroot

I was busy by joining new job onboard, but, the size of kernel was so big because:

1. I have lot of things enabled as running on laptop and need simply lot of drivers

2. I had an option to all modules in ram disk

As I had issues with my own kernel config which was 2 years old. I simply did excersize to use Live DVD config and just cut off as much as possible, this resulted in following sizes:

5.1M Oct  8 23:51 kernel-genkernel-x86_64-4.14.65-gentoo

75M Oct  8 23:55 initramfs-genkernel-x86_64-4.14.65-gentoo

So it is much better I think, lol.

I will now try to integrate initramfs into kernel to build stub, so in the end I don't need grub and can boot directly via UEFI motherboard loader. Still initramfs are quite big against yours  :Smile: , I build those via:

```
genkernel --install --no-ramdisk-modules initramfs

genkernel --install --no-ramdisk-modules kernel
```

```
genkernel --kernel-config=/usr/src/linux/.config --no-clean --luks --lvm --no-zfs all
```

NOTE: I have lvm and luks and clean configured via genkernel.conf, but was just playing so enforced via command line as override to prevent config file mistake.

----------

## archenroot

Anyway thx for your helping hints about how to get out!

----------

## khayyam

archenroot ...

my initramfs is built with better-initramfs ... and so cryptsetup, lvm2, etc, are built, and statically linked to, musl. Your genkernel built initramfs will use the host libc, and so linked against glibc. Some of the size difference is due to this, the rest is due to better-initramfs not including kernel modules, everything needed to boot is builtin to the kernel.

You could give the pre-built initramfs a shot ... but you would need to make sure that your kernel has =y for those drivers needed to access AHCI, and mount your filesystem.

You're welcom & best ... khay

----------

## archenroot

So here we are, thx for detailed explanation, I learned something new and thx for tip with better-initramfs links, etc.

Have a good day!

Ladislav

----------

