Flag | Usage |
---|---|
-boot d | Specify the boot device :
|
-cdrom file | Use file as CD-ROM image. You can use the host CD-ROM by using /dev/cdrom as filename.
-hdc and -cdrom are mutually exclusive.
|
-cpu cpuModel | Select CPU model. qemu -cpu ? to list available models. More about x86_64 processors. |
-curses | Normally, QEMU uses SDL to display the VGA output. With this option, QEMU can display the VGA output when in text mode using a curses/ncurses interface. Nothing is displayed in graphical mode.
Using this option without -k fr completely f*cks up my keyboard.
|
-hda file | Use file as hard disk 0 image. And respectively hdb, hdc, hdd for disks 1, 2 and 3 images. |
-k language | Use keyboard layout language (fr for French). Defaults to en-us. |
-m n | Set virtual Memory (RAM) size to n MiB. You can specify an optional M or G for MiB or GiB. Defaults to 128 MiB. |
-smp n | Simulate an SMP system with n CPUs.
Additional parameters are available for sockets, cores and threads : -smp sockets=8,cores=4,threads=4
|
-snapshot | Any changes made to the virtual machine while it is running are written to temporary files and thrown away when the virtual machine is turned off. No changes are saved to the original .img file. |
qemu-img convert -c myVirtualMachine.img -O qcow myVirtualMachine.img.compressed
Run these actions on the host system :
#auto eth0 iface eth0 inet manual
# auto load a bridge auto br0 # configure the bridge using DHCP iface br0 inet dhcp # create a tap device owned by bob (who is a host system user), and turn it up pre-up ip tuntap add dev tap0 mode tap user bob pre-up ip link set tap0 up # add all physical interfaces to the bridge bridge_ports all tap0 # speed up the activating of the bridge (details) bridge_stp off bridge_maxwait 0 bridge_fd 0 post-down ip link set tap0 down post-down ip tuntap del dev tap0 mode tap
rootDir='/home/bob/'; isoImageFile="${rootDir}path/to/debian-7.3.0-amd64-netinst.iso"; vmDir="${rootDir}Qemu/"; vmFile="${vmDir}debian73x64.img"; vmDiskSizeGb=2; ramMb=1024; nbCpu=2
qemu-img create "$vmFile" "${vmDiskSizeGb}G"; qemu-system-x86_64 -smp $nbCpu -m $ramMb -boot d -hda "$vmFile" -cdrom "$isoImageFile"
compressedVmFile="${vmFile}.compressed"; qemu-img convert -c "$vmFile" -O qcow "$compressedVmFile"
qemu-system-x86_64 -smp $nbCpu -m $ramMb -hda "$compressedVmFile" -net nic -net tap,ifname=tap0,script=no,downscript=no -snapshot