Tuesday, August 30, 2016

purge-old-kernels

My normal approach to cleaning up old kernels and headers in Ubuntu: In Synaptic, search linux-image, mark all but the two most recent linux-image packages for complete removal, search linux-header, mark all but the two most recent linux-headers packages for complete removal, apply the changes, reboot. This isn't something that normally needs to be done in Debian, but Ubuntu receives a lot more kernel updates and accumulates a lot more old kernels than you'll ever see in Debian Stable.

For the first time, I tried another approach: the purge-old-kernels command.

For info about using the purge-old-kernels command in Ubuntu, see http://blog.dustinkirkland.com/2016/06/purge-old-kernels.html and http://www.webupd8.org/2016/07/how-to-safely-remove-old-linux-kernels.html.

And, of course, don't forget to take a look at man purge-old-kernels.



Dustin Kirkland wrote, "You'll already have the purge-old-kernels command in Ubuntu 16.04 LTS (and later), as part of the byobu package." Here, turned out I had to install byobu in 16.04.

Then, I ran the following:

$ sudo purge-old-kernels
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libpango1.0-0 linux-headers-4.4.0-31 python3-feedparser unity-scopes-runner
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-headers-4.4.0-31-generic* linux-image-4.4.0-31-generic* linux-image-extra-4.4.0-31-generic*
  linux-signed-image-4.4.0-31-generic*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 225 MB disk space will be freed.
Do you want to continue? [Y/n]


I let that that operation proceed and then went back and ran the following as recommended by the output above:

$ sudo apt autoremove libpango1.0-0 linux-headers-4.4.0-31 python3-feedparser unity-scopes-runner
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  libpango1.0-0 linux-headers-4.4.0-31 python3-feedparser unity-scopes-runner
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 70.8 MB disk space will be freed.
Do you want to continue? [Y/n]


Again, I let the operation proceed. Seems to have worked out fine here, but as always, be careful when using that autoremove option! Perhaps take a look at the "autoremove" section in man apt:

autoremove (apt-get(8))
           autoremove is used to remove packages that were automatically installed to satisfy dependencies for other
           packages and are now no longer needed as dependencies changed or the package(s) needing them were removed
           in the meantime.

           You should check that the list does not include applications you have grown to like even though they were
           once installed just as a dependency of another package. You can mark such a package as manually installed
           by using apt-mark(8). Packages which you have installed explicitly via install are also never proposed for
           automatic removal.

No comments: