Random small break-fix or enlightening ideas
Ubuntu likes to cut space on my /boot
partitions awfully close when using their auto-partition method at install time. I had an apt update fail once because of a full /boot
partition and have been keeping an eye on them since. They frequently fill past 80%, so I clean out the old kernels when this happens. There is probably more of an automated way to do it, but this works for now.
Here is an example on a server where I received the last alert on:
[user]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/server--mc--01-root 11G 4.2G 6.2G 41% / udev 729M 12K 729M 1% /dev tmpfs 296M 264K 295M 1% /run none 5.0M 0 5.0M 0% /run/lock none 738M 0 738M 0% /run/shm /dev/sda1 228M 186M 31M 86% /boot
I hate the volume group name, but that’s another story. Notice the pretty full partition at the bottom. Let’s see what we have installed.
[root]$ dpkg --list | grep linux-image ii linux-image-3.2.0-48-generic 3.2.0-48.74 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-49-generic 3.2.0-49.75 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-51-generic 3.2.0-51.77 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-52-generic 3.2.0-52.78 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-53-generic 3.2.0-53.81 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-54-generic 3.2.0-54.82 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-55-generic 3.2.0-55.85 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-56-generic 3.2.0-56.86 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-server 3.2.0.56.66 Linux kernel image on Server Equipment.
Yup, a little gratuitous if you ask me. Before I change anything, let’s see what kernel version this box is currently running.
[root]$ uname -r 3.2.0-54-generic
Looks like I haven’t rebooted for a while. I will do that now and run the same command again.
[root]$ uname -r 3.2.0-56-generic
Much better. So I’m going to leave one previous version, and remove (purge) the rest. So in my case, I’m going to run this.
[root]$ apt-get purge linux-image-3.2.0-48-generic linux-image-3.2.0-49-generic linux-image-3.2.0-51-generic linux-image-3.2.0-52-generic linux-image-3.2.0-53-generic linux-image-3.2.0-54-generic
Keep in mind that YMMV. By the time you read this, your versions will be different. Don’t copy that above command as-is!
Once those commands are ran, the kernel list looks a bit cleaner.
[root]$ dpkg --list | grep linux-image ii linux-image-3.2.0-55-generic 3.2.0-55.85 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-3.2.0-56-generic 3.2.0-56.86 Linux kernel image for version 3.2.0 on 64 bit x86 SMP ii linux-image-server 3.2.0.56.66 Linux kernel image on Server Equipment.
Also, our disk space is much better.
[root]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/server--mc--01-root 11G 3.3G 7.0G 32% / udev 729M 12K 729M 1% /dev tmpfs 296M 252K 295M 1% /run none 5.0M 0 5.0M 0% /run/lock none 738M 0 738M 0% /run/shm /dev/sda1 228M 50M 167M 23% /boot