Today I've been researching on Linux and Debian booting.
There is an excellent article from IBM, which explains the procedure, and the involved parts:
http://www.ibm.com/developerworks/linux/library/l-linuxboot/
Basically:
- BIOS checks CMOS and choose the booting device Control is given to device's MBR (physically first 512 bytes) MBR checks for partitions on the device (in a self contained table), and gives control to bootable partition. Then, Grub, LILO or whatever takes control, to load the kernel, and the file system. Usually a [initrd](http://en.wikipedia.org/wiki/Initrd) filesystem is loaded before the "real" one. This way, the kernel can access this filesystem, while the modules for loading the one in the root partition are not yet loaded. Finally, init program is called, to load all [user-space](http://en.wikipedia.org/wiki/User_space) applications.
To set this up in a USB drive (my idea), in a simple way, we need:
Make the drive bootable, using the [syslinux](http://en.wikipedia.org/wiki/Syslinux) tool, which is used for FAT filesystems:
syslinux /dev/sdb (or whatever device you want)
Then, mount the filesystem, and copy:
linux: the linux kernel binary
initrd.gz: compressed cpio file containing the initrd file tree
and
syslinux.cfg: syslinux settings, to let syslinux know where to find the kernel and the initrd. Basically:
default linux
append initrd=initrd.gz
Then, just restart, and your device will boot your kernel, and your filesystem.
Here, you can find a Linux kernel, and a initrd file, which will load a basic linux system, running the Debian installer:
[http://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/netboot/debian-installer/i386/](http://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/netboot/debian-installer/i386/)
Some more info on it at:
[http://www.debian.org/releases/stable/i386/ch04s03.html.en](http://www.debian.org/releases/stable/i386/ch04s03.html.en)