Skip to content

Commit 6c13a3b

Browse files
committed
Remove older kernels and snapd
1 parent 458a2d1 commit 6c13a3b

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

genesis/images/genesis_base/install.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright 2025 Genesis Corporation
3+
# Copyright 2025-2026 Genesis Corporation
44
#
55
# All Rights Reserved.
66
#
@@ -90,6 +90,17 @@ sudo chpasswd < /tmp/__passwd
9090
rm -f /tmp/__passwd
9191

9292
# Cleanup
93+
# remove old kernels, headers and modules, keep only the latest one
94+
LATEST_KERNEL=$(dpkg --list | grep 'linux-image-[0-9]' \
95+
| awk '{print $2}' | sort -V | tail -1 \
96+
| sed 's/linux-image-//' | sed 's/-generic$//')
97+
OLD_PKGS=$(dpkg --list \
98+
| grep -E "linux-(image|headers|modules|modules-extra)-[0-9]" \
99+
| awk '{print $2}' | grep -v "$LATEST_KERNEL")
100+
if [ -n "$OLD_PKGS" ]; then
101+
sudo DEBIAN_FRONTEND=noninteractive apt-get autopurge -y $OLD_PKGS
102+
fi
103+
sudo apt autopurge -y snapd libllvm19
93104
sudo rm -fr /opt/gci_base
94105
sudo apt-get clean
95106
sudo rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)