====== Booting Voyage with Qemu ====== ===== Motivation ===== This way it is easy to get a working toolchain by simple apt-get it into the virtual (and huge sized) CF card. Large CF cards are expensive, the following HowTo will show how to turn a physical 256MB CF card into a virtual 1GB sized CF image file and install the compiler collection "gcc" into this virtual CF card. Files compiled in with the system from the virtual CF will also run at the real physical CF and can be copied across. The performance is slower than using chroot. ===== HowTo ===== It is possible to boot the image even without the real hardware. So far I tested it to work with a CF card for a WRAP board attached to the cardreader device /dev/sda. First create the CF card as usual and check it to work with your WRAP board (other boards should also work). Unplug the CF from your board and plug it into the cardreader (in my case /dev/sda). Then start qemu with: ''qemu -hda /dev/sda -serial stdio'', it should boot with a few error messages caused by the different hardware. * create larger image: ''dd if=/dev/zero of=image_0.2.work.img bs=1M count=1024'' * copy content from CF to image: ''dd if=/dev/sda of=image_0.2.work.img conv=notrunc'' * resize image partition (ext2 in this case) with tools present inside voyage: ''qemu -hda /dev/sda -hdc image_0.2.work.img -serial stdio'' * wait for voyage to boot from /dev/sda (ignore duplicate volume id errors) * login into voyage * ''voyage# fdisk /dev/hdc'' * delete partition by entering "d" at the fdisk command prompt (in my case only one partition at CF, so fdisk selected 1 itself) * create the partition again with the full available size: "n", "p", "1", "", "", "w" * ''voyage# e2fsck -f /dev/hdc1'', "" * ''voyage# resize2fs -f /dev/hdc1'' * ''voyage# shutdown -h now'' * Now it is possible to boot the virtual CF ''qemu -hda image_0.2.work.img -serial stdio'' * login into voyage * check size of new virtual CF: ''voyage# df -h'' * install the tools you like for compilation: ''apt-get install gcc make ...'' ===== KVM ===== It is possible to boot the image with KVM with the same way explained before. Instead of launching qemu must should be launched kvm with the same parameters. In some configurations the voyage kernel will stop with kernel panic when trying to initialize CPU APIC. To solve this is needed to add ''nolapic'' into kernel parameters. To do this when GRUB appears, press E key and move down to the line starting with kernel, then E again. As last agument add '' nolapic'' and press enter and B key. This change only affects current boot, to let this be permanent change it inside voyage on file /boot/grub/menu.lst. ===== Install directly to an image file ===== Do this to install Voyage directly to an image file for testing from Qemu first. 1. Create the image file: ''qemu-img create file.img '' 2. Create a loop device for the image file ''losetup /dev/loop0 file.img'' 3. Create a single partition in the image file ''cfdisk /dev/loop0'' 4. Create another loop device for the partion. To do this you need to provide an offset option to the losetup command. The offset is the partition starting sector * 512. Run 'fdisk -l -uS ' to get the starting sector which is usually 63 for the first partition. The offset is therefore 63 * 512 = 32256. ''losetup -o 32256 /dev/loop1 file.img'' 5. Format the partition. ''mkfs.ext2 /dev/loop1'' 6. Now install Voyage as usual using voyage.update. * Specify /dev/loop0 as the install device * Specify partition 1 * Specify partition 1 for grub 7. Release image. ''losetup -d /dev/loop0'' ''losetup -d /dev/loop1'' When you're ready to copy the image to a real device, use either of these: ''dd if= of=/dev/'' or ''qemu-image convert /dev/'' -- this section only added by Andrew Malcolmson 09/04/08