Charles Steinkuehler wrote: > James Colannino wrote: > >> I live in another part of the United States and so I wouldn't have >> been able to be there, but I have a couple questions about the kernel >> that I have been itching to figure out and was wondering if anyone >> could help enlighten me :) >> >> First, how exactly does the kernel uncompress itself? > > > It's magic! > >> Are there a few lines of code at the beginning of the binary that >> instruct the computer on how to uncompress the rest? > > > Yes, it's very much like the way a boot-loader works. A tiny section > of code is responsible for extrating (or loading) the rest of the > kernel (or boot-loader). How many "levels" of this happen can change, > depending on the system complexity. For example, in a typical x86 > based PC, you have the following general boot sequence: > > - BIOS performs POST, loads and runs the MBR > - MBR code (all 256 bytes!) loads the initial boot-loader (typically > K-Bytes of code (several sectors at fixed location on the disk), but > not the entire boot-loader) > - The initial boot-loader loads the rest of the boot-loader > - The boot loader determines which kernel and initial ramdisk to load, > and which options (if any) to pass to the kernel > - The kernel and initial ramdisk are loaded into memory > - The boot-loader starts running the kernel > - The kernel decompresses itself, and begins general "housekeeping" > (initializing buses, configuring the interrupt controler(s), etc) > - If an initial ramdisk was provided, the kernel optionally > decompresses it (if compressed) and tries to mount it and run /linuxrc > - The final root filesystem is mounted, and the kernel runs init. > Well, I stand corrected here. :) > > Gzip does the compression (see the gzip -f -9 line below). > > Binutils, including ld (the linker) and objcopy are used along with > some custom tools (arch/i386/boot/tools/build) to turn the raw kernel > image (vmlinux) into a bootable bzImage. > I'm almost completely positive that BZip2 is used if your make target is bzImage. Doesn't make target "install" create a gzip image? -- Jason Clinton I don't believe in witty sigs.