Comment 125 for bug 1842320

Revision history for this message
Adrien Nader (adrien) wrote :

I put together some notes and work-arounds in order to provide a simpler reference for people hitting this issue. I didn't test everything below but nothing should be risky.

# Summary

Grub attempts to read the initrd into a memory location that is too small.

This issue is caused by a combination of several factors:
- Grub not setting aside enough space for the initrd in memory and not at the right location,
- Initrds having grown due to holding more modules and more firmware. This is especially the case with the nvidia proprietary driver.
- Typical screen resolutions and their associated buffers in memory having increased.

A related issue is not having enough space in /boot to hold enough initrds.

# Solutions

There are four ways to tackle these issues:
- Patch grub,
- Have fewer modules,
- Compress initrds more,
- Lower screen resolution at boot.

## Patch grub
This is being worked on. It’s the trickier option so I’m not going to provide details but you can find that in the discussion above.

## Have fewer modules
The default configuration creates initrds that are meant to be universal in order to accommodate as many hardware variants as possible. Unsurprisingly this makes initrds much bigger.

It is possible to change the value of MODULES to ‘dep’ in /etc/initramfs-tools/initramfs.conf . This will drastically reduce the initrd size in virtually every configuration at the cost of not supporting during boot hardware that is not plugged when the initrd generation takes place.

## Compress initrds more
Change the value of COMPRESS in /etc/initramfs-tools/initramfs.conf .
In terms of compression level, you will have something along the lines of the following:
    lz4: 74066711
    zstd: 54260379
    gzip: 53829310
    xz: 29665544

NB: these values are only valid on one specific machine and configuration; they are only meant to give an idea of compression ratio that can be obtained but the initrd uses MODULES=dep as outlined above.

With a small hack, it is also possible to make xz compression much faster at a small cost in compression by adding the following at the end of initramfs.conf:
    export XZ_OPT='--lzma2=preset=0,dict=8M'

In the future, it will be possible to directly set compression levels for every compression method.

## Lower screen resolution at boot
You can use a lower resolution screen when booting.

You can also edit /etc/default/grub and use the following:
    GRUB_GFXMODE=640x480
Remember to run update-grub afterwards.
If you need to do it at boot-time, you will use GFXMODE instead (no ‘GRUB_’ prefix).