Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1329524 > unrolled thread
| Started by | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| First post | 2016-02-08 21:20 +0100 |
| Last post | 2016-02-10 23:00 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
kernel pruning script.. Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-08 21:20 +0100
Re: kernel pruning script.. "J. Bruce Fields" <bfields@fieldses.org> - 2016-02-08 21:30 +0100
Re: kernel pruning script.. David Rientjes <rientjes@google.com> - 2016-02-10 22:10 +0100
Re: kernel pruning script.. Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-10 23:00 +0100
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2016-02-08 21:20 +0100 |
| Subject | kernel pruning script.. |
| Message-ID | <r00rU-1Mq-13@gated-at.bofh.it> |
I'm replying to a really old email, because I - once again - installed
this silly script that you wrote several years ago on a new machine.
So Bruce - how about we add this script to the kernel "tools"
directory, because it's actually very useful for anybody who uses
CONFIG_LOCALVERSION_AUTO like I do (and clearly you at least used to
do too).
I think CONFIG_LOCALVERSION_AUTO is really nice for various reasons
(not the least of which is just doing thing like
gitk $(uname -r)..
but also because it makes it easy to go back to previous kernels when
you're working on bisecting stuff etc).
I'll happily commit it as "tools/prune-kernel" or similar, but would
like to get an ok from you as the original author.
And if somebody has improvements for specific distros, maybe the
script will start getting improvements. And I won't have to copy it
from an old machine every time, because it will just be there with the
kernel source tree (and without a kernel source tree it's not needed).
Linus
On Wed, Jul 10, 2013 at 1:54 PM, J. Bruce Fields <bfields@fieldses.org> wrote:
>
> I run this by hand every now and then. I'm probably doing it all wrong.
>
> --b.
>
> #!/bin/bash
>
> # because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
> # again, /boot and /lib/modules/ eventually fill up.
> # Dumb script to purge that stuff:
>
> ssh "root@$1" '
>
> for f in $(ls /lib/modules); do
> if rpm -qf "/lib/modules/$f" >/dev/null; then
> echo "keeping $f (installed from rpm)"
> elif [ $(uname -r) = "$f" ]; then
> echo "keeping $f (running kernel) "
> else
> echo "removing $f"
> rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
> rm -f "/boot/vmlinuz-$f" "/boot/config-$f"
> rm -rf "/lib/modules/$f"
> new-kernel-pkg --remove $f
> fi
> done
> '
[toc] | [next] | [standalone]
| From | "J. Bruce Fields" <bfields@fieldses.org> |
|---|---|
| Date | 2016-02-08 21:30 +0100 |
| Message-ID | <r00BB-1PS-19@gated-at.bofh.it> |
| In reply to | #1329524 |
On Mon, Feb 08, 2016 at 12:14:23PM -0800, Linus Torvalds wrote: > I'm replying to a really old email, because I - once again - installed > this silly script that you wrote several years ago on a new machine. > > So Bruce - how about we add this script to the kernel "tools" > directory, because it's actually very useful for anybody who uses > CONFIG_LOCALVERSION_AUTO like I do (and clearly you at least used to > do too). > > I think CONFIG_LOCALVERSION_AUTO is really nice for various reasons > (not the least of which is just doing thing like > > gitk $(uname -r).. > but also because it makes it easy to go back to previous kernels when > you're working on bisecting stuff etc). Yes, I'm a fan. My test scripts check uname after boot to make sure they're testing the kernel they built. > I'll happily commit it as "tools/prune-kernel" or similar, but would > like to get an ok from you as the original author. Oh, feel free, thanks. --b. > And if somebody has improvements for specific distros, maybe the > script will start getting improvements. And I won't have to copy it > from an old machine every time, because it will just be there with the > kernel source tree (and without a kernel source tree it's not needed). > > Linus > > On Wed, Jul 10, 2013 at 1:54 PM, J. Bruce Fields <bfields@fieldses.org> wrote: > > > > I run this by hand every now and then. I'm probably doing it all wrong. > > > > --b. > > > > #!/bin/bash > > > > # because I use CONFIG_LOCALVERSION_AUTO, not the same version again and > > # again, /boot and /lib/modules/ eventually fill up. > > # Dumb script to purge that stuff: > > > > ssh "root@$1" ' > > > > for f in $(ls /lib/modules); do > > if rpm -qf "/lib/modules/$f" >/dev/null; then > > echo "keeping $f (installed from rpm)" > > elif [ $(uname -r) = "$f" ]; then > > echo "keeping $f (running kernel) " > > else > > echo "removing $f" > > rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f" > > rm -f "/boot/vmlinuz-$f" "/boot/config-$f" > > rm -rf "/lib/modules/$f" > > new-kernel-pkg --remove $f > > fi > > done > > '
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2016-02-10 22:10 +0100 |
| Message-ID | <r0Kbo-7zi-9@gated-at.bofh.it> |
| In reply to | #1329524 |
On Mon, 8 Feb 2016, Linus Torvalds wrote: > > I run this by hand every now and then. I'm probably doing it all wrong. > > > > --b. > > > > #!/bin/bash > > > > # because I use CONFIG_LOCALVERSION_AUTO, not the same version again and > > # again, /boot and /lib/modules/ eventually fill up. > > # Dumb script to purge that stuff: > > > > ssh "root@$1" ' > > > > for f in $(ls /lib/modules); do > > if rpm -qf "/lib/modules/$f" >/dev/null; then > > echo "keeping $f (installed from rpm)" > > elif [ $(uname -r) = "$f" ]; then > > echo "keeping $f (running kernel) " > > else > > echo "removing $f" > > rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f" > > rm -f "/boot/vmlinuz-$f" "/boot/config-$f" > > rm -rf "/lib/modules/$f" > > new-kernel-pkg --remove $f > > fi > > done > > ' I do something similar to this on a regular basis as well, but I also rm -rf /lib/firmware/$f
[toc] | [prev] | [next] | [standalone]
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2016-02-10 23:00 +0100 |
| Message-ID | <r0KXM-7U9-9@gated-at.bofh.it> |
| In reply to | #1331487 |
On Wed, Feb 10, 2016 at 1:05 PM, David Rientjes <rientjes@google.com> wrote:
>> > for f in $(ls /lib/modules); do
>> > if rpm -qf "/lib/modules/$f" >/dev/null; then
>> > echo "keeping $f (installed from rpm)"
>> > elif [ $(uname -r) = "$f" ]; then
>> > echo "keeping $f (running kernel) "
>> > else
>> > echo "removing $f"
>> > rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
>> > rm -f "/boot/vmlinuz-$f" "/boot/config-$f"
>> > rm -rf "/lib/modules/$f"
>> > new-kernel-pkg --remove $f
>> > fi
>> > done
>> > '
>
> I do something similar to this on a regular basis as well, but I also rm
> -rf /lib/firmware/$f
So I don't think most people do that. I know I don't. I think it comes
into play mainly if you do the packaged kernel thing (ie the
"builddeb" rule or the rpmbuild), and in that case you should never
remove the files manually anyway.
The normal firmware_install just puts things into /lib/firmware,
because the firmware files are supposed to be versioned on their own,
not by kernel version.
So I don't think that's a thing we want to add in general. However, I
*would* want to add sanity checks for deb-based things, right now we
just have that
if rpm -qf "/lib/modules/$f" >/dev/null; then
echo "keeping $f (installed from rpm)"
and we'd need something similar for a debian package.
Also note that what I have actually been using - and what I committed
- wasn't really the quoted original script from Bruce. I end up
pruning individual kernels by name (rather than pruning everything in
/lib/modules).
Finally, note that I removed the "ssh root@$1" model that Bruce had -
his script really makes more sense in his situation where he does this
to his target test machines, but I don't think that's the proper model
for a script like this in the general case.
So to get the behavior that Bruce's script had, you'd actually do
ssh root@target 'cd /lib/modules && prune-kernel *'
with the thing I committed.
So the script that is committed (it's in current -git as
"scripts/prune-kernel") is slightly different from this emailed
thread, but I'd be more than happy to take patches for it. I've used
my edited version for a long while (pretty much since Bruce posted
it), but it's a complete hack. I think it started out as a hack, and I
hacked it up (or down, depending on your situation) some more, and
while the largest reason for me to commit it was just to not have to
look it up every time I do a new machine install, I'm also hoping that
now that it's in the kernel tree, maybe people will say ".. but I'm
running Ubuntu, and that rpm test does nothing for me, so it should
add a line to do X".
But I still think that your firmware thing implies that you're using a
packaged kernel, and that you shouldn't be removing subdirectories by
hand.
Linus
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web