View previous topic :: View next topic |
Author |
Message |
jasu n00b
Joined: 23 May 2022 Posts: 61
|
Posted: Tue Nov 29, 2022 3:09 pm Post subject: Correct way to delete old kernels and kernel related files? |
|
|
Hi,
I've read https://wiki.gentoo.org/wiki/Kernel/Removal article but I didn't fully grasp how to get rid of all old kernel's and files related to them.
Code: | eclean-kernel
No outdated kernels found.
|
Though
Code: | eclean-kernel -l
5.15.75-gentoo-x86_64 [5.15.75-gentoo-x86_64]
- systemmap: /boot/System.map-5.15.75-gentoo-x86_64
- initramfs: /boot/initramfs-5.15.75-gentoo-x86_64.img
- vmlinuz: /boot/vmlinuz-5.15.75-gentoo-x86_64
- modules: /lib/modules/5.15.75-gentoo-x86_64
- build: /usr/src/linux-5.15.75-gentoo
- last modified: 2022-11-29 13:56:20
5.15.75-gentoo-x86_64.old [5.15.75-gentoo-x86_64]
- systemmap: /boot/System.map-5.15.75-gentoo-x86_64.old
- initramfs: /boot/initramfs-5.15.75-gentoo-x86_64.img.old
- vmlinuz: /boot/vmlinuz-5.15.75-gentoo-x86_64.old
- modules: /lib/modules/5.15.75-gentoo-x86_64
- build: /usr/src/linux-5.15.75-gentoo
- last modified: 2022-11-29 12:15:02
5.15.48-gentoo-dist [5.15.48-gentoo-dist]
- systemmap: /boot/System.map-5.15.48-gentoo-dist
- config: /boot/config-5.15.48-gentoo-dist
- initramfs: /boot/initramfs-5.15.48-gentoo-dist.img
- vmlinuz: /boot/vmlinuz-5.15.48-gentoo-dist
- modules: /lib/modules/5.15.48-gentoo-dist
- last modified: 2022-06-19 11:55:17
5.15.46-gentoo-dist [5.15.46-gentoo-dist]
- systemmap: /boot/System.map-5.15.46-gentoo-dist
- config: /boot/config-5.15.46-gentoo-dist
- initramfs: /boot/initramfs-5.15.46-gentoo-dist.img
- vmlinuz: /boot/vmlinuz-5.15.46-gentoo-dist
- modules: /lib/modules/5.15.46-gentoo-dist
- last modified: 2022-06-17 00:35:06
5.15.41-gentoo-x86_64 [5.15.41-gentoo-x86_64]
- systemmap: /boot/System.map-5.15.41-gentoo-x86_64
- initramfs: /boot/initramfs-5.15.41-gentoo-x86_64.img
- vmlinuz: /boot/vmlinuz-5.15.41-gentoo-x86_64
- modules: /lib/modules/5.15.41-gentoo-x86_64
- build: /usr/src/linux-5.15.41-gentoo
- last modified: 2022-05-23 17:50:20
5.15.41-gentoo-x86_64.old [5.15.41-gentoo-x86_64]
- systemmap: /boot/System.map-5.15.41-gentoo-x86_64.old
- initramfs: /boot/initramfs-5.15.41-gentoo-x86_64.img.old
- vmlinuz: /boot/vmlinuz-5.15.41-gentoo-x86_64.old
- modules: /lib/modules/5.15.41-gentoo-x86_64
- build: /usr/src/linux-5.15.41-gentoo
- last modified: 2022-05-23 16:22:16
5.15.41-gentoo-dist [5.15.41-gentoo-dist]
- systemmap: /boot/System.map-5.15.41-gentoo-dist
- config: /boot/config-5.15.41-gentoo-dist
- initramfs: /boot/initramfs-5.15.41-gentoo-dist.img
- vmlinuz: /boot/vmlinuz-5.15.41-gentoo-dist
- modules: /lib/modules/5.15.41-gentoo-dist
- last modified: 2022-05-22 23:42:11 |
So I suppose that grub is somehow signaling that they are still needed?
My /boot is getting awfully crowded so I need to get rid of those files.
Code: | ls /boot
total 214M
-rwxr-xr-x 1 root root 230K May 23 2022 config-5.15.41-gentoo-dist*
-rwxr-xr-x 1 root root 230K Jun 17 04:35 config-5.15.46-gentoo-dist*
-rwxr-xr-x 1 root root 230K Jun 19 15:56 config-5.15.48-gentoo-dist*
drwxr-xr-x 3 root root 512 May 20 2022 EFI/
drwxr-xr-x 6 root root 1.0K Nov 29 16:55 grub/
-rwxr-xr-x 1 root root 32M May 23 2022 initramfs-5.15.41-gentoo-dist.img*
-rwxr-xr-x 1 root root 12M May 23 2022 initramfs-5.15.41-gentoo-x86_64.img*
-rwxr-xr-x 1 root root 11M May 23 2022 initramfs-5.15.41-gentoo-x86_64.img.old*
-rwxr-xr-x 1 root root 32M Jun 17 04:35 initramfs-5.15.46-gentoo-dist.img*
-rwxr-xr-x 1 root root 2.1M Jun 19 15:56 initramfs-5.15.48-gentoo-dist.img*
-rwxr-xr-x 1 root root 12M Nov 29 16:54 initramfs-5.15.75-gentoo-x86_64.img*
-rwxr-xr-x 1 root root 12M Nov 29 16:52 initramfs-5.15.75-gentoo-x86_64.img.old*
-rwxr-xr-x 1 root root 5.6M May 23 2022 System.map-5.15.41-gentoo-dist*
-rwxr-xr-x 1 root root 4.8M May 23 2022 System.map-5.15.41-gentoo-x86_64*
-rwxr-xr-x 1 root root 4.8M May 23 2022 System.map-5.15.41-gentoo-x86_64.old*
-rwxr-xr-x 1 root root 5.6M Jun 17 04:35 System.map-5.15.46-gentoo-dist*
-rwxr-xr-x 1 root root 5.6M Jun 19 15:56 System.map-5.15.48-gentoo-dist*
-rwxr-xr-x 1 root root 4.9M Nov 29 15:56 System.map-5.15.75-gentoo-x86_64*
-rwxr-xr-x 1 root root 4.8M Nov 29 14:15 System.map-5.15.75-gentoo-x86_64.old*
-rwxr-xr-x 1 root root 11M May 23 2022 vmlinuz-5.15.41-gentoo-dist*
-rwxr-xr-x 1 root root 9.2M Jul 6 22:36 vmlinuz-5.15.41-gentoo-x86_64*
-rwxr-xr-x 1 root root 9.2M May 23 2022 vmlinuz-5.15.41-gentoo-x86_64.old*
-rwxr-xr-x 1 root root 11M Jun 17 04:35 vmlinuz-5.15.46-gentoo-dist*
-rwxr-xr-x 1 root root 11M Jun 19 15:56 vmlinuz-5.15.48-gentoo-dist*
-rwxr-xr-x 1 root root 9.6M Nov 29 15:56 vmlinuz-5.15.75-gentoo-x86_64*
-rwxr-xr-x 1 root root 9.6M Nov 29 14:15 vmlinuz-5.15.75-gentoo-x86_64.old* |
What is the correct way to delete unused kernel files?
EDIT: Oh, it seems that I can just delete those manually. My bad. |
|
Back to top |
|
|
kite14 Apprentice
Joined: 07 Nov 2006 Posts: 216 Location: Italy
|
Posted: Tue Nov 29, 2022 4:18 pm Post subject: |
|
|
You can also use: to prune all kernel files referenced by bootloader (or present in /boot directory) except the newest one.
See Code: | eclean-kernel --help |
|
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5348 Location: Bavaria
|
Posted: Tue Nov 29, 2022 6:38 pm Post subject: |
|
|
AFAIK eclean-kernel will not delete user files from /usr/src/linux-x.y.z You have to delete them by yourself (rm -rf /usr/src/....)
The same is true for kernels (and related files) in /boot/
Also have a look into /lib/modules ... |
|
Back to top |
|
|
DavidF n00b
Joined: 12 Jan 2004 Posts: 45 Location: Rocky Mountains
|
Posted: Tue Nov 29, 2022 7:21 pm Post subject: |
|
|
Quote: | AFAIK eclean-kernel will not delete user files from /usr/src/linux-x.y.z You have to delete them by yourself (rm -rf /usr/src/....)
The same is true for kernels (and related files) in /boot/ |
That's interesting, I have been using depclean, eclean-kernel -n 3 and it removes files from /boot and /usr/src/ and /lib/modules . Is that because I am using genkernel to compile the kernel?[/quote] |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2657
|
Posted: Tue Nov 29, 2022 7:27 pm Post subject: |
|
|
DavidF wrote: | Quote: | AFAIK eclean-kernel will not delete user files from /usr/src/linux-x.y.z You have to delete them by yourself (rm -rf /usr/src/....)
The same is true for kernels (and related files) in /boot/ |
That's interesting, I have been using depclean, eclean-kernel -n 3 and it removes files from /boot and /usr/src/ and /lib/modules . Is that because I am using genkernel to compile the kernel? |
Possibly. If genkernel tells the build scripts to use another output directory, the directories under /usr/src would not contain user files.
But I don't know if that's the case, I don't use genkernel.
Regards,
Georgi |
|
Back to top |
|
|
kite14 Apprentice
Joined: 07 Nov 2006 Posts: 216 Location: Italy
|
Posted: Wed Nov 30, 2022 8:18 pm Post subject: |
|
|
pietinger wrote: | AFAIK eclean-kernel will not delete user files from /usr/src/linux-x.y.z You have to delete them by yourself (rm -rf /usr/src/....)
The same is true for kernels (and related files) in /boot/
Also have a look into /lib/modules ... |
I usually clean old kernels manually (all the stuff in /boot, /usr/src/, /lib/modules/) but looks like eclean-kernels -n can do the same job, except for the kernel sources, unless you clean it up before with
Here an example of a dry run on my system:
Code: | $ eclean-kernel -p -n 1
Legend:
[-] file being removed
[+] file being kept (used by other kernels)
These are the kernels which would be removed:
- 5.15.75-gentoo.old: not referenced by bootloader (symlinks)
[-] /boot/vmlinuz-5.15.75-gentoo.old
[+] /usr/src/linux-5.15.75-gentoo
[+] /lib/modules/5.15.75-gentoo
[-] /boot/System.map-5.15.75-gentoo.old
[-] /boot/config-5.15.75-gentoo.old
- 5.15.74-gentoo: not referenced by bootloader (symlinks)
[-] /boot/vmlinuz-5.15.74-gentoo
[-] /lib/modules/5.15.74-gentoo
[-] /boot/System.map-5.15.74-gentoo
[-] /boot/config-5.15.74-gentoo |
|
|
Back to top |
|
|
freke Veteran
Joined: 23 Jan 2003 Posts: 1048 Location: Somewhere in Denmark
|
Posted: Sun Dec 11, 2022 5:37 pm Post subject: |
|
|
DavidF wrote: | Quote: | AFAIK eclean-kernel will not delete user files from /usr/src/linux-x.y.z You have to delete them by yourself (rm -rf /usr/src/....)
The same is true for kernels (and related files) in /boot/ |
That's interesting, I have been using depclean, eclean-kernel -n 3 and it removes files from /boot and /usr/src/ and /lib/modules . Is that because I am using genkernel to compile the kernel? |
It's not because of genkernel - it's because of the - without -n (or -d) all kernels referenced by grub is left untouched.
With ie. -n 3 the three newest kernels (+ the running kernel if not one of the three newest) is left - all others are pruned. |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2657
|
Posted: Mon Dec 12, 2022 12:31 pm Post subject: |
|
|
kite14 wrote: | pietinger wrote: | AFAIK eclean-kernel will not delete user files from /usr/src/linux-x.y.z You have to delete them by yourself (rm -rf /usr/src/....)
The same is true for kernels (and related files) in /boot/
Also have a look into /lib/modules ... |
I usually clean old kernels manually (all the stuff in /boot, /usr/src/, /lib/modules/) but looks like eclean-kernels -n can do the same job, except for the kernel sources, unless you clean it up before with
Here an example of a dry run on my system:
Code: | $ eclean-kernel -p -n 1
Legend:
[-] file being removed
[+] file being kept (used by other kernels)
These are the kernels which would be removed:
- 5.15.75-gentoo.old: not referenced by bootloader (symlinks)
[-] /boot/vmlinuz-5.15.75-gentoo.old
[+] /usr/src/linux-5.15.75-gentoo
[+] /lib/modules/5.15.75-gentoo
[-] /boot/System.map-5.15.75-gentoo.old
[-] /boot/config-5.15.75-gentoo.old
- 5.15.74-gentoo: not referenced by bootloader (symlinks)
[-] /boot/vmlinuz-5.15.74-gentoo
[-] /lib/modules/5.15.74-gentoo
[-] /boot/System.map-5.15.74-gentoo
[-] /boot/config-5.15.74-gentoo |
|
That works because you're not changing CONFIG_LOCALVERSION. I use it for testing the new kernel and if it works well I change it once again to mark it known good and make sure that even if I test something else on the same global kernel version, the files will go in other directories with other names and won't affect my currently known good kernel. Thus, *I think* eclean-kernel would not clean versions not currently referenced by your local version.
This should either be tested or someone who knows should tell us. I currently have no other versions to confirm my speculation.
Regards,
Georgi |
|
Back to top |
|
|
|