Using qemu under ubuntu - quickstart guide to installing a distro

Hi guys,

At the meeting I did an impromptu presentation on installing SME Server in a qemu virtual machine. Here's a quickstart guide to installing a distro under qemu.

For more complete documentation see the qemu website. SME Server is available at Contribs.org


# Install qemu from repositories
sudo apt-get install qemu


# Make a 5GB image to use as the hda hard drive
dd if=/dev/zero of=hda.img bs=1024k count=5000


# Run qemu to boot from cd and install to hard drive
# note - hda is unpartitioned space! Some installers may give out warnings
# note2 - the installer rebooting will probably fail, if installation is complete
# just proceed to the next step, otherwise quit and rerun this line (depends on
# the distro you are installing)
sudo qemu -hda hda.img -cdrom ~/some_cd_image.iso -boot d -net nic -net tap


# Boot your hd image! networking support included
sudo qemu hda.img -net nic -net tap

Notes:

  • No need to run as root if you don't require networking.
  • If you have also installed the proprietary accelerator module (available from the qemu website), do a sudo /sbin/modprobe kqemu major=0 before running qemu (as per the docs). Performance is vastly improved
  • Network ip address is likely to be 172.20.0.1 on the host. However, check to make sure the ip address is set. If not, run sudo ifconfig tap0 up 172.20.0.1 . Also keep this IP in mind when selecting an IP for the client machine
  • Other distros, don't use 'sudo', run as root or set up networking differently (see man qemu or the online docs)