The QEMU system emulation command utilizes the qemu-system-x86_64
emulator to create a virtual x86_64 system with various hardware components, including a graphics card, network interfaces, storage devices, and USB controllers. The command enables acceleration and allocates 3 GB of RAM to the emulated system.
qemu-system-x86_64 -monitor stdio \
-device ati-vga \
-enable-kvm -accel hvf \
-smp 2 \
-m 3G \
-netdev tap,ifname=tap0,br=bridge1,script=no,downscript=no,id=n1 \
-device rtl8139,netdev=n1 \
-drive if=ide,index=1,media=cdrom,file="" \
-drive file="./VirtualBox VMs/Ubuntu/Ubuntu.vmdk",if=none,id=ubuntuhdd \
-device virtio-blk-pci,drive=ubuntuhdd,bus=pci.0,bootindex=2 \
-device piix3-usb-uhci \
-drive id=freeagent,file=/dev/disk2,if=none,format=raw \
-device usb-storage,drive=freeagent
#!/bin/bash
# Define VM settings
VMMODE="qemu-system-x86_64"
MONITOR="stdio"
GPU="ati-vga"
QEMU_ACCEL="hvf"
VCPUS="2"
MEM="3G"
NETWORK_DEV="tap"
NETWORK_IFNAME="tap0"
NETWORK_BRIDGE="bridge1"
NETWORK_SCRIPT="no"
NETWORK_DOWN_SCRIPT="no"
NETWORK_ID="n1"
NIC_MODEL="rtl8139"
# Define disk settings
CDROM_MEDIA="cdrom"
CDROM_FILE=""
DISK_ID="ubuntuhdd"
DISK_FILE="/path/to/Ubuntu.vmdk"
DISK_IF="none"
DISK_FORMAT="raw"
BOOT_INDEX="2"
# Define USB settings
USB_DEV="piix3-usb-uhci"
USB_HDD_ID="freeagent"
USB_HDD_FILE="/dev/disk2"
USB_HDD_IF="none"
# Define qemu command options
qemu_opts=(
"-monitor ${MONITOR}"
"-device ${GPU}"
"-enable-kvm"
"-accel ${QEMU_ACCEL}"
"-smp ${VCPUS}"
"-m ${MEM}"
"-netdev ${NETWORK_DEV},ifname=${NETWORK_IFNAME},br=${NETWORK_BRIDGE},script=${NETWORK_SCRIPT},downscript=${NETWORK_DOWN_SCRIPT},id=${NETWORK_ID}"
"-device ${NIC_MODEL},netdev=${NETWORK_ID}"
"-drive if=ide,index=1,media=${CDROM_MEDIA},file=${CDROM_FILE}"
"-drive file=${DISK_FILE},if=${DISK_IF},id=${DISK_ID}"
"-device virtio-blk-pci,drive=${DISK_ID},bus=pci.0,bootindex=${BOOT_INDEX}"
"-device ${USB_DEV}"
"-drive id=${USB_HDD_ID},file=${USB_HDD_FILE},if=${USB_HDD_IF},format=${DISK_FORMAT}"
"-device usb-storage,drive=${USB_HDD_ID}"
)
# Create qemu command
qemu_cmd="${VMMODE} ${qemu_opts[@]}"
# Print qemu command
echo "${qemu_cmd}"
This command utilizes QEMU to emulate an x86_64 system.
qemu-system-x86_64
: Starts the x86_64 QEMU emulator.-monitor stdio
: Establishes a standard input/output monitor for the emulator.-device ati-vga
: Specifies the ATI VGA graphics card for the emulated system.-enable-kvm
: Enables KVM (Kernel-based Virtual Machine) acceleration.-accel hvf
: Enables HVF (Hardware Virtualization Framework) acceleration.-smp 2
: Sets the number of CPU threads to 2.-m 3G
: Allocates 3 GB of RAM to the emulated system.-netdev tap,ifname=tap0,br=bridge1,script=no,downscript=no,id=n1
: Creates a tap device for networking.-device rtl8139,netdev=n1
: Specifies the RTL8139 network card with the tap device.-drive if=ide,index=1,media=cdrom,file=""
: Specifies an empty CDROM drive.-drive file="./VirtualBox VMs/Ubuntu/Ubuntu.vmdk",if=none,id=ubuntuhdd
: Specifies a VMDK file for the Ubuntu system.-device virtio-blk-pci,drive=ubuntuhdd,bus=pci.0,bootindex=2
: Specifies the virtio block device for the Ubuntu system.-device piix3-usb-uhci
: Specifies the PIIX3 USB UHCI controller.-drive id=freeagent,file=/dev/disk2,if=none,format=raw
: Specifies the raw disk file for the FreeAgent system.-device usb-storage,drive=freeagent
: Specifies the USB storage device for the FreeAgent system.