发新话题
打印

[分享] How to install QEmu on Ubuntu Linux (Breezy)

How to install QEmu on Ubuntu Linux (Breezy)

Intro:How to install and run Windows 2000 under QEMU on Ubuntu Linux (Breezy)
OverviewThe below details how to install Windows 2000 as a guest O/S using the freely available QEMU virtualisation software. The document below assumes you are running a Linux based O/S (as reference I used Ubuntu Hoary/Breezy).
I came across QEMU when looking for alternatives to VMWare (and paying for a license). QEMU is free (but has distribution restrictions - see the Qemu website for further details).
History:Last Updated: February 14th 2006 for Qemu version 0.8.0.
Step 1 : Install QEMUInstall Qemu - this should be a simple "apt-get install qemu". You'll notice it sucks down the BOCHs BIOS stuff.
Unfortunately the qemu package in Ubuntu Breezy has a bug in that the Windows 2000 installer appears to hang when it's "detecting devices"; for this reason I had to use the binary distribution of QEMU from the website
After installing the binary package, I decided to also install the kernel module, which can be installed as follows...
Note; you do not need the kernel module, but installing it makes Qemu a lot quicker
Download QEmu SourceYou'll need :

wget http://fabrice.bellard.free.fr/qemu/qemu-0.8.0.tar.gz
Extract it to somewhere (e.g /tmp)
Download Kernel packageIf you don't already have the kernel-source package installed for your currently running kernel, you'll need it.

apt-get install linux-source-2.6.12cd /usr/srctar -xjf linux-source-2.6.12.tar.bz2
Setup kernel package
cp /boot/config-`uname -r` /usr/src/linux-source-2.6.12/.configcd /usr/src/linux-source-2.6.12make oldconfigmake modules
(*Note*: You don't need to make all modules, but leave it compile until 30 lines or so of output appear)
Ensure the link in /lib/modules/`uname -r`/build points to the /usr/src/linux-source-2.6.12 directory.
Compiling the kqemu kernel moduleNext we need to compile the kqemu kernel module....so download the KQemu source package ...

wget http://fabrice.bellard.free.fr/qemu/kqemu-0.7.2.tar.gz
Extract (tar -zxf kqemu-0.7.2.tar.gz) this file, and it'll produce a directory called 'kqemu'. Copy (or move) this into the qemu source directory.

cd /path/to/qemu-sources./configure --prefix=/usr/local
(*Needed to setup kqemu's Makefile.. *)
(*Note: If using qemu 0.8.0 + Breezy, you'll need to use the --disable-gcc-check option to ./configure as well).

cd kqemumakemake installsh installmodprobe kqemu
(Check 'dmesg' output and you should see it being mentioned near the bottom).
Step 2: Create an Image file to contain the Guest O/S (Windows 2000)
qemu-img create qemu_basic.img 3G
In my case, I'm creating an image which is 3gb in size, and will be located in my current working directory with a name of qemu_basic.img.
Step 3 : Install Windows 2000 under QEMUInsert the Windows 2000 cdrom, and run the following to begin the installation :

qemu -hda qemu_basic.img -cdrom /dev/cdrom -boot d -win2k-hack -m 256
The above tells it to boot using the above created image file as it's C:, to make the cdrom accessible (using /dev/cdrom) and to boot from D: (the cdrom).
The -win2k-hack bit is needed to stop Windows hanging (there are reports of a disk-full error online, but I just experienced it hanging while trying to detect devices.).
The installation of Windows does take quite some time, even with the kqemu kernel module loaded. Other reports online stated that it was faster if it was kept full screened. QEMU's default memory allocation is 128mb which is probably about average for when Windows 2000 was released, but we can do better than that now.
Step 4: Running Windows 2000 under QEMUThis is as simple as :

qemu -hda /path/to/image_file -m 256
If you wish for networking to work as well, you'll need to configure IP Masquerading (See script below) - QEmu since v0.8 has a new network stack, where qemu will give a client computer an ip address (10.X.X.X) via dhcp (from qemu); all settings are taken care of - aside from you ensuring you have IP forwarding and NAT enabled on the host (I assume).
Step 5: Wrapper script for QEMUI've written the following wrapper script for QEMU which makes life slightly easier :

#!/bin/bashset -eset -xecho "Enter your password when prompted."sudo sysctl -w net.ipv4.ip_forward=1sudo /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEsudo sysctl -w dev.rtc.max-user-freq=1024set +xecho "Starting QEMU"/usr/local/bin/qemu -hda /var/qemu/qemu_basic_win2k.img -boot c
The above should be possible using sudo, but for some reason it didn't work for me, hence the multiple "su - X -c" 's.
Notes for x86-64 installationsWhen installing qemu for an x86-64 system, it'll be necessary to :
  • apt-get install libsdl1.2-dev zlib1g-dev gcc-3.4
The kqemu kernel module will need to be compiled with the same compiler as the kernel - probably gcc 4.0 if you're using Ubuntu Breezy.
You'll have to compile qemu from source, as there isn't a binary package on the qemu website for x86-64....
Qemu itself has a few warnings about compilation with gcc-4.0; because of this I changed the /usr/bin/gcc symlink to point to /usr/bin/gcc-3.4, and compiled qemu with this. There were quite a few warnings, but none fatal, and it appears to work.
My Observations
  • It's definately slower to install Windows 2000 under QEMU than it was with VMWare. Even with the kqemu module loaded.
  • There's a lack of obvious documentation on the QEMU website (hence I wrote this) (I couldn't see instructions on how to install windows and get up and running)
  • The QEMU source code's ./configure script doesn't pick up all the dependencies you'll need. I found I needed to install various -dev packages in order to compile QEMU. Perhaps this is Ubuntu's fault for not including libraries/compilers/make with the default install?
  • Did I say it takes a long time to install? I'd strongly suggest you give qemu more than it's default of 128mb of RAM. (for example use '-m 256')
  • Changing the resolution under Windows results in an unreadable screen (Well mostly unreadable, you can figure out how to shut it down!). After rebooting however the QEMU window will refresh properly and you'll see the new resolution setting work fine.
Technorati Tags: Documentation Linux

QEMUSubmitted by Rob Neild (not verified) on Sat, 26/11/2005 - 08:54.
excellent directions on setting up qemu on ubuntu. Thanks a lot.

»

sudoSubmitted by Leigh Purdie (not verified) on Tue, 13/12/2005 - 00:25.
Try the following sudo commands instead:
sudo sh -c "/bin/echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo /bin/chmod 666 /dev/net/tun

»

Very useful.Submitted by stilgar (not verified) on Wed, 25/01/2006 - 14:59.
Thank you, this post saved me a lot of time.

»

Time saverSubmitted by jan-wijbrand (not verified) on Sun, 12/03/2006 - 12:49.
I can concur: this howto saves a lot of time. Thanks!

»

make oldconfig doesn't workSubmitted by Navid (not verified) on Thu, 16/03/2006 - 11:30.
I have followed all the steps before the make oldconfig, but after installing that creepy command, it gives me this naughty error:
----------------------------------------------------------------

root@ubuntu:/usr/src/linux-source-2.6.12# make oldconfig
/usr/src/linux-source-2.6.12/scripts/gcc-version.sh: line 11: gcc-3.4: command n
ot found
/usr/src/linux-source-2.6.12/scripts/gcc-version.sh: line 12: gcc-3.4: command n
ot found
HOSTCC scripts/basic/fixdep
/bin/sh: gcc-3.4: command not found
make[1]: *** [scripts/basic/fixdep] Error 127
make: *** [scripts_basic] Error 2

----------------------------------------------------------------
I was wondering if anybody has any diagnostic for this poor guy's case. BTW I'm using Kubuntu Breezy and as you can see my GCC version is 3.4.
Cheers

»

apt-get install gcc-3.4Submitted by David Goodwin on Thu, 16/03/2006 - 13:56.
You need to install gcc-3.4;
run :

apt-get update
apt-get install gcc-3.4

And that should fix it!

»

I got the intial error andSubmitted by Steve Pai (not verified) on Wed, 20/02/2008 - 19:48.
I got the intial error and applied the suggested changes. Still getting errors:
dhcp203:/usr/src/linux-source-2.6.18# make oldconfig
/usr/src/linux-source-2.6.18/scripts/gcc-version.sh: line 11: gcc: command not found
/usr/src/linux-source-2.6.18/scripts/gcc-version.sh: line 12: gcc: command not found
HOSTCC scripts/basic/fixdep
/bin/sh: gcc: command not found
make[1]: *** [scripts/basic/fixdep] Error 127
make: *** [scripts_basic] Error 2
dhcp203:/usr/src/linux-source-2.6.18#

»

install a compiler etcSubmitted by David Goodwin on Wed, 20/02/2008 - 20:36.
I think debian has a linux-kernel-devel package - install this and your problem will go away.
(The problem is you don't have gcc (a compiler) installed on your computer).
thanks,
David.

»

Thank you for your help.Submitted by Steve (not verified) on Thu, 21/02/2008 - 01:44.
Thank you for your help. Everything worked after I used your suggestion up until ./configure --prefix=/usr/local
dhcp203:/home/steve/Desktop/Downloads/kqemu-1.3.0pre11# ./configure --prefix=/usr/local
Could not find kernel includes in /lib/modules or /usr/src/linux - cannot build the kqemu module
Source path /home/steve/Desktop/Downloads/kqemu-1.3.0pre11
C compiler gcc
Host C compiler gcc
make make
host CPU i386
./configure: line 344: test: =: unary operator expected
Thank you for your help :) I'm pretty new to Linux.

»

Sorry, I just saw that mySubmitted by Steve (not verified) on Thu, 21/02/2008 - 02:59.
Sorry, I just saw that my previous reply was commented on below. I received the following output:
________________________________________________
dhcp203:/home/steve/Desktop/Downloads/kqemu-1.3.0pre11# ./configure --prefix=/usr/local
Source path /home/steve/Desktop/Downloads/kqemu-1.3.0pre11
C compiler gcc
Host C compiler gcc
make make
host CPU i386
kernel sources /usr/src/linux
kbuild type 2.6
dhcp203:/home/steve/Desktop/Downloads/kqemu-1.3.0pre11# cd ..
__________________________________________________________________________________________
I'm assuming it means that it was successful? Thank you for your help.

»





Kernel compilationSubmitted by SOULfly_B (not verified) on Fri, 17/03/2006 - 11:15.
http://wiki.ubuntu-fr.org/doc/custom_kernel
To compile the kernel, you will need some extra packages, as explained in the page mentioned above.
Indeed, you will need those packages :
build-essential
kernel-package

»

crashing xSubmitted by skeleton (not verified) on Fri, 19/05/2006 - 14:06.
I found that x was crashing a lot momentarily after running qemu
after I stopped telling it to use 256 bit colour like the command given here does its stopped doing it.
Just thought this could be useful for someone else.
Windows is computer AIDS.

»

Umm.. it's not color, it'sSubmitted by andrejkw (not verified) on Fri, 02/06/2006 - 20:39.
Umm.. it's not color, it's how mmuch RAM you want to give the Guest OS.

»

QEMU WIndows XPSubmitted by Luis Caldera (not verified) on Fri, 30/06/2006 - 18:39.
Thanks for this howto. You saved my life!. I installed win XP, in dapper 386, every ran smoothly. But now I want to load in windows a fat32 partition that I have in /dev/hda2, I tried to doit with the option -hdb /dev/hda2, as normal user and as sudo, but it didn't work neither way.
Any HInts!!!

»

Yeah you have to specify theSubmitted by Anonymous (not verified) on Tue, 25/07/2006 - 08:32.
Yeah you have to specify the location by using fat:// or something.

»


help me out plzSubmitted by Anonymous (not verified) on Fri, 11/08/2006 - 21:53.
i've donw the installation all fine can run qin2k perfectly
but how can i make qemu access the internet ? ? ? ? ?i ned to run applications that require internet on my pc thnx in advance

»

"fatal" errors when trying to modprobeSubmitted by xurizaemon (not verified) on Sun, 13/08/2006 - 12:09.
if you try to load the kqemu module and get FATAL errors, this may indicate that you've compiled the kqemu module with a different GCC to the one used to compile your kernel
on dapper, my kernel (currently 2.6.15-26-k7) is built with gcc4. qemu wanted to be built with gcc-3.4, so when i compiled the kqemu module after that it took me a while to realise that the kqemu mod needs to be compiled with the same gcc as my kernel - but it doesn't matter that it's compiled with a different gcc from qemu!
so: kernel + kqemu GCC have to match ... and for me, kqemu + qemu GCC don't need to match ...
hope this helps anyone who gets thrown by it!

»

Kqemu setup errorSubmitted by apit (not verified) on Tue, 27/02/2007 - 04:33.
i got this msj when installing kqemu
root@buzz:/home/skylixx/Desktop/kqemu-1.3.0pre11# ./configure --prefix=/usr/local
Could not find kernel includes in /lib/modules or /usr/src/linux - cannot build the kqemu module
Source path /home/skylixx/Desktop/kqemu-1.3.0pre11
C compiler gcc
Host C compiler gcc
make make
host CPU i386
./configure: line 344: test: =: unary operator expected

»

install the kernel source or kernel headers packageSubmitted by David Goodwin on Tue, 27/02/2007 - 08:20.
you need to either install the source package for your running kernel and set it up appropriately ...
e.g.
apt-get install linux-source-2.6.17
cd /usr/src
tar -xjf linux-source-2.6.17.tar.bz2
ln -s linux-source-2.6.17 linux
cd linux
cp /boot/config-2.6.17 .config
make oldconfig
make modules (press ctrl+c after about 30 seconds)
Then try running the configure script again...

»


qemu 9 packagesSubmitted by Tolero Linux (not verified) on Tue, 06/03/2007 - 13:32.
I've prepared packages of qemu 9 and kqemu for ubuntu dapper and edgy, check my repository. The feisty is upcomming.

»

qemu installingSubmitted by Anonymous (not verified) on Thu, 11/10/2007 - 08:03.
dear all
i got an error when i'm trying write this line of code
cp /boot/config-`uname -r` /usr/src/linux-source-2.6.12/.config
the error message is as follow:
cp: cannot stat `/boot/config-uname -r': No such file or directory
please help me
thanks

»

back ticks....Submitted by David Goodwin on Thu, 11/10/2007 - 17:57.
looks like you missed the opening ` mark - it's a back tick - and _not_ a single quote.
Alternatively, you could do :
cp /boot/config-$(uname -r) /usr/src/linux-source-2.6.12/.config
as the $(command) syntax is the same as `command`

»


cold not open hard disk image?Submitted by TheSourMango (not verified) on Mon, 10/12/2007 - 16:03.
i get an error like this when trying to boot my windows install disk..
dennis@DennisPs3:~$ sudo qemu -hda qemu_basic.img -cdrom -boot /media/cdrom0/ -m 256
Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a fatal
error, but for better emulation accuracy either use a 2.6 host Linux kernel or
type 'echo 1024 > /proc/sys/dev/rtc/max-user-freq' as root.
qemu: could not open hard disk image '/media/cdrom0/'
I have made some adjustments on your code, since im booting XP and since im on a PS3.. But the location of the cd is right, its located in /media/cdrom0/
just a small question.. the install cd should be a totally normal one, exactly one you buy from the store right?

»

boot cd for ps3Submitted by David Goodwin on Mon, 10/12/2007 - 18:33.
Hi,
I think you need something like /dev/sdc (or whatever). /media/cdrom0 is the mount point for the CD, and you need to be specifying the block device (I think)
David

»


When trying to install Qemu,Submitted by Steve (not verified) on Thu, 21/02/2008 - 02:56.
When trying to install Qemu, I get this output:
__________________________________________________________________________________
dhcp203:/home/steve/Desktop/Downloads/qemu-0.9.1# ./configure --prefix=/usr/local
WARNING: "gcc" looks like gcc 4.x
Looking for gcc 3.x
Found "gcc-3.4"
./configure: line 639: pkg-config: command not found
Install prefix /usr/local
BIOS directory /usr/local/share/qemu
binary directory /usr/local/bin
Manual directory /usr/local/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path /home/steve/Desktop/Downloads/qemu-0.9.1
C compiler gcc-3.4
Host C compiler gcc
make make
install install
host CPU i386
host big endian no
target list i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user sparc64-linux-user sparc32plus-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user sh4-linux-user sh4eb-linux-user ppc-linux-user ppc64-linux-user ppc64abi32-linux-user x86_64-linux-user cris-linux-user i386-softmmu sparc-softmmu x86_64-softmmu mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu arm-softmmu ppc-softmmu ppcemb-softmmu ppc64-softmmu m68k-softmmu sh4-softmmu sh4eb-softmmu cris-softmmu
gprof enabled no
profiler no
static build no
-Werror enabled no
SDL support no
mingw32 support no
Adlib support no
CoreAudio support no
ALSA support no
DSound support no
FMOD support no
OSS support yes
VNC TLS support no
kqemu support yes
Documentation no
The error log from compiling the libSDL test is:
/tmp/qemu-conf-21853-10067-6412.c:1:17: SDL.h: No such file or directory
/tmp/qemu-conf-21853-10067-6412.c: In function `main':
/tmp/qemu-conf-21853-10067-6412.c:3: error: `SDL_INIT_VIDEO' undeclared (first use in this function)
/tmp/qemu-conf-21853-10067-6412.c:3: error: (Each undeclared identifier is reported only once
/tmp/qemu-conf-21853-10067-6412.c:3: error: for each function it appears in.)
ERROR: QEMU requires SDL or Cocoa for graphical output
To build QEMU without graphical output configure with --disable-gfx-check
Note that this will disable all output from the virtual graphics card.
______________________________________________________________________________________________________
Upon adding --disable-gfx-check, I have this error:
______________________________________________________________________________________________________
dhcp203:/home/steve/Desktop/Downloads/qemu-0.9.1# ./configure --prefix=/usr/local --disable-gfx-check
WARNING: "gcc" looks like gcc 4.x
Looking for gcc 3.x
Found "gcc-3.4"
./configure: line 639: pkg-config: command not found
Install prefix /usr/local
BIOS directory /usr/local/share/qemu
binary directory /usr/local/bin
Manual directory /usr/local/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path /home/steve/Desktop/Downloads/qemu-0.9.1
C compiler gcc-3.4
Host C compiler gcc
make make
install install
host CPU i386
host big endian no
target list i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user sparc64-linux-user sparc32plus-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user sh4-linux-user sh4eb-linux-user ppc-linux-user ppc64-linux-user ppc64abi32-linux-user x86_64-linux-user cris-linux-user i386-softmmu sparc-softmmu x86_64-softmmu mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu arm-softmmu ppc-softmmu ppcemb-softmmu ppc64-softmmu m68k-softmmu sh4-softmmu sh4eb-softmmu cris-softmmu
gprof enabled no
profiler no
static build no
-Werror enabled no
SDL support no
mingw32 support no
Adlib support no
CoreAudio support no
ALSA support no
DSound support no
FMOD support no
OSS support yes
VNC TLS support no
kqemu support yes
Documentation no
The error log from compiling the libSDL test is:
/tmp/qemu-conf-5092-10456-27214.c:1:17: SDL.h: No such file or directory
/tmp/qemu-conf-5092-10456-27214.c: In function `main':
/tmp/qemu-conf-5092-10456-27214.c:3: error: `SDL_INIT_VIDEO' undeclared (first use in this function)
/tmp/qemu-conf-5092-10456-27214.c:3: error: (Each undeclared identifier is reported only once
/tmp/qemu-conf-5092-10456-27214.c:3: error: for each function it appears in.)
______________________________________________________________________________________________________
I'm not sure how to solve it. Again, Thank you so much for your help :)

TOP

的尺不停的衡量那情感。

<我不爱你,我不恨你。>
以为该22ccc的尺不停的衡量那情感。
sese的尺不停的衡量那情感。
avi很爱的,可能只爱在心里。会心酸。
当作亲人,当作陌生人。其实。都只是人。
以为怀着恨的。心里的尺不停的衡量那情感。
测不出。都在起点。
只有冷淡。

TOP

[url=http://www.lhjipiao.cn/]lhjipiao.cn[/url]

TOP

发新话题