Skip to content

Commit 8300e0c

Browse files
author
Mike Seidle
committed
Added tool to clean up old kernel images in /boot on ubuntu
1 parent 42b6d97 commit 8300e0c

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@
1515
*.exe
1616
*.out
1717
*.app
18+
19+
# editor artifacts
20+
\#*\#
21+
*~

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
bash
22
====
3+
Misc. useful bash scripts that are useful to me, and maybe someone else.
4+
5+
License
6+
-------
7+
GNU GPL V2 - http://www.gnu.org/licenses/gpl-2.0.html
8+
9+
What's In This Repo?
10+
--------------------
11+
* /ubuntu - Ubuntu specific scripts
12+
* clean-kernel-images.sh - Script for removing old kernels from /boot. In other news, Ubuntu server defaults to a tiny /boot partition and aftere 5-10 upgrades it runs out of space.
313

4-
Misc. useful bash scripts

ubuntu/clean-kernel-images.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# clean-kernel-images.sh
4+
# ----------------------
5+
# removes old kernel images from /boot
6+
#
7+
# does so by creating a list of kernel images in /tmp/oldimages and
8+
# then calling apt-get purge for each. Use this two ways:
9+
#
10+
# Get rid of all but the current Kernel:
11+
#
12+
# $ sudo cleankernelimages
13+
#
14+
# Create a list of kernels, review and then remove.
15+
#
16+
# $ sudo createkernellist
17+
#
18+
# edit /tmp/oldimages with your favorite text editor
19+
#
20+
# sudo removeoldkernels
21+
#
22+
23+
function createkernellist()
24+
{
25+
dpkg -l ‘linux-*| sed ‘/^ii/!d;/’”$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)”‘/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’ >/tmp/oldimages
26+
}
27+
28+
function removeoldkernels()
29+
{
30+
cat /tmp/file | xargs sudo apt-get -y purge
31+
}
32+
33+
function cleankernelimages()
34+
{
35+
cleankernelimages
36+
removeoldkernels
37+
}

0 commit comments

Comments
 (0)