Howto on installing Ubuntu on qemu

Jan Morén jan.moren at lucs.lu.se
Fri Sep 17 12:54:58 UTC 2004


A short and incomplete Howto on installing ubuntu on the qemu hardware
emulator. if you find errors or omissions, please let me know and I'll
fix it.






-- 
Trust the Computer. The Computer is your friend.
 
Tel. (Japan) 090-3622 8920            Dr. Jan Morén (mr)
                                      Dept. of Cognitive Science
http://lucs.lu.se/people/jan.moren    Lund, Sweden
-------------- next part --------------
Installing Ubuntu on the Qemu emulator

qemu (http://fabrice.bellard.free.fr/qemu/) is a hardware emulator,
capable of full emulation of x86 and partial emulation of PPC, Arm
and SPARC architectures. This small document chronicles the steps
taken to get the Ubuntu preview release up and running under this
emulator.

Why would you want to? Since qemu is emulating everything, including
the cpu, it is a lot slower than the host system. You will not get
much benefit of most of your hardware either. But it is a pretty good
way of testing a distribution without having to repartition your
drive or set up new hardware.  It is also quite fun, in a geeky sort
of way. :)


1. Preparation

First, of course, you need to get and install qemu. Fortunately, this
is quite easy. For FC2 (the OS I'm currently running), there is an
apt-getable package in Dag Wieers repository. the qemu site has a
binary package as well. Unlike some other virtualization systems,
like VMware, there is no need for kernel modules or anything; it runs
just fine in userland.

Download the Ubuntu iso file - no need to actually burn it to a CD,
though.

To get networking going for your emulated system, you need to set it
up. The "linux-test" add-on tarball on the qemu site has a one-line
script to put among your network scripts; I just found it easier to
run the one-liner manually before starting the emulator:

    sudo /sbin/ifconfig eth0 172.20.0.1


We also need a virtual disk for our system. You make a disk simply by
creating a file of the size you like, something like this:

    dd of=ubuntuimage bs=1024 seek=10485760 count=0


This will create a 10Gb file to use as a disk. That is actually
overkill if you want to just try out the distribution; the whole
install takes around 1.5Gb so a file of 3-4Gb would be plenty.


2. Installation

We are ready to run the install. This is how to do it:

    qemu -hda ubuntuimage -cdrom warty-i386.iso -m 192 -boot d


We set hda to be our empty disk file, set the cdrom to actually be
the ubuntu iso file, set the amount of memory our virtual machine has
to 192Mb, and tell it to boot from the cdrom.

Now, a word of caution: giving too much memory to the virtual system
will make your real machine start swapping, which will slow things
down a lot. On the other hand, giving it too little memory will make
the virtual machine start swapping, which will slow things down as
well. Moral: have a lot of memory on your host system. I have 512Mb
and wish I had more. 

The installer should be booting at this point. I ran through the
dialogues, pretty much choosing the defaults at every turn. The
installer detected the virtual network properly and the install went
without a hitch.

Now, at the end, it tries to reboot the machine. This will fail. exit
the emulator (type "quit" in the emulator console), then rerun:

    qemu -hda ubuntuimage -cdrom warty-i386.iso -m 192


Note that we have removed the boot parameter so it will boot ubuntu
from the virtual hard drive, not from the cd.

Follow the directions from the installer and create a user. The
installer will then fetch updates and add additional packages.

This takes a long time.

At one point, it will register all documentation for the help system
(including generating search indexes and so on).

This will take an inordinate amount of time.

In fact, for me, this step took well over an hour. So don't worry,
the install has not gone wrong. Relax, have a coffee, surf the web.
It will get there.

X setup is very easy; the only question is what video modes to
support. Leave this at the defaults; the virtual video hardware does
not support higher resolutions than those already set.

3. Usage


First of all, running an OS on emulated hardware is not screamingly,
insanely fast. Don't expect to run anything demanding on this system,
other than for testing purposes. My machine is a 1.7Ghz Pentium
Mobile, and Ubuntu is running - or strolling - rather sedately. 

That said, even on this fairly underpowered hardware, it is certainly
fast enough to test the distribution, perhaps install some packages,
see how it all fits together.

This is also a good tool for paranoid system management. qemu can
have a read-only disk image with a separate write-back file, so one
use would be to test installation of intrusive packages (or test your
own packages to make sure they don't break the system) without
actually touching your real system.  And if it turns out it breaks
the system, just remove the write-back file and it never happened.
p


More information about the ubuntu-users mailing list