Is there unused `initrd.img` to remove?
d 2 years, 3 months ago
Active 1 year, 8 months ago
Viewed 13k times
4
Looks like I have a unnecessary initrd.img in my /boot directory:
$ ls -1s /boot
total 82835
1439 abi-4.11.0-10-generic
204 config-4.11.0-10-generic
1 extlinux
1 grub
48186 initrd.img-4.11.0-10-generic
10626 initrd.img-4.8.0-34-generic
10626 initrd.img-4.8.0-39-generic
12 lost+found
180 memtest86+.bin
182 memtest86+.elf
182 memtest86+_multiboot.bin
3695 System.map-4.11.0-10-generic
7501 vmlinuz-4.11.0-10-generic
These are initrd.img-4.8.0-34-generic and initrd.img-4.8.0-39-generic because I cannot find any traces of them
$ sudo update-grub2
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.11.0-10-generic
Found initrd image: /boot/initrd.img-4.11.0-10-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done
$ dpkg -l *4.8.0*
dpkg-query: no packages found matching *4.8.0*
$ dpkg -l linux-*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===========================-==================-==================-===========================================================
ii linux-base 4.5ubuntu1 all Linux image base package
un linux-doc-4.11.0 <none> <none> (no description available)
ii linux-firmware 1.167 all Firmware for Linux kernel drivers
ii linux-generic 4.11.0.10.10 amd64 Complete Generic Linux kernel and headers
un linux-headers <none> <none> (no description available)
un linux-headers-3.0 <none> <none> (no description available)
ii linux-headers-4.11.0-10 4.11.0-10.15 all Header files related to Linux kernel version 4.11.0
ii linux-headers-4.11.0-10-gen 4.11.0-10.15 amd64 Linux kernel headers for version 4.11.0 on 64 bit x86 SMP
ii linux-headers-generic 4.11.0.10.10 amd64 Generic Linux kernel headers
un linux-image <none> <none> (no description available)
ii linux-image-4.11.0-10-gener 4.11.0-10.15 amd64 Linux kernel image for version 4.11.0 on 64 bit x86 SMP
ii linux-image-extra-4.11.0-10 4.11.0-10.15 amd64 Linux kernel extra modules for version 4.11.0 on 64 bit x86
ii linux-image-generic 4.11.0.10.10 amd64 Generic Linux kernel image
un linux-initramfs-tool <none> <none> (no description available)
un linux-kernel-headers <none> <none> (no description available)
un linux-kernel-log-daemon <none> <none> (no description available)
ii linux-libc-dev:amd64 4.11.0-10.15 amd64 Linux Kernel Headers for development
ii linux-libc-dev:i386 4.11.0-10.15 i386 Linux Kernel Headers for development
un linux-restricted-common <none> <none> (no description available)
ii linux-sound-base 1.0.25+dfsg-0ubunt all base package for ALSA and OSS sound systems
un linux-source-4.11.0 <none> <none> (no description available)
un linux-tools <none> <none> (no description available)
Are these both really useless? If they are useless, what is the correct way to remove them (I read, that rm strictly unrecommended for /boot folder)?
EDIT1: sudo apt autoremove cannot help either.
boot kernel
shareimprove this question
edited Jul 13 '17 at 19:34
Ravexina
36.8k1515 gold badges101101 silver badges130130 bronze badges
asked Jul 13 '17 at 17:05
Loom
35611 gold badge55 silver badges1515 bronze badges
Did you try sudo apt autoremove? – George Udosen Jul 13 '17 at 17:29
add a comment
2 Answers
active
oldest
votes
7
"initrd" images will be created each time a package triggers update-initramfs, so it's unlikely that you can find a corresponding package to them.
Use:
dpkg -S /boot/initrd.img*
to see the image has been placed by which package, you should get:
dpkg-query: no path found matching pattern /boot/initrd.img-4...
which means "I can't find any related package to this file", just as I said.
So here is my suggestion,
Remove all "initrd" images:
sudo rm /boot/initrd.img*
Generate new "intird" images for all of your currently installed kernels:
sudo update-initramfs -c -k all
You're done.
shareimprove this answer
edited Jul 15 '17 at 13:50
answered Jul 13 '17 at 19:27
Ravexina
36.8k1515 gold badges101101 silver badges130130 bronze badges
I removed all initrd images an generated the one for the current kernel, but dpkg -S still says no path found .. for the newly installed image. – sinclair May 10 '18 at 2:13
Sadly, this doesn't work (I am on Ubuntu 14.04 running kernel 3.13.0-149-generic). Each time I run the last command, the update-initramfs generates the unwanted initrd.img file again. – Sonny May 29 '18 at 20:40
4
The thing that did work is from the link help.ubuntu.com/community/RemoveOldKernels and does this: $ sudo update-initramfs -d -k 4.8.0-34-generic. Then, run update-initramfs -c -k all. It works then. – Sonny May 29 '18 at 20:49
@sinclair This answer has explained that. It says that dpkg won't know the initrd images because they are not in the downloaded package. The initrd images are generated locally after installing the package. – Franklin Yu Oct 2 '18 at 18:57
add a comment
4
In your case, I think it is ok to remove the initrd.img manually since you clearly do not have a linux-image-4.8.0-34-generic.
For anyone else who comes across this thread and needs to get rid of an "extra" initrd.img, you might have an "extra" linux-image installed which is what update-initramfs is using to generate this "unwanted" initrd.img
So before running sudo rm /boot/initrd.img*, consider running:
sudo apt-get remove linux-image-4.8.0-34-generic
Now run:
sudo update-initramfs -c -k all
I know you already solved your problem, but I thought another person might need quick instructions and might not understand the uniqueness of your problem.
Unless you are VERY sure of what you are doing, do not manually remove system files.
You might need to run sudo update-grub manually afterwards.
shareimprove this answer
answered Feb 19 '18 at 18:01
user797138
Thank you, you've been very helpful.
https://askubuntu.com/questions/935871/is-there-unused-initrd-img-to-remove