Ubuntu – Is removing old linux-headers and linux-image packages safe

aptkernel

I started using Ubuntu and like it so far.

I got my first system at a point where problems would really hurt.

Normally I do the apt-get upgrade stuff quite brain-off but this here made me feel a bit uncertain.

The following packages were automatically installed and are no longer required:
  linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic linux-image-4.15.0-29-generic linux-modules-4.15.0-29-generic linux-modules-extra-4.15.0-29-generic
Use 'sudo apt autoremove' to remove them.

I believe that newer version of this modules are installed and used already and that this old ones can be removed. But that is just me theory. When running autoremove it says that 335 MB will be freed.

Is this safe or not?

Update: I went for the autoremove with purge (even if I have enough space) I just seem to be greedily. It then popped up a purple screen asking me:

A new version of /boot/grub/menu.lst is available, but the version installed currently has been locally modified.
What would you like to do about menu.lst?

  • install the package maintainer's version
  • keep the local version currently installed
  • show the differences between the versions
  • show a side-by-side difference between the versions
  • show a 3-way difference between available versions
  • do a 3-way merge between available versions (experimental)
  • List item start a new shell to examine the situation

if I choose option 2: keep the local version, will it keep revert back to 4.15.0-29?
what should I do.
I'm sure this is just a small thing but I dont want this system to have short or longterm issues.

Update:
I compared both versions: one was the grub list and the other was some tmp list.
one was version 29 and the other had version 34. I pressed: keep the local version currently installed twice and rebootet.

$ uname -r
4.15.0-34-generic

hope that grub list is okay and its not the tmp list.

Nevertheless I wanted to thank all you guys for the amount of very detailed answers. I felt a bit bad for all the time you spent answering me the initial question.
But this seems to stand up for a decent community.

Best Answer

Yes, Michael - it is completely safe to remove this old kernel. By default Ubuntu keeps two kernels - the current one and the one before. One set of kernel packages uses about 335 MB disk space and that's why you receive the information about the freed space. To completely remove those old kernel packages, including all configuration files, execute this command (purge instead of autoremove) :

sudo apt purge linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic linux-image-4.15.0-29-generic linux-modules-4.15.0-29-generic linux-modules-extra-4.15.0-29-generic
Related Question