QEMU-KVM redux
Walter Dnes
waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Wed Jul 21 23:41:43 UTC 2010
OK, I'm up and running. 32-bit Gentoo guest installed with only one
hiccup, which isn't Gentoo-specific, but applies to linux in general.
While the default QEMU-KVM boot provides /dev/hda, /dev/hdb, etc, to the
install CD boot, an installed linux kernel will boot and see /dev/sda,
/dev/sdb, etc. In a you-can't-get-from-here-to-to-there chicken-and-egg
scenario, you can't write lilo to a /dev/sda that doesn't exist. Here's
how I worked around it.
First, I created 2 disk image files, a 10-gig working disk, and a
2-gig swap disk...
qemu-img create -f raw g32_00_sda.img 10G
qemu-img create -f raw g32_00_sdb.img 2G
For the install only, I boot with a ridiculously long line
kvm -redir tcp:5555::22 -m 2048 -drive file=g32_00_hda.img,if=scsi,bus=0,unit=6 -drive file=g32_00_hdb.img,if=scsi,bus=1,unit=6 -cdrom gentoo32.iso -boot d
Let's look at the parameters one-by-one...
-redir tcp:5555::22
redirect host port 5555 to guest port 22. The Gentoo minimal install
cd allows you to set a root password, and start an ssh server. This
allows you to finish the install from host. From the host, I can do
stuff like...
ssh -p 5555 root at localhost
scp -P 5555 foobar root at localhost:.
-m 2048
allocate 2048 megabytes (2 gigs) of ram to the virtual machine
-drive file=g32_00_hda.img,if=scsi,bus=0,unit=6
treat file g32_00_hda.img as a scsi drive on bus 0, unit 6 i.e. /dev/sda
-drive file=g32_00_hdb.img,if=scsi,bus=1,unit=6
treat file g32_00_hdb.img as a scsi drive on bus 1, unit 6 i.e. /dev/sdb
-cdrom gentoo32.iso
treat file gentoo32.iso as a cdrom, i.e. /dev/hdc
-boot d
boot from the CD. For those of us old enough to remember DOS, the
boot codes actually make sense...
a ==> boot from floppy image (like A:)
c ==> boot from drive image (like C:)
d ==> boot from cdrom image (like D:)
n ==> boot from network
From here, I do a normal install. The IP address comes from dhcp, and
I install lilo to boot from /dev/sda1. Note that the boot command for
the installed linux is different. KVM doesn't seem to want to boot from
file=g32_00_hda.img,if=scsi,bus=0,unit=6 So I go back to...
kvm -localtime -startdate now -vga std -redir tcp:5555::22 -m 2048 -hda g32_00_hda.img -hdb g32_00_hdb.img -boot c
The differences here are...
-localtime
force virtual machine to local time, rather than
-startdate now
initialize guest date/time to host's date/time
-vga std
note the new syntax, Other options are "-vga cirrus" and "-vga vesa".
"-vga std" gives faster video redraws. To get the highest resolution
in the guest's X...
* "X -configure" as root to generate an xorg.conf.
* copy horizontal and vertical sync ranges from the host's xorg.conf
to the guest's xorg.conf. If necessary, search Google for your
monitor's specs. This allows me to go fullscreen 1920x1200 in the
guest. I find that clumsy, so I throttled it down to only 1680x1050.
-hda g32_00_hda.img -hdb g32_00_hdb.img
"-drive file=g32_00_hda.img,if=scsi,bus=0,unit=6" doesn't work as a
boot drive, so I drop back to the simpler syntax. Note that the
drives come up as /dev/sda and /dev/sdb. Don't be confused by the
-hda and -hdb notation
-boot c
boot from a hard drive, versus the cdrom from the install stage
One thing I noticed is that going from 1 cpu in the guest to 2 cpus
really slows down the guest. I don't understand, since the host has 4
cores.
--
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org>
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list