README.diskimage 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Sample for i386 to create a 6MB disk-image
  2. # create an image file
  3. dd if=/dev/zero bs=512 count=$((6*1024*1024/512)) of=img
  4. # create a partition (optional)
  5. echo -e "n\np\n1\n\nw\n" | \
  6. ~/src/busybox/busybox fdisk -C 16065 -H 255 -S 63 ./img
  7. # as root, associate the image with a look-device:
  8. # The offset of 512 comes from the the layout of the image. See
  9. # ~/src/busybox/busybox fdisk -C 16065 -H 255 -S 63 -l ./img for the start
  10. # block and multiply this with the block size (==512).
  11. ~/src/busybox/busybox losetup -o 512 /dev/loop/0 /path/to/the/img
  12. # create some filesystem on it, for example ext2
  13. mkfs.ext2 -m0 -Lslash /dev/loop/0
  14. # mount it and copy your stuff to it
  15. ~/src/busybox/busybox mount -oloop,rw /dev/loop/0 /media/l0
  16. ~/src/busybox/busybox mkdir -p /media/l0/boot/grub
  17. ~/src/busybox/busybox cp -a project_build_i386/root/boot/grub/stage? /media/l0/boot/grub/
  18. ~/src/busybox/busybox cp -a project_build_i386/root/boot/bzImage /media/l0/boot/
  19. ~/src/busybox/busybox cat > /media/l0/boot/grub/menu.lst <<EOF
  20. title=GNU/Linux
  21. root (hd0,0)
  22. kernel /boot/bzImage
  23. EOF
  24. # finally unmount the dist and disassociate the loopdev
  25. ~/src/busybox/busybox umount /media/l0
  26. ~/src/busybox/busybox losetup -d /dev/loop/0
  27. # now install grub from the chroot
  28. ~/src/busybox/busybox losetup /dev/loop/0 /path/to/the/img
  29. project_build_i386/root/usr/sbin/grub --device-map=/dev/null
  30. device (hd0) img
  31. geometry (hd0) 16065 255 63
  32. root (hd0,0)
  33. setup (hd0)
  34. quit
  35. # finally boot the thing
  36. /opt/qemu-trunk_ggi-2.2.2/bin/qemu -snapshot -hda img -boot c