I build lots of linux-kernels, old ones accumulate, along with their
/lib/modules/`uname -r` files. For years, I'd occasionally go into
a machine as root and manually delete the accumulated dross in /boot
and /lib/modules.
Finally got around to writing a bash script that reads /etc/lilo.conf
and deletes unreferenced kernel files. Two runs, one through /boot,
another through /lib/modules discover stale kernels and modules and
remove them.
Anyone game enough to review / try out the script? It is part of a
set of updated kernel-build scripts I'm writing, see it here:
<http://bugsplatter.mine.nu/bash/kernel/rm-old-kernels>
Along with some notes and other kernel build scripts under:
<http://bugsplatter.mine.nu/bash/kernel/>
Cheers,
Grant.
--
Memory fault -- brain fried
This is nice.. I'll have to check it out and see if this
can be useful for myself or not. I don't have too many old kernels
laying around. Usually only two.
Grant:
Just a suggestion, but you might consider using a variable for the
kernel name instead of assuming :) It's much more difficult to make
that script work for me (I use "vmlinuz-$VERSION") than it would be
if it used something like:
KERNEL_NAME=bzImage
and referred to $KERNEL_NAME instead of hard-coded bzImage
RW
--
>On 2006-06-09, Grant <bugsp...@gmail.com> wrote:
>>
>> Anyone game enough to review / try out the script? It is part of a
>> set of updated kernel-build scripts I'm writing, see it here:
>>
>> <http://bugsplatter.mine.nu/bash/kernel/rm-old-kernels>
>
>
>Grant:
>Just a suggestion, but you might consider using a variable for the
>kernel name instead of assuming :)
Your assumption is based on commentary example rather than the
script, there is no hard-coded "bzImage". There is a tweak to
recognise slackware's non-conventional "*ide-*" kernel name.
Well, yeah, I noticed that after I looked a bit farther into the
script; however, it was too late at that point - I'd already sent
my comment out into the ether-land... That's what I get for
jumping to conclusions...
<apology sent>
RW
--
>Well, yeah, I noticed that after I looked a bit farther into the
>script; however, it was too late at that point - I'd already sent
>my comment out into the ether-land...
Well, the commentary does have a heading 'Assumptions', but in my
mind it was a focus on tying of kernel, System.map and config names
together with the kernel-version, not the particular kernel name
vmlinuz, vmlinux or bzImage ;)
Cheers,
Hello,
I'll have to build a few new kernels now to try out your script
a bit harder (I had a HD crash last fortnight so after transfer of
backucps to a nex machine I haven't had much time to catch up with
the LK pace ;-) Imagine I'm still on 2.6.16.17 !-)
Nevertheless, I post here a small patch for your script:
1 typo and 2 alomost cometic suggestions for easier reading
and maintaining of a ouija test.
I `think (TM)' that I'd have some more to suggest in the
regexps parts (some of my vm Sysmap variants seems to escape
this shot) but I'm a bit busy at the time (I bought a spare
HD for the dying laptop and am restoring it to make a new
typing machine for family :-)
Cheers.
PS: I posted it here but I guess it's mostly OT for the group,
so if you want to discuss it further, use the email
(see extended header X-LaBrea)
$ cat patch.rm-old-kernels
*** rm-old-kernels 2006-06-09 18:45:58.000000000 +0200
--- rm-old-kernels.new 2006-06-11 11:33:11.000000000 +0200
***************
*** 57 ****
! # display and count unused kernel verisons
--- 57 ----
! # display and count unused kernel versions
***************
*** 71 ****
! if [ "$reply" = "Y" ] || [ "$reply" = "y" ]; then
--- 71,72 ----
! case $reply in
! Y|y|O|o|J|j|S|s)
***************
*** 75 ****
! fi
--- 76,78 ----
! ;;
! *) ;;
! esac;
***************
*** 97 ****
! if [ "$reply" = "Y" ] || [ "$reply" = "y" ]; then
--- 100,101 ----
! case $reply in
! Y|y|O|o|J|j|S|s)
***************
*** 101 ****
! fi
--- 105,107 ----
! ;;
! *) ;;
! esac;
>1 typo and 2 alomost cometic suggestions for easier reading
>and maintaining of a ouija test.
Okay, added:
Y|y|O|o|J|j|S|s) # a dash o' l0k1 ;)
Ouija I see, what's 's'?
> I `think (TM)' that I'd have some more to suggest in the
>regexps parts (some of my vm Sysmap variants seems to escape
>this shot) but I'm a bit busy at the time (I bought a spare
>HD for the dying laptop and am restoring it to make a new
>typing machine for family :-)
Sure... I've been putting off automating stale kernel file
deletion for years, it's a pain to get right and I have deleted
/boot/* by accident a couple times -- 'rm -f *-something *'
looking for another version to add and hit the go button, oops :(
I'm used to unified diffs, dunno what to do with these other
forms.
Do you also allow for the 2.6 (vmlinuz-generic-*) kernel:
> -rw-r--r-- 1 root root 1492552 2005-09-04 06:15:04 boot/vmlinuz-generic-2.6.13
> -rw-r--r-- 1 root root 1256566 2005-06-06 05:37:36 boot/vmlinuz-ide-2.4.31
(from my standard Slackware 10.20 installed system at home)?
And what about the respective sources in /usr/src/linux-`uname -r`?
--
********************************************************************
** Eef Hartman, Delft University of Technology, dept. EWI/TW **
** e-mail: E.J.M....@math.tudelft.nl, fax: +31-15-278 7295 **
** snail-mail: P.O. Box 5031, 2600 GA Delft, The Netherlands **
********************************************************************