3.4 KiB
PLONK
PLONK stands for:
PLONK Leaves Only Needed Kernels
It is a small Debian-oriented shell script used to list, simulate and purge old Linux kernel packages.
In short:
old kernels go plonk.
What it does
PLONK helps keeping Debian systems clean by removing old kernel packages while preserving the kernels that are still needed.
It can:
- list old installed kernel packages;
- list kernel packages left in
rcstate; - simulate the purge operation before doing anything;
- purge old kernel packages;
- keep a configurable number of installed kernels;
- always keep the currently running kernel;
- avoid removing Debian kernel meta-packages such as
linux-image-amd64.
Why
Debian systems can accumulate old kernel packages over time, especially on long-lived servers or frequently updated machines.
Sometimes old kernels are already removed but still appear in dpkg output with rc status, meaning that only residual configuration files are left.
PLONK tries to clean both cases in a conservative way.
Requirements
PLONK requires:
- Debian;
bash;apt-get;dpkg-query;- root privileges when actually removing packages.
It is mainly written and tested with Debian in mind.
Usage
plonk [option]
Available options:
-l | --list : list old kernel packages
-n | --dry-run : simulate old kernel packages removal
-r | --remove : remove old kernel packages
-k | --keep NUM : number of kernels to keep
-y | --yes : assume yes when removing packages
-h | --help : show help and exit
Examples
List old kernel packages and residual rc packages:
./plonk --list
Simulate the purge operation:
./plonk --dry-run
Remove old kernel packages:
sudo ./plonk --remove
Remove old kernel packages and keep three installed kernels:
sudo ./plonk --remove --keep 3
Remove old kernel packages without confirmation:
sudo ./plonk --remove --yes
Recommended workflow
Before removing anything, always run:
./plonk --list
Then run:
./plonk --dry-run
Only after reviewing the output, run:
sudo ./plonk --remove
On production servers, remote systems or machines where rollback matters, keeping more than the default number of kernels is recommended:
sudo ./plonk --remove --keep 3
About rc packages
In dpkg output, packages in rc state are already removed, but their configuration files are still present.
Example:
rc linux-image-6.1.0-38-amd64 6.1.147-1 amd64 Linux 6.1 for 64-bit PCs
PLONK can purge those residual packages too.
Safety notes
PLONK is intentionally conservative.
It always keeps:
- the currently running kernel;
- at least one additional installed kernel by default;
- the related Debian kernel ABI packages;
- Debian kernel meta-packages.
Still, kernel removal can be risky. Always check the dry-run output before purging packages.
Install
Clone the repository:
git clone <repo-url>
cd plonk
Make the script executable:
chmod +x plonk
Optionally install it system-wide:
sudo install -m 0755 plonk /usr/local/sbin/plonk
Then run:
plonk --help
Name
plonk is both:
PLONK Leaves Only Needed Kernels
and the sound old kernels make when they finally disappear down the drain.
License
- GPL-3.0-or-later.