05 janvier 2006

Win2K in qemu under Ubuntu x86 5.10

Howto install Windows in Ubuntu 5.10
(based on various documents coming mainly from www.ubuntuforums.org especially a post from Fredrik Lunde from Norway
many thanks to him)


You need a Windows Install CD and the appropriate license from a Redmond company to do so.


In this little howto we will guide you through how to set up the free emulator that I have tested with win2000 professional.



Before we start:

Guest = Your Operating System installed in the emulator
Host = In this case, Ubuntu 5.10

Do this at your own risk, there are know problems with different graphic cards, refresh rate and color settings.
If you notice any flickering on the screen when you change the screen resolution on the guest OS, try to shutdown first the guest, then completely reboot the host. if still it is flickering, there are probably something wrong with your graphic drivers or settings in the Xorg file.

I did this with an Ubuntu upgraded to 5.10 with 2.6.12-10 i386 kernel and 1024 MB memory.

Please note that you preferably have some gigabites available while setting this up. I recommend taking some backups of both the guest and the host while configuring this.


Qemu (GPL) with KQemu (Free as beer but not GPL!)
Virtual Machine for every thing you dream of GNU/Linux or BSD based OS's or need Win2000 or WinXP.

Note: This is what we will go through here. I tried this with Win2000, CentOS4 and will continue to try different OS's here. It is not as fast as VMware with Win2000, but it's a very good free alternative and not so slow.



OK.. Let's start...

Step 1. RUNNING QEMU WITH WIN98
If you are just installing Win98, with the current version (qemu-0.8.0) KQemu will not work anyway, so you don't need to install it.

Win98 only, Just do:
$ apt-get install qemu
...and jump to step 2

If you deside to install Qemu with the KQemu accelerator you just need to start win98 with the extra command -no-kqemu , we will get back to this later anyway.



Step 1. RUNNING QEMU WITH KQEMU ACCELERATOR

Some of this information I ripped from: Nano Florestan at http://oui.com.br/n/content.php?article.21 a lot of the credits should go to him.

First we need to remove any previously installed Qemu and compile it with Kqemu

$ sudo apt-get remove qemu

Go to: http://fabrice.bellard.free.fr/qemu/download.html
...and download these 2 files:
1) QEMU source code (Not the binary for i386)
2) QEMU Accelerator Module

0.8.0 is the current version (5rd January 2006).

$ tar zxvf qemu-0.8.0.tar.gz

The Kqemu shall be unpacked into a subdirectory of the new qemu-0.8.0 directory

$ cd qemu-0.8.0
$ tar zxvf /location of downloaded files/kqemu-0.7.2.tar.gz

NOTE: Some people have reported permission errors during installation, the following command will correct the problem.

$ sudo chmod -R 775 /path/to/qemu-0.8.0

You now need to make sure you have some extra packets. First make sure you have the kernel headers installed by:

$ uname -r
..this will output the kernel version

Open Synaptic package manager and search for packages called "linux-headers". Several packages start with this name. Install the one that corresponds to your processor and your kernel version.

Still in Synaptic, choose the package you have just installed, click Properties and go to the "Installed Files" tab. Write down the directory where the files were copied (looks like /usr/src/linux-headers-2.6versionnumber/)

$ vi configure (or another editor e.g. gedit if you prefer GUI)

change the: kernel_path="/usr/src/linux-headers-2.6.12-10" (adapt it)

$ sudo apt-get install libsdl1.2-dev
$ sudo apt-get install zlib1g-dev


Then check that everything is correct with:

$ ./configure

If everything is correct and you recieve no errors, proceed with:

$ make

Correct output to make will go on and on and output a lot of text...

If you did'nt get any errors you are now ready to install. If you get any errors or this does'nt work at all, make sure you have a gcc compiler in your system.

By default Ubuntu is not installed with gcc so there is a high probability that you need to install it through apt or synaptic. Choose the 3.4 version of gcc not the 4.0 or superior there are some problems with qemu and 4.0 version of gcc. Also do a link between gcc and gcc-3.4 like this ln -s /usr/bin/gcc-3.4 /usr/bin/gcc

Now we are ready to install:

Note: Please check AgenT's suggestion of doing checkinstall instead of make install: http://www.ubuntuforums.org/showthre...873#post200873

$ sudo make install

If everything went ok, you can now start the qemu with the command

$ sudo modprobe kqemu

Then we need to make this start when the computer boots

$ sudo vi /etc/init.d/bootmisc.sh (or another editor...)

Add these lines to the end just before "exit;"

# Start Qemu with KQemu accelerator
/sbin/modprobe kqemu
mknod /dev/kqemu c 250 0 # Create the KQEMU device
chmod 666 /dev/kqemu # Make it accessible to all users



Step 2. MAKING A VIRITUAL DISK WITH QEMU

First create a directory for the guest OS's. This should be done as the user you will use while running the guest OS

$ cd /home/your username
$ mkdir Qemu
$ cd Qemu


Then we will create the virtual hard drive, in my case for Win2k I used 8 gigabyte for Win2000. We set the size with the (amount)M

$ qemu-img create hd.img 8000M

