Creating a bootable qemu image from a root filesystem and bootloader
Create a hard disk image
qemu-img create -f qcow <imagename.img> <size>GUse a live CD (better to have a lighter OS like system rescue CD to make the process faster) and the image created to boot.
qemu -cdrom /dev/cdrom -hda <imagename.img> -boot dOnce system is booted use a partition editing tool (like fdisk, cfdisk, parted, gparted, qtparted ...) to partition the image.
cfdiskcreate the necessary partitions (root and swap partitions boot, home ... if required)
Create a file syatem for the root partiotion
mke2fs /dev/hda1Mount the partition
mkdir disk mount /dev/hda1 diskCopy the file system from the host machine to the mounted directory (use a compressed file system to make the copying faster)
Grab the GNU spapshot from ams' site http://www.update.uu.se/~ams/home/slask/GNU/
scp <user>@<host>:<path to the compressed file system> diskUncompress the files
cd disk tar -jxvf <compressed filesystem>Unmount the mounted partition
cd .. umount diskpower off the guest OS.
poweroffTo make the file syatem bootable download a grub floppy image
<http://hurd.in/pub/Hurd/HurdOnVMware/grub.img>Run qemu to boot into your brand new system
qemu -hda <hard disk image.img> -fda grub.img -boot a
Happy Hacking !!
Make your new system boot from the hard disk
Mount your grub image
mkdir floppy mount -t ext2 -o loop grub.img floppyUse previous steps 2 and 5 to boot from a liveCD and mount the partition
cd disk/boot scp -r <user>@<host>:<path to mounted floppy image directory>/boot/grubPoweroff the guest
poweroffBoot new system using floppy image previous step 11
use install to hard disk option if you used the above grub image
or go to grub command line and type
root (hd0,0) setup (hd0)Now you have a bootable system image. Enjoy Maadi !!
