QEMU

QEMU is an open-source emulator. There is a GUI called virt-manager.

$ sudo apt install qemu-system-x86
$ qemu-system-x86_64 -h

QEMU uses the .qcow2 (QEMU Copy On Write) format for hard drives.

$ # format (.qcow2) | drive_name | drive_size
$ qemu-img create xxx.qcow2 1G
$ qemu-img create -f qcow2 xxx.qcow2 4G

Common usage

The most basic usage is to boot on a hard drive:

$ qemu-system-x86_64 -hda xxx.qcow2

Performance flags

$ [...] -m 2048        # RAM = 2G
$ [...] -smp 2         # 2 cores

Interface-related flags

$ [...] -nographic     # disable GUI, terminal-only interface
shutdown -h now
$ [...] -sdl           # use the SDL

Other flags

$ [...] -snapshot      # don't save to hard-drive

Networking

NAT network

You can use NAT which is the default. The VM will have the same network configuration as the host, but no one can reach the host.

$ # both are similar, the latter can be more tuned
$ [...] -net user
$ [...] -netdev user,id=net0 \
    -device virtio-net-pci,netdev=usernet

TAP Network

A TAP network simulates that the host and the VM are connected physically. Both are on the same network and can reach each other.

$ sudo ip tuntap add dev tap0 mode tap
$ sudo ip link set tap0 up
$ qemu[...] -netdev tap,ifname=tap0,id=br0 \
    -device virtio-net-pci,netdev=br0 # ,mac=...

πŸ‘» To-do πŸ‘»

Stuff that I found, but never read/used yet.