[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debian kernel: what to do with everything



Cheryl Homiak wrote:
> Having compiled my own kernel from a kernel downloaded from ftp.kernel.org 
> or a mirror thereof for years, last night I finally got brave and 
> installed a kernel from DEBIAN sources.

Many people would say the reverse.  That running the distro kernel is
the safe thing and compiling their own from kernel.org the scary thing.

> this was due in large part to the simple and straightforward howto
> at www.desktop-linux.net/debkernel.htm.

Thanks for providing that pointer.  I skimmed it and it looks like a
useful resource.  Unfortunately I disagree with several of the
suggestions there.  Here is a more detailed reference.  I also don't
agree with everything there.  But I disagree with less things. :-)

  http://newbiedoc.sourceforge.net/system/kernel-pkg.html

> But now I am a bit confused as to what to do with all that this
> compilation has left in /usr/src. For each kernel there's the kernel
> source tree, the kernel headers, a .deb for docs, a .deb for
> changes, a .deb for "all", and of course a .deb for the image!!! So
> what does one remove and what does one keep?

So many questions.  This is rather like going into a wood working shop
and asking the craftsman why they keep their scraps?  Or to another
why they throw them away.  To the wood worker those scraps from one
project become useful parts of future projects.  Sometimes only for
jigs and other things.  Sometimes for entire projects themselves.
Sometimes they are too small to be useful and the shop must be cleaned
out.  Everything is relative.

The answer is that you keep what you want to keep and you delete what
you want to delete.

> Does one keep a kernel source tree for each kernel

I frequently do.  I might want to come back later and compile it again
with different options.  So sometimes I will keep the kernel source
primed and ready to go.  I am using the 'madwifi' driver and sometimes
I will need to update from CVS and make modifications, for example.

Or I may decide I never need to go back to that kernel again.  So I
delete it.  I will never be booting that 2.4.17 kernel I built ages
ago.  Out in the bit bucket it goes.  I also remove old kernels from
/boot, with the proper package removal commands, to free up the
installed disk space.  I only have 21 kernels installed in my laptop
at the moment.  Time to clean.  But my desktop has only two kernels
installed on it.  It all depends upon what you are doing with your
machine.

> and switch the /usr/src/linux link accordingly,

Excuse me but what is that?  I don't have one of those on my machine.
Okay, I do know what you are talking about but am trying to impress
upon you that type of thinking is wrong thinking.  Really you don't
need the /usr/src/linux symlink.  That is a hold over from the bad old
days.  How can you keep two versions of the kernel in a rebuildable
state at the same time on the same machine while using a single
symlink to point to only one of them?  The answer is that you cannot.
So don't try.  Just build the kernel in its own directory.  Don't try
to do anything like symlink to it.  Everything works fine.

Every so often you run into an add-on piece of software, usually a
script or something, that wants something like /usr/src/linux hard
coded.  That is a bug.  The best answer is to fix the bug and not to
keep working around them with the symlink.

> or is it customary to delete the source tree and link with the
> kernel headers?

I delete the source tree when I need the disk space.  As Ken Thompson
said, "The steady state of disks is full."

> and what does one do with all the .deb packages, some or most of
> which I would think you would want to keep? Could somebody please
> help me sort this out?

Well, assuming that you built the kernel deb for a reason I would say
install it.  If it works then continue to boot off of it and then
remove one of the kernels from the bottom of the list.  I always keep
the 2.4.18-bf24 kernel around for a safe fallback.  I remove one of my
old ones instead.  If it does not work then make changes, compile it
again, install it again.  Repeat until you are either happy with the
result or a newer kernel is released.  In which case switch to the new
kernel and if you never got the old one going you might as well delete
the old one.

So for a concrete example linux-2.6.5 was the first kernel that seems
to fully support ACPI on my nc4000 laptop.  Yeah!  Up until that point
the stock kernel did not report any battery.  There are a lot of acpi
patches available from places like sourceforge.  So I would need to
patch my kernel previously.  Now I am running linux-2.6.6.

I start with 'apt-get source kernel-source-2.6.6' to get the tar file.
I don't need to do that.  I could get the source from a different
machine and copy it into place.  I could get the pristine sources from
kernel.org.  It all depends on what is desired.  I wanted the Debian
cramfs patches already applied.  So I used the Debian kernel.  This
operation leaves me with the following file.

  /usr/src/kernel-source-2.6.6.tar.bz2

I unpack it.  Now I have a directory.

  /usr/src/kernel-source-2.6.6/

I build the kernel source.  Now I have at least one deb.  I usually
build the headers too.  I don't usually need them.  But some people
like to play with vmware or other things that need to compile against
the kernel headers.  If I build them now I have them for later.

  /usr/src/kernel-headers-2.6.6-2+1-686_1.1_i386.deb
  /usr/src/kernel-image-2.6.6-2+1-686_1.1_i386.deb

Install at least the kernel image.  Whether I install the headers
depends on if I think I will need them.  I can always install it later
if I run into a case that wants it.

Now I decide I want the disk space back.  Then I delete the source
when I need to free up the disk space.  But mostly I leave it around
until I really need the disk space.  I might come back and hack on the
code for swsusp (software suspend) and will want to compile it again
and again.

  rm -rf /usr/src/kernel-source-2.6.6

When I decide I no longer want that particular kernel installed and I
don't want the disk space used in /usr/src I clean up everything.
After switching to the 2.6.6 kernel I really did not need the 2.6.5
kernel any more.

  dpkg --purge kernel-image-2.6.5-2+1-686
  dpkg --purge kernel-source-2.6.5
  rm -rf /usr/src/kernel-*-2.6.5*

This is a time for me to plug grub.  I can keep many kernels in a
bootable state all at the same time.  The list is dynamically
generated for grub by a script every time I install or uninstall a
kernel.  So I am not limited to only the ones listed in lilo.conf,
usually Linux and LinuxOLD.  Being able to have multiple kernels
dynamically assigned is really nice when you are actively hacking on
kernel parts.

Bob

Attachment: pgpsKErovb2q8.pgp
Description: PGP signature


Reply to: