20

with my latest upgrade to Ubuntu 13.04, the initrd.img-3.8.0-21-generic file is now 32M. This is creating me problem with upgrading to newer kernels as I have /boot partition of just 96MB. What can I do to reduce the size of this file?

3
  • You can't reduce the size of the kernel. You will have to enlarge your boot partition. See askubuntu.com/questions/126153/how-to-resize-partitions and askubuntu.com/questions/24027/…
    – Takkat
    Commented May 24, 2013 at 8:33
  • Thanks for the comment. My situation for enlarging the boot partition is particularly complicated - /dev/md0 is raid1 /boot partition at 96MB - /dev/md1 is raid1 hosting LVM2 partitions containing the rest of the system. I have no idea how to reduce the size of /dev/md1 to make more room for /dev/md0 in this scenario
    – nwaltham
    Commented May 24, 2013 at 8:56
  • I am using grub2 - I guess the only potential option to explore is /boot inside the lvm.
    – nwaltham
    Commented May 24, 2013 at 9:04

1 Answer 1

33

In /etc/initramfs-tools/initramfs.conf, set MODULES=dep instead of MODULES=most. The initrd build process will work out what modules you need rather than including a wide variety of things. Note, however, that this makes your boot process very dependent on your hardware and if you need to use a different set of hardware (in particular, drives) the initrd may not work.

Additionally you can choose a better compression algorithm, the default should still be gzip, but xz (or lzma2) is also available via COMPRESS=xz. Of course you need to have xz-utils installed. The initial compression takes longer, but decompression during boot shouldn't take much longer. Both options together may also reduce your boot time a little bit.

After setting this, run sudo update-initramfs -u -k all to have it take effect.

2
  • 4
    For relative comparison some test results with 13.10 amd64 in a kvm virtual environment, booting to text mode. (1) Modules=most,gzip: /boot/initrd.img-3.11.0-12-generic size is 16 985 839 bytes, boots in 6.69s. (2) Modules=dep,gzip: /boot/initrd.img-3.11.0-12-generic size is 2 229 559 bytes, boots in 6.12s. (3) Modules=dep,xz: /boot/initrd.img-3.11.0-12-generic size is 1 685 916 bytes, boots in 6.26s. (4) Modules=dep,lzma: /boot/initrd.img-3.11.0-12-generic size is 1 685 872 bytes, boots in 6.35s.
    – Pro Backup
    Commented Feb 10, 2014 at 23:41
  • I can report a similar 25% decrease with xz on my 4.14 initramfs
    – mirh
    Commented Aug 23, 2018 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .