QEMU (Application)

From campisano.org
Jump to navigation Jump to search

Using a debian as host

Install QEMU KVM version

su -
apt-get install qemu-kvm
exit

Install Windows 7 on a Debian 9

Create a raw image

  • Still raw images does not allocate all the initial required disk space (50 GB in this example), the initial disk space will be near to 0 and will increment during the use
qemu-img create -f qcow2 win7emu64bit.qcow2 50G

Install Windows

  • In this example, we will emulate a x86_64 system, with the same cpu as the host but with 4 cores and 3 GB of ram
qemu-system-x86_64 -nodefaults -nodefconfig -no-reboot\
 -enable-kvm -machine type=pc -cpu host -smp 4 -m 3072\
 -monitor vc -localtime\
 -vga std\
 -soundhw hda\
 -netdev user,id=network0\
 -device e1000,netdev=network0\
 -drive cache=writethrough,format=qcow2,media=disk,file=win7emu64bit.qcow2\
 -cdrom windows_7.iso;

Run after installation

  • This settings will set up a samba share folder that can be mapped as //10.0.2.4/qemu
qemu-system-x86_64 -nodefaults -nodefconfig -no-reboot\
 -enable-kvm -machine type=pc -cpu host -smp 4 -m 3072\
 -monitor vc -localtime\
 -vga std\
 -soundhw hda\
 -netdev user,id=network0,smb="/home/shared/public"\
 -device e1000,netdev=network0\
 -drive cache=writethrough,format=qcow2,media=disk,file=win7emu64bit.qcow2\
 -cdrom /dev/sr0;

Using a Macos as host

Install QEMU

  • then, use brew to install qemu:
brew install qemu

Install Debian 10 on a Macos

Create a raw image

  • Still raw images does not allocate all the initial required disk space (50 GB in this example), the initial disk space will be near to 0 and will increment during the use
qemu-img create -f qcow2 debian.qcow2 50G

Install Debian

  • In this example, we will emulate a x86_64 system, with an emulated cpu with 4 cores and 6 GB of ram
qemu-system-x86_64 -no-user-config -nodefaults -no-reboot\
 -cpu host -smp 6 -m 10240 -accel hvf\
 -display default,show-cursor=on -full-screen\
 -device virtio-vga,edid=true,xres=1440,yres=900\
 -device virtio-keyboard-pci\
 -device virtio-tablet-pci\
 -audiodev coreaudio,id=snd0\
 -device intel-hda -device hda-output,audiodev=snd0\
 -device virtio-net-pci,netdev=network0\
 -netdev user,id=network0\
 -device virtio-blk-pci,drive=disk0\
 -drive id=disk0,if=none,cache=writethrough,format=qcow2,media=disk,file=debian.qcow2\
 -cdrom debian.iso

Run after installation

  • forward guest port 22 to host port 10022
qemu-system-x86_64 -no-user-config -nodefaults -no-reboot\
 -cpu host -smp 6 -m 10240 -accel hvf\
 -display default,show-cursor=on -full-screen\
 -device virtio-vga,edid=true,xres=1440,yres=900\
 -device virtio-keyboard-pci\
 -device virtio-tablet-pci\
 -audiodev coreaudio,id=snd0\
 -device intel-hda -device hda-output,audiodev=snd0\
 -device virtio-net-pci,netdev=network0\
 -netdev user,id=network0,hostfwd=tcp::10022-:22\
 -device virtio-blk-pci,drive=disk0\
 -drive id=disk0,if=none,cache=writethrough,format=qcow2,media=disk,file=debian.qcow2

Convert a Virtualbox image

qemu-img convert -f vdi -O raw Win7Emu.vdi Win7Emu.img

References