BUILD KERNEL AND BOOT TO OWN APPLICATION ======================================== Manuel Traut retrive kernel source --------------------- normaly download it from kernel.org or use git: -------------------------------------------------------------------------------- home# git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git -------------------------------------------------------------------------------- or download it from my laptop (it's faster..) -------------------------------------------------------------------------------- home# git clone http:///linux -------------------------------------------------------------------------------- configure the kernel for your machine -------------------------------------- download the config for qemu from my webmachine -------------------------------------------------------------------------------- home# mkdir linux-qemu home# cd linux-qemu home/linux-qemu# wget http://mecka.net/hswgt/uebung1/config-qemu -O .config home/linux-qemu# cd .. -------------------------------------------------------------------------------- you can create an initial config, or modify a given config with this command -------------------------------------------------------------------------------- home# cd linux home/linux# ARCH=i386 CFLAGS=-m32 make O=../linux-qemu menuconfig -------------------------------------------------------------------------------- build the kernel ---------------- -------------------------------------------------------------------------------- home/linux# ARCH=i386 CFLAGS=-m32 make O=../linux-qemu -j5 home/linux# cd .. -------------------------------------------------------------------------------- boot the kernel with qemu ------------------------- -------------------------------------------------------------------------------- home# qemu-system-i386 -kernel linux-qemu/arch/x86/boot/bzImage \ -nographic -append "console=ttyS0,115200" -------------------------------------------------------------------------------- generated a harddisk image -------------------------- -------------------------------------------------------------------------------- home# dd if=/dev/zero of=hd.img bs=1024 count=4000 -------------------------------------------------------------------------------- format the harddisk image ------------------------- -------------------------------------------------------------------------------- home# /sbin/mkfs.ext4 hd.img -------------------------------------------------------------------------------- build your own application and link it static --------------------------------------------- -------------------------------------------------------------------------------- home# mkdir hello home# cd hello home/hello# $EDITOR hello.c home/hello# gcc -static -m32 -o hello hello.c home/hello# cd .. -------------------------------------------------------------------------------- use e2cp or loopback mount to copy your application to the image ----------------------------------------------------------------- -------------------------------------------------------------------------------- home# e2cp -P 777 hello/hello hd.img:/ -------------------------------------------------------------------------------- boot the kernel and let it start your application ------------------------------------------------- -------------------------------------------------------------------------------- home# qemu-system-i386 -kernel linux-qemu/arch/x86/boot/bzImage \ -drive file=hd.img,if=virtio \ -nographic -append "console=ttyS0,115200 root=/dev/vda init=/hello" --------------------------------------------------------------------------------