# Remove old Kernel's

**URL:** https://dietpi.com/forum/t/remove-old-kernels/19896
**Category:** General Discussion
**Created:** [14 April 2024 08:40 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896 "2024-04-14T08:40:44Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![pede](https://dietpi.com/forum/user_avatar/dietpi.com/pede/32/3716_2.png) [@pede](https://dietpi.com/forum/u/pede)
#### Post date: [14 April 2024 08:40 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/1 "2024-04-14T08:40:44Z")

</div>

Hi,

with every kernel-update dietpi/debian keeps the old kernel. How can I remove the old kernels?

Peter

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [14 April 2024 09:02 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/2 "2024-04-14T09:02:32Z")

</div>

Pls share some more information on your system

#### Required

- DietPi version | `cat /boot/dietpi/.version`
- Distro version | `echo $G_DISTRO_NAME $G_RASPBIAN`
- Kernel version | `uname -a`
- Architecture | `dpkg --print-architecture`
- SBC model | `echo $G_HW_MODEL_NAME` or (EG: RPi3)

As well following information is needed

```auto
ls -la /boot

```

---

<div class="post-metadata">

### Author: ![pede](https://dietpi.com/forum/user_avatar/dietpi.com/pede/32/3716_2.png) [@pede](https://dietpi.com/forum/u/pede)
#### Post date: [14 April 2024 09:18 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/3 "2024-04-14T09:18:13Z")

</div>

> [@Joulinar](#):
>
> cat /boot/dietpi/.version

G\_DIETPI\_VERSION\_CORE=9  
G\_DIETPI\_VERSION\_SUB=2  
G\_DIETPI\_VERSION\_RC=1  
G\_GITBRANCH=‘master’  
G\_GITOWNER=‘MichaIng’

bookworm

Linux DietPi 6.1.0-20-amd64 #1 SMP PREEMPT\_DYNAMIC Debian 6.1.85-1 (2024-04-11) x86\_64 GNU/Linux

amd 64

Native PC (x86\_64)

```sh
insgesamt 662077
drwxr-xr-x 5 root root 4096 14. Apr 10:14 .
drwxr-xr-x 20 root root 4096 17. Mär 02:58 ..
-rw-r--r-- 1 root root 236275 21. Okt 2022 config-5.10.0-19-amd64
-rw-r--r-- 1 root root 236452 21. Jan 2023 config-5.10.0-21-amd64
-rw-r--r-- 1 root root 236469 22. Apr 2023 config-5.10.0-22-amd64
-rw-r--r-- 1 root root 259507 27. Jul 2023 config-6.1.0-10-amd64
-rw-r--r-- 1 root root 259602 8. Aug 2023 config-6.1.0-11-amd64
-rw-r--r-- 1 root root 259602 7. Sep 2023 config-6.1.0-12-amd64
-rw-r--r-- 1 root root 259421 29. Sep 2023 config-6.1.0-13-amd64
-rw-r--r-- 1 root root 259455 30. Nov 16:41 config-6.1.0-14-amd64
-rw-r--r-- 1 root root 259455 9. Dez 16:48 config-6.1.0-15-amd64
-rw-r--r-- 1 root root 259455 12. Dez 13:16 config-6.1.0-16-amd64
-rw-r--r-- 1 root root 259420 30. Dez 10:31 config-6.1.0-17-amd64
-rw-r--r-- 1 root root 259453 1. Feb 09:05 config-6.1.0-18-amd64
-rw-r--r-- 1 root root 259525 11. Apr 23:17 config-6.1.0-20-amd64
-rw-r--r-- 1 root root 259446 8. Mai 2023 config-6.1.0-9-amd64
drwxr-xr-x 4 root root 4096 17. Mär 02:58 dietpi
-rw-r--r-- 1 root root 18092 23. Okt 2022 dietpi-LICENSE.txt
-rw-r--r-- 1 root root 15251 23. Okt 2022 dietpi-README.md
-rw-r--r-- 1 root root 16252 27. Aug 2023 dietpi.txt
drwxr-xr-x 3 root root 512 1. Jan 1970 efi
drwxr-xr-x 5 root root 4096 14. Apr 10:14 grub
-rw-r--r-- 1 root root 35971064 6. Nov 2022 initrd.img-5.10.0-19-amd64
-rw-r--r-- 1 root root 35975343 24. Jan 2023 initrd.img-5.10.0-21-amd64
-rw-r--r-- 1 root root 37887403 30. Apr 2023 initrd.img-5.10.0-22-amd64
-rw-r--r-- 1 root root 45884298 31. Jul 2023 initrd.img-6.1.0-10-amd64
-rw-r--r-- 1 root root 45979422 13. Aug 2023 initrd.img-6.1.0-11-amd64
-rw-r--r-- 1 root root 39564160 11. Sep 2023 initrd.img-6.1.0-12-amd64
-rw-r--r-- 1 root root 39570221 24. Nov 07:28 initrd.img-6.1.0-13-amd64
-rw-r--r-- 1 root root 39556905 9. Dez 14:14 initrd.img-6.1.0-14-amd64
-rw-r--r-- 1 root root 39554518 11. Dez 22:11 initrd.img-6.1.0-15-amd64
-rw-r--r-- 1 root root 39565503 17. Dez 10:30 initrd.img-6.1.0-16-amd64
-rw-r--r-- 1 root root 39559017 1. Jan 21:46 initrd.img-6.1.0-17-amd64
-rw-r--r-- 1 root root 39565398 11. Feb 10:58 initrd.img-6.1.0-18-amd64
-rw-r--r-- 1 root root 39572650 14. Apr 10:14 initrd.img-6.1.0-20-amd64
-rw-r--r-- 1 root root 45843056 27. Jun 2023 initrd.img-6.1.0-9-amd64
-rw-r--r-- 1 root root 83 21. Okt 2022 System.map-5.10.0-19-amd64
-rw-r--r-- 1 root root 83 21. Jan 2023 System.map-5.10.0-21-amd64
-rw-r--r-- 1 root root 83 22. Apr 2023 System.map-5.10.0-22-amd64
-rw-r--r-- 1 root root 83 27. Jul 2023 System.map-6.1.0-10-amd64
-rw-r--r-- 1 root root 83 8. Aug 2023 System.map-6.1.0-11-amd64
-rw-r--r-- 1 root root 83 7. Sep 2023 System.map-6.1.0-12-amd64
-rw-r--r-- 1 root root 83 29. Sep 2023 System.map-6.1.0-13-amd64
-rw-r--r-- 1 root root 83 30. Nov 16:41 System.map-6.1.0-14-amd64
-rw-r--r-- 1 root root 83 9. Dez 16:48 System.map-6.1.0-15-amd64
-rw-r--r-- 1 root root 83 12. Dez 13:16 System.map-6.1.0-16-amd64
-rw-r--r-- 1 root root 83 30. Dez 10:31 System.map-6.1.0-17-amd64
-rw-r--r-- 1 root root 83 1. Feb 09:05 System.map-6.1.0-18-amd64
-rw-r--r-- 1 root root 83 11. Apr 23:17 System.map-6.1.0-20-amd64
-rw-r--r-- 1 root root 83 8. Mai 2023 System.map-6.1.0-9-amd64
-rw-r--r-- 1 root root 6963648 21. Okt 2022 vmlinuz-5.10.0-19-amd64
-rw-r--r-- 1 root root 7019136 21. Jan 2023 vmlinuz-5.10.0-21-amd64
-rw-r--r-- 1 root root 7035328 22. Apr 2023 vmlinuz-5.10.0-22-amd64
-rw-r--r-- 1 root root 7977248 27. Jul 2023 vmlinuz-6.1.0-10-amd64
-rw-r--r-- 1 root root 7971232 8. Aug 2023 vmlinuz-6.1.0-11-amd64
-rw-r--r-- 1 root root 8139648 7. Sep 2023 vmlinuz-6.1.0-12-amd64
-rw-r--r-- 1 root root 8135584 29. Sep 2023 vmlinuz-6.1.0-13-amd64
-rw-r--r-- 1 root root 8168256 30. Nov 16:41 vmlinuz-6.1.0-14-amd64
-rw-r--r-- 1 root root 8140672 9. Dez 16:48 vmlinuz-6.1.0-15-amd64
-rw-r--r-- 1 root root 8148352 12. Dez 13:16 vmlinuz-6.1.0-16-amd64
-rw-r--r-- 1 root root 8147424 30. Dez 10:31 vmlinuz-6.1.0-17-amd64
-rw-r--r-- 1 root root 8152768 1. Feb 09:05 vmlinuz-6.1.0-18-amd64
-rw-r--r-- 1 root root 8167616 11. Apr 23:17 vmlinuz-6.1.0-20-amd64
-rw-r--r-- 1 root root 7962368 8. Mai 2023 vmlinuz-6.1.0-9-amd64

```

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [14 April 2024 09:59 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/4 "2024-04-14T09:59:13Z")

</div>

can you try following

```auto
apt autoremove

```

Usually this should remove not needed packages

There should be a similar message while running `apt upgrade`

```auto
root@DietPi:~# apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
  linux-image-6.1.0-18-amd64
Use 'apt autoremove' to remove it.
The following NEW packages will be installed:
  linux-image-6.1.0-20-amd64

```

---

<div class="post-metadata">

### Author: ![pede](https://dietpi.com/forum/user_avatar/dietpi.com/pede/32/3716_2.png) [@pede](https://dietpi.com/forum/u/pede)
#### Post date: [14 April 2024 10:04 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/5 "2024-04-14T10:04:22Z")

</div>

Autoremove does not remove the unused kernerl’s. This is part of my Alias in bash to run an update/upgrade.

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [14 April 2024 10:09 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/6 "2024-04-14T10:09:18Z")

</div>

Testing on a VM is working quite well

```auto
root@DietPi:~# apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  linux-image-6.1.0-18-amd64
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 408 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 23597 files and directories currently installed.)
Removing linux-image-6.1.0-18-amd64 (6.1.76-1) ...
/etc/kernel/postrm.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.0-20-amd64
Found initrd image: /boot/initrd.img-6.1.0-20-amd64
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done
root@DietPi:~#

```

Did you tried running `apt autoremove` after a reboot?

And what is the output of following

```auto
dpkg -l linux-image*

```

---

<div class="post-metadata">

### Author: ![pede](https://dietpi.com/forum/user_avatar/dietpi.com/pede/32/3716_2.png) [@pede](https://dietpi.com/forum/u/pede)
#### Post date: [14 April 2024 10:13 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/7 "2024-04-14T10:13:17Z")

</div>

> [@Joulinar](#):
>
> `dpkg -l linux-image*`

A reboot give the same result for auto remove.

```auto
dietpi@DietPi:~$ dpkg -l linux-image*
Gewünscht=Unbekannt/Installieren/R=Entfernen/P=Vollständig Löschen/Halten
| Status=Nicht/Installiert/Config/U=Entpackt/halb konFiguriert/
         Halb installiert/Trigger erWartet/Trigger anhängig
|/ Fehler?=(kein)/R=Neuinstallation notwendig (Status, Fehler: GROSS=schlecht)
||/ Name Version Architektur Beschreibung
+++-====================================-============-============-===================================
ii linux-image-5.10.0-19-amd64 5.10.149-2 amd64 Linux 5.10 for 64-bit PCs (signed)
un linux-image-5.10.0-19-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
rc linux-image-5.10.0-20-amd64 5.10.158-2 amd64 Linux 5.10 for 64-bit PCs (signed)
un linux-image-5.10.0-20-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-5.10.0-21-amd64 5.10.162-1 amd64 Linux 5.10 for 64-bit PCs (signed)
un linux-image-5.10.0-21-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-5.10.0-22-amd64 5.10.178-3 amd64 Linux 5.10 for 64-bit PCs (signed)
un linux-image-5.10.0-22-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-10-amd64 6.1.38-2 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-10-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-11-amd64 6.1.38-4 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-11-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-12-amd64 6.1.52-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-12-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-13-amd64 6.1.55-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-13-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-14-amd64 6.1.64-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-14-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-15-amd64 6.1.66-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-15-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-16-amd64 6.1.67-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-16-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-17-amd64 6.1.69-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-17-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-18-amd64 6.1.76-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-18-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-20-amd64 6.1.85-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-20-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-6.1.0-9-amd64 6.1.27-1 amd64 Linux 6.1 for 64-bit PCs (signed)
un linux-image-6.1.0-9-amd64-unsigned <keine> <keine> (keine Beschreibung vorhanden)
ii linux-image-amd64 6.1.85-1 amd64 Linux for 64-bit PCs (meta-package)
un linux-image-generic <keine> <keine> (keine Beschreibung vorhanden)

```

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [14 April 2024 10:21 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/8 "2024-04-14T10:21:50Z")

</div>

looks like all the kernel packages are still installed. Therefore `apt autoremove` did not have any effect.

Can you try to remove one of the packages manually? Like

```auto
apt purge linux-image-5.10.0-19-amd64

```

---

<div class="post-metadata">

### Author: ![pede](https://dietpi.com/forum/user_avatar/dietpi.com/pede/32/3716_2.png) [@pede](https://dietpi.com/forum/u/pede)
#### Post date: [14 April 2024 10:25 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/9 "2024-04-14T10:25:28Z")

</div>

> [@Joulinar](#):
>
> `apt purge linux-image-5.10.0-19-amd64`

That worked. So I have to do that with the other kernel’s too.

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [14 April 2024 10:34 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/10 "2024-04-14T10:34:46Z")

</div>

yes this time. Usually it should happen automatically. At least it is removing old kernel on my demo VM.

---

<div class="post-metadata">

### Author: ![pede](https://dietpi.com/forum/user_avatar/dietpi.com/pede/32/3716_2.png) [@pede](https://dietpi.com/forum/u/pede)
#### Post date: [14 April 2024 11:07 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/11 "2024-04-14T11:07:21Z")

</div>

When upgrading the kernel, a window always opens and you are asked whether you want to delete the currently active kernel. Can this be done safely?

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [14 April 2024 11:11 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/12 "2024-04-14T11:11:07Z")

</div>

can you share that message?

---

<div class="post-metadata">

### Author: ![pede](https://dietpi.com/forum/user_avatar/dietpi.com/pede/32/3716_2.png) [@pede](https://dietpi.com/forum/u/pede)
#### Post date: [14 April 2024 11:11 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/13 "2024-04-14T11:11:58Z")

</div>

I will come back on this next kernel update 😉

---

<div class="post-metadata">

### Author: ![system](https://dietpi.com/forum/uploads/default/original/1X/7e1021de2213860bce185915ce2c1786e56490ec.png) [@system](https://dietpi.com/forum/u/system)
#### Post date: [13 July 2024 11:12 UTC](https://dietpi.com/forum/t/remove-old-kernels/19896/14 "2024-07-13T11:12:05Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
