Adding a kernel removal script to linux-base or elsewhere
Ralf Mardorf
ralf.mardorf at alice-dsl.net
Thu Oct 13 23:36:08 UTC 2016
On Fri, 14 Oct 2016 00:09:44 +0100, J Fernyhough wrote:
>Doesn't `apt-get autoremove` remove old kernel versions already?
Yesno depending on how the meta package is installed, automatically or
manual. However, writhing scripts to manage something to a user's
individual needs isn't hard to do.
I don't need to care about dkms, an universal script must care about it,
too. I only need to care about lowlatency, an universal script should
be able to handle all types of kernels, including local builds. An
universal script should provide options, for example to keep two or
tree kernels of the same type.
My script does something unimportant for other users, it removes and
adds links required by the used bootloader. The script doesn't do
anything automatically in the first place, but it suggests something I
could copy and paste and add as the options that should be used.
[root at moonstudio ~]# cat /usr/local/sbin/lowlatency
#!/bin/bash
usage() {
cat<<EOF
Nothing has been done.
usage:
$(basename $0) old.version-release new.version-release
EOF
exit
}
echo "-----------"
echo "old : "$1
echo "new : "$2
s=$(dpkg -l linux-lowlatency |tail -n1|cut -d"y" -f2|cut -d" " -f2)
[ "$s" = "" ] || echo "dpkg-query: "$s
printf "modules : "
echo $(ls -vd /lib/modules/*-lowlatency|cut -d"/" -f4|sed s/-lowlatency/""/)
echo "-----------"
[ "$(id -u)" = "0" ] || usage
[ "$3" = "" ] || usage
case $2 in
"")
usage
;;
*)
case $1 in
"")
usage
;;
*)
[ "$1" = "$2" ] || apt-get purge linux-{headers,image}-$1-lowlatency linux-headers-$1
[ -L /initrd.img ] && unlink /initrd.img
[ -L /vmlinuz ] && unlink /vmlinuz
cd /boot
if [ "$(readlink initrd.img-lowlatency)" != "initrd.img-$2-lowlatency" ]; then
ln -sf initrd.img-$2-lowlatency initrd.img-lowlatency
fi
if [ "$(readlink vmlinuz-lowlatency)" != "vmlinuz-$2-lowlatency" ]; then
ln -sf vmlinuz-$2-lowlatency vmlinuz-lowlatency
fi
;;
esac
;;
esac
exit
More information about the Ubuntu-devel-discuss
mailing list