Qemu running the oralux live CD in debian sarge

From LQWiki
Jump to: navigation, search

Installation of qemu from source

System: Debian sarge

alias definitions:

alias g='egrep -i -r'
alias ll='ls -l --color=tty'

Note: To execute the commands properly, log in as root.

Get the softWare

Get the package from http://bellard.org/qemu/:

cd /usr/src
wget http://fabrice.bellard.free.fr/qemu/qemu-0.8.2.tar.gz
tar -xzf qemu-0.8.2.tar.gz

You will also need to get the dependencies for building:

apt-get build-dep qemu

According to http://www.kidsquid.com/cgi-bin/moin.cgi/FrequentlyAskedQuestions, the code needs to be compiled with a gcc of a smaller version than 4.0. So,

apt-get install gcc-3.4
dpkg -l | g gcc-3.4
ii  gcc-3.4                           3.4.3-13sarge1                    The GNU C compiler
ii  gcc-3.4-base                      3.4.3-13sarge1                    The GNU Compiler Collection (base package)

I compiled the kernel with gcc-3.4 :

modinfo /lib/modules/2.6.18-am2nf3/kernel/drivers/char/lp.ko | g vermagic
vermagic:       2.6.18-am2nf3 preempt mod_unload K8 gcc-3.4
If your kernel was compiled with gcc-3.3 just replace "gcc-3.4" with "gcc-3.3" in the next ./configure command line options.
If you don't want to recompile your kernel, just do a ./configure without arguments. I didn't test it but this is the usual way to do things anyway.
If you have already made some compilation, let's clean (obviously not needed if you just decompressed the archive) 
cd /usr/src/qemu-0.8.2
make clean

./configure --cc=gcc-3.4 --host-cc=gcc-3.4 && make && make install

Note: At the moment the --host-cc option seems to only apply to the compilation of the program dyngen which is used to generate some '.h' files during compilation so i guess the --cc option could be sufficient but it shouldn't hurt to use the same gcc for everything anyway.

QEMU Accelerator : KQEMU

Get the package from http://fabrice.bellard.free.fr/qemu/download.html 
cd /usr/src
wget http://fabrice.bellard.free.fr/qemu/kqemu-1.3.0pre9.tar.gz
tar -xzf kqemu-1.3.0pre9.tar.gz
cd /usr/src/kqemu-1.3.0pre9

make clean
./configure --cc=gcc-3.4 --host-cc=gcc-3.4 && make && make install

modinfo $(modprobe --list | g kqemu)
filename:       /lib/modules/2.6.18-am2nf3/misc/kqemu.ko
license:        Proprietary
vermagic:       2.6.18-am2nf3 preempt mod_unload K8 gcc-3.4
depends:
parm:           major:int
mknod /dev/kqemu c 250 0
chmod 666 $device
ll /dev/kqemu
crw-rw-rw-  1 root root 250, 0 Dec 26 13:56 /dev/kqemu
If you use udev like me and reboot right now, there won't be any /dev/kqemu anymore even if you insert the kqemu module (modprobe kqemu).

Let's configure the system so that the kqemu module is loaded with the "major=0" option :

echo "options kqemu major=0" > /etc/modprobe.d/my_kqemu

Let's remove /dev/kqemu to see how it is recreated.

rm /dev/kqemu
modprobe kqemu
ll /dev/kqemu
crw-rw----  1 root root 10, 62 Dec 26 14:00 /dev/kqemu

tail -n 2 /var/log/syslog
Dec 26 14:00:00 sarge kernel: KQEMU installed, max_locked_mem=518060kB.
Dec 26 14:00:03 sarge udev[14105]: creating device node '/dev/kqemu'

The "major=0" module option provided to kqemu has had at least two noticeable effects :

  • The /dev/kqemu device file is autocreated by udev on insertion of kqemu.
  • There is now an automatic major/minor numbers allocation of /dev/kqemu going on.

We need to be able to access /dev/kqemu as a normal user :

echo 'KERNEL="kqemu",		MODE="0666", GROUP="root"' > /etc/udev/rules.d/my_kqemu.rules

Let's udev know about the configuration modification :

/etc/init.d/udev restart
ll /dev/kqemu
crw-rw-rw-  1 root root 10, 62 Dec 26 14:00 /dev/kqemu

If you want to increase the amount of memory on your virtual machine and have enough memory/swap on your host OS, then you may need to extend the maximum size limit of the standard virtual memory filesystem [1] mounted on /dev/shm :

mount -t tmpfs -o remount,size=528m none /dev/shm

Let's give Qemu what it asks for :

echo 1024 > /proc/sys/dev/rtc/max-user-freq

Example : qemu running the oralux live cd

Quote: "Oralux hopes to facilitate access to GNU/Linux for the visually impaired."

Where to get the oralux iso : http://oralux.org/download.php

How to boot the live CD :

qemu -m 512 -kernel-kqemu -cdrom /usr/src/Oralux_0.7_alpha.iso -boot d -soundhw es1370 &

At the boot prompt, enter the following line :

knoppix apic=off clock=pit

The "clock=pit" boot option is recommanded for kernel 2.6 (guest) on the qemu web site. It seemed to work ok without though.

Small description of the qemu command line :

-m 512

512 Mo of RAM
Adjust to your needs/capabilities

-kernel-kqemu

Use the kemu Accelerator

-cdrom /usr/src/Oralux_0.7_alpha.iso

The live CD inserted into the virtual machine at boot time.

-boot d

Boot the vm from the CD

-soundhw es1370

A sound card simulation
You can click in the qemu window to get full keyboard emulation.
Press Ctrl-Alt to get keyboard control back in your Host OS.

See also