Now you need a bootloader. The /boot/grub/menu.lst on the image
needs to be set up (presumably you did this in step 1). You'll need at
least grub 0.95 as explained in this
thread
% ./grub-0.95/grub/grub --no-floppy
grub> device (hd0) c.img
grub> geometry (hd0) 3047 16 63
drive 0x80: C/H/S = 3047/16/63, The number of sectors = 3071376, c.img
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 22 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+22 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"..
. succeeded
Done.
Make sure grub on the image is also 0.95. Also there may be problems
if you try to use the graphical bootloader, so make sure you have the
text-based one selected on the image's /boot/grub/menu.lst.
Offsets and loopback mounting
To determine the correct offset for mounting your disk image, do:
/sbin/sfdisk debian-3.0r0.img
You'll get a chart like:
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
debian-3.0r0.img1 0+ 260 261- 131512+ 82 Linux swap
debian-3.0r0.img2 261 1023 763 384552 83 Linux
Take the starting cylinder that you care about (261). sfdisk is using
cylinders of 516096 bytes, so the offset is 261*516096 = 134701056. Or,
use fdisk (with -u) instead:
/sbin/fdisk -l -u c.img
In this case
Disk c.img: 0 heads, 0 sectors, 0 cylinders
Units = sectors of 1 * 512 bytes
Device Boot Start End Blocks Id System
c.img1 63 1596671 798304+ 83 Linux
And we take 63 * 512 = 32256.