KVM getting started
Can use the prompt in ChatAI
how to launch ubuntu linux x86_64 in mac os apple silicon use :
qemu-system-x86_64
QEMU in macos
- Basic QEMU
1
2# create the virtual disk image
3qemu-img create -f qcow2 ubuntu-x86.qcow2 20G
4
5# install the ubuntu os to virtual disk
6qemu-system-x86_64 \
7-m 4G \
8-smp 4 \
9-machine q35,accel=tcg\
10-cpu Broadwell \
11-drive file=ubuntu-x86.qcow2,format=qcow2 \
12-cdrom path/to/ubuntu-iso.iso \
13-boot d \
14-vga virtio \
15-display default,show-cursor=on
16
17# launch the ubuntu linux from virtual disk
18qemu-system-x86_64 \
19-m 4G \
20-smp 4 \
21-machine q35,accel=tcg \
22-cpu Broadwell \
23-drive file=ubuntu-x86.qcow2,format=qcow2 \
24-vga virtio \
25-display default,show-cursor=on
26
27
28#
29# -machine virt specifies a type of a machine - we have no interest in emulating a specific hardware so we just use the special type virt
30# the accel=hvf part is the important one: it enables hardware acceleration using macOS Hypervisor Framework
31# -cpu host specifies that the guest machine will see exactly the same CPU model as the host machine (required for acceleration)
32#
33qemu-system-aarch64 \
34 -machine virt,accel=hvf \
35 -cpu host
- Shortcut Try hitting Ctrl+Opt+2 or Ctrl+Opt+3 and you should see the output of serial and parallel ports. This is where we’re going to see our operating system running. You can always go back to the monitor console with Ctrl+Opt+1
- Use the UEFI to launch
1qemu-system-aarch64 \
2 -nodefaults \
3 -machine virt,accel=hvf \
4 -cpu host \
5 -chardev vc,id=monitor \
6 -mon monitor \
7 -serial vc \
8 -bios /opt/homebrew/share/qemu/edk2-aarch64-code.fd
Install require packages
1# check the BIOS is enabled virtualization
2egrep --color 'vmx|svm' /proc/cpuinfo
3
4echo " Upgrade the system"
5sudo apt-get update && sudo apt-get -y upgrade || apt-get -y install sudo && sudo apt-get update && sudo apt-get -y upgrade
6
7echo "Virtualization host installation"
8sudo apt-get -y install qemu-kvm libvirt-bin virtinst virt-viewer libguestfs-tools virt-manager uuid-runtime curl libvirt-dev genisoimage qemu-kvm libyaml-dev
9
10echo "Enable libvirt"
11sudo systemctl restart libvirtd
12sudo virt-host-validate
13
14
15
16# with kvm
17minikube start --vm-driver kvm2