woensdag 31 oktober 2007

Installing Debian 4.0r (amd64) on KVM (KQEMU)

First you create a image to install debian on:
qemu-img create -f qcow debian.img 5G

The -f option tells what the format of this image is.
vmdk is for VMware compatible images.
raw does create the image and allocates the whole size immediately.

The qcow advantages:
  1. qcow does only allocates the size that is used. So if you create an image of 5GB (like above) and install a 200MB distro on it, the file will only be 200MB
  2. Snapshot support, where the image only represents changes made to an underlying disk image
  3. Optional zlib based compression
  4. Optional AES encryption
Source: http://www.gnome.org/~markmc/qcow-image-format.html

So I use qcow.
If you want to see image information use:
qemu-img info debian.img

Now we can start the virtual machine:
/usr/bin/qemu-system-x86_64 -hda cluster-node.img -cdrom /dev/cdrom -m 348 -localtime -boot d -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,macaddr=00:18:8B:D9:41:2F,script=/mnt/vm/qemu-ifup

Note the "-boot d" which selects that I want to boot from the cdrom-drive that is defined by "-cdrom /dev/cdrom".
The -net part does has to do with network bridging and it depends on what networking you want for your VM.

I can boot into the net-install disk just fine.
But after selecting my language and keyboard layout Qemu crashes with an "unknown return code":(.
This will probably a bug, so lets try to install without kqemu support (KVM) and see after installation if all goes fine:
/usr/bin/qemu-system-x86_64 -hda cluster-node.img -cdrom /dev/cdrom -m 348 -localtime -boot d -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,macaddr=00:18:8B:D9:41:2F,script=/mnt/vm/qemu-ifup -no-kqemu

Now the installation goes fine... UNTIL installing GRUB (the bootloader).
grub-install just hangs there (retried it and let it wait for like half an hour).
Eventually I killed the processes and tried it manually:
grub-install /dev/hda

This gives following error:
/dev/sda does not have any corresponding BIOS drive

So first I tried this to rebuild the devices.map file:
grub-install --recheck /dev/hda

Didn't help, let's try it the ultra-manual way :p (the way I love it the most). Run grub and then:
install (hd0,0)/grub/stage1 (hd0) (hd0,0)/grub/stage2 p (hd0,0)/grub/menu.lst

Same problem :(

Now I looked what the mounts were, and /boot was not the hard drive partition.
So I mounted the /boot partition on my hard disk to /boot:
NOTE: Boot with a linux rescue cd and mount the hard drive... the install environment is clumsy because it is so limited.
mkdir /mnt/tmpboot
mount /dev/hda1 /mnt/tmpboot
mount -o bind /boot /mnt/tmpboot
grub-install /dev/hda

This went smoothly.


After installation I started the VM (same command as above but without "-boot d") and that went fine.
But when removing the -no-kqemu I it did crash again.


TODO:
  1. Try with kqemu on my arch-linux system (maybe the bug does not exist there)
  2. If the first does not solve it, try another boot cd
  3. Try with i386 boot cd instead of amd64

Geen opmerkingen: