How to use qemu

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
(Imported from MoinMoin)
 
(Adapted to new qemu commands)
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
= How to use QEMU to test Fedora development or test images =
+
= How to use QEMU =
 
+
  
 +
QEMU is a very flexible virtualization technology however it is quite slow and it is recommended that you understand and evaluate alternative solutions before picking this one.  Refer to [[Getting started with virtualization]]
  
 
== Qemu ==
 
== Qemu ==
Line 16: Line 16:
 
QEMU is available on Fedora repository. It can be installed by:
 
QEMU is available on Fedora repository. It can be installed by:
  
$<code> su -c "yum install qemu" </code>
+
<pre>
 +
$ su -c "yum install qemu"
 +
</pre>
  
== Testing Rawhide or Fedora Test releases ==
 
  
Create the virtual image for the system:
+
== Qemu commands since F?+ ==
 +
To discover the qemu commands that are installed perform the following:
  
 +
<pre>
 +
$ ls /usr/bin/qemu-*
 +
</pre>
  
$ <code> qemu-img create -f qcow fedora.qcow 5G </code>
+
In the following examples where "qemu" is, substitute your command for executing qemu.
 +
E.g.
 +
<pre>
 +
qemu-system-i386
 +
</pre>
 +
 
 +
or
 +
 
 +
<pre>
 +
qemu-i386
 +
</pre>
 +
 
 +
Of course, this does not apply to "qemu-img".
 +
 
 +
== Qemu virtual machine installation ==
 +
 
 +
Create the virtual image for the system:
 +
 
 +
<pre>
 +
$ qemu-img create fedora.qcow 5G
 +
</pre>
  
 
Of course you are not obliged to take 5GB.
 
Of course you are not obliged to take 5GB.
Line 32: Line 57:
 
Put in the install CD and type into your konsole (all in one line without break):
 
Put in the install CD and type into your konsole (all in one line without break):
  
$ <code> qemu -cdrom /dev/cdrom -hda fedora.qcow -boot d -net nic -net user -m 196 -localtime </code>
+
<pre>
 +
$ qemu -cdrom /dev/cdrom -hda fedora.qcow -boot d -net nic -net user -m 196 -localtime
 +
</pre>
  
 
"-user -net" is important to have internet access within your new system. "-m 196" is the Set virtual RAM size (megabytes), default is 128 MB, I chose 196.
 
"-user -net" is important to have internet access within your new system. "-m 196" is the Set virtual RAM size (megabytes), default is 128 MB, I chose 196.
Line 38: Line 65:
 
The install may take some time. After the install, qemu will try to boot the new OS itself. Maybe this may fail (was the case for me) - but don't worry. If that happens: just close the qemu window and type the following command into your konsole to launch your new OS:
 
The install may take some time. After the install, qemu will try to boot the new OS itself. Maybe this may fail (was the case for me) - but don't worry. If that happens: just close the qemu window and type the following command into your konsole to launch your new OS:
  
$ <code> qemu fedora.qcow -boot c -net nic -net user -m 196 -localtime </code>
+
<pre>
 +
$qemu fedora.qcow -boot c -net nic -net user -m 196 -localtime
 +
</pre>
  
 
== Testing ISO Images ==
 
== Testing ISO Images ==
Line 44: Line 73:
 
Type, in the proper directory
 
Type, in the proper directory
  
$ <code> qemu -cdrom fXtestN.iso </code>
+
<pre>
 +
$ qemu -m 512M -cdrom <isoname>.iso
 +
</pre>
 +
 
 +
== Debugging ==
  
 +
To get kernel output dumped to a file outside the virtual system, add e.g. "-serial file:/tmp/qemu-output.log" to the qemu command line.  When booting the virtual system, add "console=ttyS0" to the kernel boot parameters.
  
Credits to MirjamWaeckerlin
+
This output is particularly helpful if you are having trouble booting the system, in which case you may also wish to remove "rhgb" and "quiet" from the kernel boot parameters.

Revision as of 04:38, 10 August 2012

Contents

How to use QEMU

QEMU is a very flexible virtualization technology however it is quite slow and it is recommended that you understand and evaluate alternative solutions before picking this one. Refer to Getting started with virtualization

Qemu

QEMU is a generic and open source processor emulator which achieves a good emulation speed by using dynamic translation.

QEMU has two operating modes:

  • Full system emulation. In this mode, QEMU emulates a full system (for example a PC), including a processor and various peripherials. It can be used to launch different Operating Systems without rebooting the PC or to debug system code.
  • User mode emulation (Linux host only). In this mode, QEMU can launch Linux processes compiled for one CPU on another CPU.

Download

QEMU is available on Fedora repository. It can be installed by:

$ su -c "yum install qemu"


Qemu commands since F?+

To discover the qemu commands that are installed perform the following:

$ ls /usr/bin/qemu-*

In the following examples where "qemu" is, substitute your command for executing qemu. E.g.

qemu-system-i386

or

qemu-i386

Of course, this does not apply to "qemu-img".

Qemu virtual machine installation

Create the virtual image for the system:

$ qemu-img create fedora.qcow 5G

Of course you are not obliged to take 5GB.

Note: Even if you take 10GB this does NOT mean that the image does really HAVE the size of 10GB. It just means that your new system is limited up to 10GB - if the new sytem takes only 1,2 GB also the image will only be at 1,2GB.

now let's install the OS. Put in the install CD and type into your konsole (all in one line without break):

$ qemu -cdrom /dev/cdrom -hda fedora.qcow -boot d -net nic -net user -m 196 -localtime

"-user -net" is important to have internet access within your new system. "-m 196" is the Set virtual RAM size (megabytes), default is 128 MB, I chose 196.

The install may take some time. After the install, qemu will try to boot the new OS itself. Maybe this may fail (was the case for me) - but don't worry. If that happens: just close the qemu window and type the following command into your konsole to launch your new OS:

$qemu fedora.qcow -boot c -net nic -net user -m 196 -localtime

Testing ISO Images

Type, in the proper directory

$ qemu -m 512M -cdrom <isoname>.iso

Debugging

To get kernel output dumped to a file outside the virtual system, add e.g. "-serial file:/tmp/qemu-output.log" to the qemu command line. When booting the virtual system, add "console=ttyS0" to the kernel boot parameters.

This output is particularly helpful if you are having trouble booting the system, in which case you may also wish to remove "rhgb" and "quiet" from the kernel boot parameters.