I need to compress the initramfs to reduce their size
I am not computer literate. I have a command I use to clean out old kernals. That has always been sufficient to provide space for updates. I updated to Ubuntu 20.04.1. Now I need to update and cleaning out the kernals is not enough to provide necessary space. The notice said to compress the initramfs to make more space. But I cannot figure out how to do this. Do you do it in terminal? What commands do you enter? I need precise instructions since I have no idea what I am doing.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Manfred Hampl
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Initramfs is already compressed.
Are you low on space? What is the output of:
lsb_release -a; uname -a; df -h
Thanks
Revision history for this message
|
#2 |
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
sakialele@
:~$ uname -a
Linux merry-X550CA 5.4.0-52-generic #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
sakialele@
:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 383M 1.9M 381M 1% /run
/dev/mapper/
tmpfs 1.9G 27M 1.9G 2% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/loop0 9.2M 9.2M 0 100% /snap/canonical
/dev/loop1 9.2M 9.2M 0 100% /snap/canonical
/dev/loop3 98M 98M 0 100% /snap/core/10185
/dev/loop2 98M 98M 0 100% /snap/core/10126
/dev/sda2 237M 108M 117M 48% /boot
/dev/sda1 511M 7.8M 504M 2% /boot/efi
tmpfs 383M 40K 383M 1% /run/user/1002
Revision history for this message
|
#3 |
Before I upgraded, my boot could always be reduced to 33%. Now I can't get it under 48%.
Revision history for this message
|
#4 |
You have plenty of space here. You can remove old kernels if required.
Revision history for this message
|
#5 |
/dev/sda2 237M 108M 117M 48% /boot
237 MB for /boot is very small for the kernel files of current kernel versions, probably too small.
What is the output of the commands
ls -l /boot
dpkg -l | grep linux-image
Revision history for this message
|
#6 |
ls -l /boot
total 99700
-rw-r--r-- 1 root root 237807 Oct 15 05:28 config-
drwxr-xr-x 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 5 root root 1024 Nov 11 18:05 grub
lrwxrwxrwx 1 root root 27 Oct 23 16:22 initrd.img -> initrd.
-rw-r--r-- 1 root root 84454054 Nov 6 16:21 initrd.
lrwxrwxrwx 1 root root 27 Oct 28 16:48 initrd.img.old -> initrd.
drwx------ 2 root root 12288 Jun 11 2016 lost+found
-rw-r--r-- 1 root root 182704 Aug 18 05:46 memtest86+.bin
-rw-r--r-- 1 root root 184380 Aug 18 05:46 memtest86+.elf
-rw-r--r-- 1 root root 184884 Aug 18 05:46 memtest86+
-rw------- 1 root root 4743490 Oct 15 05:28 System.
lrwxrwxrwx 1 root root 24 Oct 23 16:22 vmlinuz -> vmlinuz-
-rw------- 1 root root 11678464 Oct 15 05:33 vmlinuz-
lrwxrwxrwx 1 root root 24 Oct 28 16:48 vmlinuz.old -> vmlinuz-
sakialele@
:~$ dpkg -l | grep linux-image
ii linux-image-
ii linux-image-generic 5.4.0.52.55 amd64 Generic Linux kernel image
Revision history for this message
|
#7 |
To actionparsnip (andrew-
Revision history for this message
|
#9 |
Is the system a virtual machine or is it a real system?
Revision history for this message
|
#10 |
You might experiment with options, see e.g. https:/
No warranty given that your system still boots after doing that.
Revision history for this message
|
#11 |
actionparsnip (andrew-
I don't even know for sure what a virtual machine is. I loaded Trusty Taur on an Asus computer, wiping out the Windows that it came with.
Revision history for this message
|
#12 |
Manfred Hampl (m-hampl)
When I run Software Updater, it brings up a 'not enough free disc space' notice. This reads in part:
you could also set COMPRESS=xz in /etc/initramfs-
How do I do this? Please? I need full instructions.
Step one: open terminal
Step two: put in?
Thank you
Revision history for this message
|
#13 |
I was looking for the answer to a question years ago when I ran across a conversation. Someone was complaining about the /boot being so small. The questioner wanted to know why the file could not be enlarged as part of an upgrade or update. The expert answering him said that he thought that ought to be done. But I don't think it ever has. It's not as though I don't have space on my hard drive. I think I'm using less than 10%
Revision history for this message
|
#14 |
"wanted to know why the file could not be enlarged"
The item involved is not a file, but a disk partition, and modifying disk partitions is not an easy task.
To check whether it is possible to enlarge the partition in-place, or if a complete re-allocation has to be done, what is the output of the command
sudo fdisk -l
Revision history for this message
|
#15 |
"you could also set COMPRESS=xz in /etc/initramfs-
What is the output of the command
cat -n /etc/initramfs-
Revision history for this message
|
#16 |
Manfred Hampl (m-hampl)
sudo fdisk -l
Disk /dev/loop0: 9.7 MiB, 9506816 bytes, 18568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 9.7 MiB, 9510912 bytes, 18576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 97.72 MiB, 102445056 bytes, 200088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop3: 97.76 MiB, 102486016 bytes, 200168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop4: 55.37 MiB, 58052608 bytes, 113384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop5: 162.89 MiB, 170778624 bytes, 333552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop6: 62.9 MiB, 65105920 bytes, 127160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop7: 64.79 MiB, 67915776 bytes, 132648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: WDC WD5000LPVX-8
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C61421AB-
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 1550335 499712 244M Linux filesystem
/dev/sda3 1550336 976771071 975220736 465G Linux filesystem
Disk /dev/mapper/
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/loop8: 179.17 MiB, 187871232 bytes, 366936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop9: 94.77 MiB, 99356672 bytes, 194056 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
cat -n /etc/initramfs-
1 #
2 # initramfs.conf
3 # Configuration file for mkinitramfs(8). See initramfs.conf(5).
4 #
5 # Note that configuration options from this file can be overridden
6 # by config files in the /etc/initramfs-
7
8 #
9 # MODULES: [ most | netboot | dep | list ]
10 #
11 # most - Add most filesystem and all harddrive drivers.
12 #
13 # dep - Try and guess which modules to load.
14 #
15 # netboot - Add the base modules, network modules, but skip block devices.
16 #
17 # list - Only include modules from the 'additional modules' list
18 #
19
20 MODULES=most
21
22 #
23 # BUSYBOX: [ y | n | auto ]
24 #
25 # Use busybox shell and utilities. If set to n, klibc utilities will be used.
26 # If set to auto (or unset), busybox will be used if installed and klibc will
27 # be used otherwise.
28 #
29
30 BUSYBOX=auto
31
32 #
33 # COMPCACHE_SIZE: [ "x K" | "x M" | "x G" | "x %" ]
34 #
35 # Amount of RAM to use for RAM-based compressed swap space.
36 #
37 # An empty value - compcache isn't used, or added to the initramfs at all.
38 # An integer and K (e.g. 65536 K) - use a number of kilobytes.
39 # An integer and M (e.g. 256 M) - use a number of megabytes.
40 # An integer and G (e.g. 1 G) - use a number of gigabytes.
41 # An integer and % (e.g. 50 %) - use a percentage of the amount of RAM.
42 #
43 # You can optionally install the compcache package to configure this setting
44 # via debconf and have userspace scripts to load and unload compcache.
45 #
46
47 COMPCACHE_SIZE=""
48
49 #
50 # COMPRESS: [ gzip | bzip2 | lz4 | lzma | lzop | xz ]
51 #
52
53 COMPRESS=lz4
54
55 #
56 # NFS Section of the config.
57 #
58
59 #
60 # DEVICE: ...
61 #
62 # Specify a specific network interface, like eth0
63 # Overridden by optional ip= or BOOTIF= bootarg
64 #
65
66 DEVICE=
67
68 #
69 # NFSROOT: [ auto | HOST:MOUNT ]
70 #
71
72 NFSROOT=auto
73
74 #
75 # RUNSIZE: ...
76 #
77 # The size of the /run tmpfs mount point, like 256M or 10%
78 # Overridden by optional initramfs.runsize= bootarg
79 #
80
81 RUNSIZE=10%
Revision history for this message
|
#17 |
Since I last messaged, I have suddenly had to move. I have been too busy to go to a neighbor's to get online. That is why it has been so long.
Thank you.
Revision history for this message
|
#18 |
1. The information about /dev/sda shows that there is no free space around partition /dev/sda2 (which is the /boot partition), so you would have to completely rearrange also the /dev/sda3 partition to increase the size of /boot.
2. To change the compression to xz do the following:
open a terminal window
issue the command
sudo gedit /etc/initramfs-
scroll down to line 53 and replace
COMPRESS=lz4
by
COMPRESS=xz
then save the file and close the editor.
Revision history for this message
|
#19 |
How do I know if anything happened? The /boot is still at 48%. I still cannot run an update. Can I go back to Ubuntu 18?
Revision history for this message
|
#20 |
The issue isn't the release. Whomever setup your system made a poor choice of size for the /boot partition. You could reinstall 18.04 (I assume that's what you mean by "Ubuntu 18". There is no Ubuntu 18. It doesn't exist) and you'd still have the same problems. The file system is just too small.
If you are going to reinstall, I suggest don't use a separate partition for /boot and you'll not run into this problem. You can then use Ubuntu 20.04 and enjoy LTS support until April 2025
Revision history for this message
|
#21 |
The issue isn't the release. Whomever setup your system made a poor choice of size for the /boot partition. You could reinstall 18.04 (I assume that's what you mean by "Ubuntu 18". There is no Ubuntu 18. It doesn't exist) and you'd still have the same problems. The file system is just too small.
If you are going to reinstall, I suggest don't use a separate partition for /boot and you'll not run into this problem. You can then use Ubuntu 20.04 and enjoy LTS support until April 2025
Revision history for this message
|
#22 |
"How do I know if anything happened"
After changing the compression algorithm in the initramfs.conf configuration file you have to create a new version of the initramfs file with the command
sudo update-initramfs -u
You should check with
ls -l /boot
before and after that command, whether there is a significant change in size.
And for the need for a separate /boot partition:
I see that your root file system is using lvm (Logical Volume Manager) functions. Is there a specific reason for that?
Revision history for this message
|
#24 |
Manfred Hampl
I see that your root file system is using lvm (Logical Volume Manager) functions. Is there a specific reason for that?
Whatever the install set up when I put Ubuntu on is what I have been running with. I don't know why it is or what it is doing. I just want a basic OS that will let me do a few things online.
The total went from 99700 to 63266. Is that a significant change in size?
The update is running. No warnings.
The boot was at 60% after update. After I ran the command to remove all old kernals, the boot is at 31%. It appears that I can continue to use this system. Thank you so much.
The following warnings showed up. I don't know what to do about them. Can you help me with these?
WARNING: PV /dev/mapper/
WARNING: PV /dev/mapper/
Found linux image: /boot/vmlinuz-
Found initrd image: /boot/initrd.
WARNING: PV /dev/mapper/
WARNING: PV /dev/mapper/
WARNING: PV /dev/mapper/
Revision history for this message
|
#25 |
I assume that this "WARNING: PV /dev/mapper/
I do not think that this does any harm, but as far as the documentation tells, you can get rid of the messages by executing the following command:
sudo vgck --updatemetadata ubuntu-vg
(Disclaimer: I have never tried that myself.)
Revision history for this message
|
#26 |
I ran the command. This is what I got.
WARNING: PV /dev/mapper/
WARNING: updating PV header on /dev/mapper/
It sounds like it is updating the header.
Revision history for this message
|
#27 |
Thanks Manfred Hampl, that solved my question.