My Blog

Qemu x86/64

PDF ·

Download Alpine ISO, and save it to the file. Make empty Linux disk for a VM:

# ./mkdisk_20G linux.disk
qemu-img create -f qcow2 $1 20G

Then:

# ./install_x8664 linux.disk
qemu-system-x86_64 \
	-drive file=$1,format=qcow2 \
	-m 2048 \
	-netdev user,id=net0 \
	-device e1000,netdev=net0 \
	-netdev user,id=net1 \
	-device e1000,netdev=net1 \
	-boot d -cdrom /Users/wk/Downloads/alpine-extended-3.19.1-x86_64.iso

You should see terminal and then proceed with the installation. Once you’re done:

poweroff

Now to run the VM;

# run.sh linux.disk

qemu-system-x86_64 \
	-drive file=$1,format=qcow2 \
	-m 1500 \
	-netdev user,id=net0,hostfwd=tcp:127.0.0.1:9022-:22 \
	-device e1000,netdev=net0 \
        -netdev vmnet-shared,id=net1 \
	-device e1000,netdev=net1 \
	-virtfs local,path=`pwd`,mount_tag=osxfs,security_model=passthrough

Tags