Qemu commands

Some useful command to help running and setup qemu…

  • Create an empty compressed 10 Go disk image (in qcow2 format):

    qemu-img create -f qcow2 /home/kevin/qemu-disk-image.qcow 10G
    
  • Boot on your machine’s CD-Rom in qemu with previous disk image as primary HDD:
    qemu -cdrom /dev/cdrom -hda /home/kevin/qemu-disk-image.qcow -boot d
    
  • Same as above but with a CD-Rom iso image:
    qemu -cdrom /home/kevin/ubuntu.iso -hda /home/kevin/qemu-disk-image.qcow -boot d
    
  • Boot the previously created disk image:
    qemu /home/kevin/qemu-disk-image.qcow
    
  • Convert qcow image to a raw image:
    qemu-img convert /home/kevin/qemu-disk-image.qcow -O raw /home/kevin/qemu-disk-image.raw
    
  • Mount a RAW disk image:
    mount -o loop,offset=32256 /home/kevin/qemu-disk-image.raw /media/qemu/
    
  • Mount a qcow2 disk image via the nbd protocol (don’t forget to install the nbd-client package):
    modprobe nbd max_part=63
    qemu-nbd -c /dev/nbd0 /home/kevin/qemu-disk-image.qcow2
    mount /dev/nbd0p1 /media/qemu
    
  • To run a x86_64 guest system on a 32-bit host, simply use qemu-system-x86_64 binary command instead of qemu.

4 thoughts on “Qemu commands

  1. Pingback: Usefull Commands: a Synthesis | Kev's blog

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.