2

I have a server I'm maintaining, and on weekly bases, I basically have to delete some big files like old backups and what not to keep the server from crashing and reaching maximum capacity. Although today I noticed as I listed all the big files by running "sudo find . -size +10000k -exec ls -sd {} +"

I found these three big initrd.img files popping up.

enter image description here

Now I understand these are my Kernels. By running "uname -r" I got the output "4.15.0-64-generic". Does that mean I can safely remove 4.15.0-96-generic and 4.15.0-99-generic?

It seems intuitive to only have one file, but I didn't attempt to delete anything as I'm not aware how initial ram disk exactly works. Reading articles about it didn't help with answering my question about these files either. If someone could elaborate, I would greatly appreciate it, thanks!

Extra Details:

Distributor ID: Ubuntu

Description: Ubuntu 18.04.3 LTS

Release: 18.04

Codename: bionic

Version of Linux: Ubuntu Server (Specifically a DigitalOceans droplet)

Kulfy
  • 17,696
  • 4
    Those are ramdisk files, and there's one for every kernel that you have installed. Don't remove them if you expect those kernels to boot. – heynnema May 13 '20 at 20:13
  • @K7AAY I have now updated my question with the extra details. – Walrus Artist May 14 '20 at 11:43
  • If one kernel gets corrupted, it can be handy to have another. I always keep two, the one I want to boot with, and one release previous. – K7AAY May 14 '20 at 15:23

1 Answers1

1

The files you list appear newer than your running kernel. I would guess newer kernel packages were installed but the server was not rebooted. I suggest rebooting after patching to avoid possible issues.

I'd advise against manually deleting the files if you are unsure about them. Apt has ways to automatically manage the kernel files and delete unneeded ones.

Generally, you can clean up older kernels using apt-get autoremove

Apt will keep the latest 2 kernels installed due to the generated config at /etc/apt/apt.conf.d/01autoremove-kernels

Sometimes kernel packages get marked as manual install and some files do not deleted. This command resets the packages back to auto, which allows autoremove to remove the old packages (and delete the old files)

apt-mark auto $(apt-mark showmanual | grep -E -- "^linux-([[:alpha:]]+-)+[[:digit:].]+-[^-]+(|-.+)$")

More background