But there is a known bug with Win2K (only one? ;o) ) so create it rather with:

$ dd if=/dev/zero of=hd.img bs=4096 count=2000000

Otherwise you can have a not space enough place on c: error after a 2 hours installation process (High frustration level guaranted believe me especially at the third attempt in a row).

Step 3. INSTALLING THE GUEST OS

So... we now have the disk and need to install something on it..

first lets have a look at the options for booting with Qemu
-boot gives the parameter of which device to boot from.

a = floppy
d = cdrom
c = hard drive


-fda /dev/fda
will tell qemu where to find the floppy drive
-fda /path/to/your/bootdisk.img
will tell qemu to boot from a bootdisk image. You can download images from www.bootdisk.com

PS: you can download an .exe bootdisk extractor and open it with Archive Manager and extract the bootdisk image


-cdrom /dev/cdrom
will tell qemu where to find the cdrom drive.
-cdrom /path/to/your/install_cd.iso
will tell qemu to use an iso instead of your cdrom drive.


-hda /path/to/your/new/viritual/hd.img
Will tell qemu which viritual harddrive to use. you can also use secondary drive with -hdb /path/to/your/new/viritual/secondary/hd.img


So here we go... If we have a bootable install cd and just want to use the cdrom drive, this is how it goes:
$ qemu -win2k-hack boot d -cdrom /dev/cdrom -hda hd.img

If you need to start with different parameters, just modify and add to the end. If you install Win98, dont forget to add -no-kqemu at the end.

Alternatively you can first copy the cdrom on the hard disk (quicker?)
$ dd if=/dev/cdrom of=win2000.iso

Proceed to installation via:

$ qemu -win2k-hack -boot d -cdrom win2000.iso -hda hd.img


(When the installation ask you to reboot, change the -boot d flag to -boot c for the virtual hard drive) seems not to be necessary.



Step 4. STARTING THE GUEST OS

Well.. we're sort of already there, again it's mostly just to change the -boot flag

$ qemu -boot c -cdrom /dev/cdrom -hda hd.img -m 256 -k fr-be &



Description of other flags used in this startup:

-k fr-be
Keyboard layout.. works with some languages (not needed but can't be bad to specify it see qemu man for further explanations)

-m 256
Amount of memory provided the guest OS

Note: I will not go into details about networking here.. at least not yet. Internet should probably work from the guest without any modifications. To set up shared folders between the guest and the host, a tip is. Install samba, then share the folders with SMB and add the flag -smb /shared/folder to your startup command.



Step 5. PERFORMANCE TWEAKING THE GUEST OS

Before you start tweaking the guest OS.. just copy the hd.img

$ cp hd.img hd.img.backup

Now find a good performance tweek site on the net for removing all unwanted processes for your OS
Win2000: http://www.techspot.com/tweaks/win2k...es/print.shtml

EDIT: Additional information from sebdah
For you guys who wants to tweak WinXP: Check TweakXP.com, it should be everything you need!


Step 6. CREATING A LAUNCER

Now finally you may want a launcher for your new OS..
Rightclick on the panel where you want to create the launcher and choose:
(The panel is the bar at the top of your screen)

Add to Panel > Custom Application Launcher >
Name: win2000 (or something else devil2k?)
Command: qemu -boot c -cdrom /dev/cdrom -hda /path/to/your/hd.img -m 256 -k fr-be &
Choose an icon for you new OS

Note: modify the command starter after your needs.

About networking

By using the option `-net user' (default configuration if no `-net' option is specified), QEMU uses a completely user mode network stack (you don't need root priviledge to use the virtual network). The virtual network configuration is the following:

         QEMU VLAN      <------>  Firewall/DHCP server <-----> Internet
| (10.0.2.2)
|
----> DNS server (10.0.2.3)
|
----> SMB server (10.0.2.4)

The QEMU VM behaves as if it was behind a firewall which blocks all incoming connections. You can use a DHCP client to automatically configure the network in the QEMU VM. The DHCP server assign addresses to the hosts starting from 10.0.2.15.

In order to check that the user mode network is working, you can ping the address 10.0.2.2 and verify that you got an address in the range 10.0.2.x from the QEMU virtual DHCP server.

Note that ping is not supported reliably to the internet as it would require root priviledges. It means you can only ping the local router (10.0.2.2).

When using the built-in TFTP server, the router is also the TFTP server.

When using the `-redir' option, TCP or UDP connections can be redirected from the host to the guest. It allows for example to redirect X11, telnet or SSH connections.


MISC

CHANGING CD'S IN THE GUEST
Some people have reported problems changing CD's while running the guest OS.
rcerreto has posted a solution here:
http://ubuntuforums.org/showpost.php...&postcount=256



LINKS TO USEFULL INFORMATION

http://fabrice.bellard.free.fr/qemu/index.html
http://fabrice.bellard.free.fr/qemu/qemu-doc.html
http://www.debian-administration.org/?article=40
http://oui.com.br/n/content.php?article.21
http://www.carlsonhome.net/computer_help_log.php

Free Operating System Zoo
http://free.oszoo.org/

Have fun... and report me with any error confusion or other problem (copyright or other)

Aucun commentaire: