Cleaning up old kernels on an Ubuntu box

So, I’m piddling around, cleaning up old kernels on my crappy Ubuntu server.  I thought I’d make a note for future reference, I always have to Google whenever it occurs to me to do this.

Find the running kernel (so I know what not to delete):

root@schoolserver:~# uname -r

Here’s what I’ve got installed:

root@schoolserver:~# dpkg --list | grep linux-image | grep -v module
ii  linux-image-3.19.0-43-generic        3.19.0-43.49~14.04.1                 i386         Linux kernel image for version 3.19.0 on 32 bit x86 SMP
ii  linux-image-3.19.0-47-generic        3.19.0-47.53~14.04.1                 i386         Linux kernel image for version 3.19.0 on 32 bit x86 SMP
ii  linux-image-generic-lts-vivid                         i386         Generic Linux kernel image

Lemme remove the old, unused one:

root@schoolserver:~# apt-get purge linux-image-3.19.0-43-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.19.0-42 linux-headers-3.19.0-42-generic
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  linux-image-3.19.0-43-generic* linux-image-extra-3.19.0-43-generic*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 155 MB disk space will be freed.
Do you want to continue? [Y/n] y

There’s no power button on this weird machine, it boots when you plug it in.  My workaround for powering it off is that I’ve set the grub timeout to 3 minutes. Reboot, then unplug it at the grub menu.

Leave a Reply