Skip to content

Instantly share code, notes, and snippets.

@ojpojao
Created August 27, 2024 18:00
Show Gist options
  • Save ojpojao/7093e07a732fcb40f87b1f79699cfb43 to your computer and use it in GitHub Desktop.
Save ojpojao/7093e07a732fcb40f87b1f79699cfb43 to your computer and use it in GitHub Desktop.
create vm with QEMU from cmd
## 1
qemu-system-x86_64 \
-device e1000,netdev=net0,mac=50:b8:15:00:01:00 -netdev tap,id=net0,ifname=vunl1_0,script=no \
-device e1000,netdev=net1,mac=50:b8:15:00:01:01 -netdev tap,id=net1,ifname=vunl1_1 ,script=no \
-device e1000,netdev=net2,mac=50:b8:15:00:01:02 -netdev tap,id=net2,ifname=vunl1_2,script=no \
-device e1000,netdev=net3,mac=50:b8:15:00:01:03 -netdev tap,id=net3,ifname=vunl1_3,script=no \
-nographic -chardev socket,id=serial0,path=/opt/unetlab/tmp/1/1/console.sock,server,nowait \
-serial chardev:serial0 \
-chardev socket,id=monitor,path=/opt/unetlab/tmp/1/1/monitor.sock,server,nowait \
-monitor chardev:monitor \
-smp 1 \
-m 256 \
-name 'MK' \
-uuid 3705fd22-38b0-4cda-a622-787e8afdcdd5 \
-hda hda.qcow2 \
-machine type=pc,accel=kvm -serial mon:stdio -nographic -no-user-config -nodefaults -display none -vga std -rtc base=utc > /opt/unetlab/tmp/1/1/wrapper.txt
## 2
qemu-system-x86_64 \
-device e1000,netdev=net0,mac=50:49:bf:00:01:00 -netdev tap,id=net0,ifname=vunl1_0,script=no \
-device e1000,netdev=net1,mac=50:49:bf:00:01:01 -netdev tap,id=net1,ifname=vunl1_1,script=no \
-device e1000,netdev=net2,mac=50:49:bf:00:01:02 -netdev tap,id=net2,ifname=vunl1_2,script=no \
-device e1000,netdev=net3,mac=50:49:bf:00:01:03 -netdev tap,id=net3,ifname=vunl1_3,script=no \
-nographic -chardev socket,id=serial0,path=/opt/unetlab/tmp/1/1/console.sock,server,nowait \
-serial chardev:serial0 -chardev socket,id=monitor,path=/opt/unetlab/tmp/1/1/monitor.sock,server,nowait \
-monitor chardev:monitor \
-smp 1 \
-m 256 \
-name 'MK' \
-uuid 3705fd22-38b0-4cda-a622-787e8afdcdd5 \
-hda hda.qcow2 \
-machine type=pc,accel=kvm -serial mon:stdio -nographic -no-user-config -nodefaults -display none -vga std -rtc base=utc > /opt/unetlab/tmp/1/1/wrapper.txt
## 3
qemu-img create -f qcow2 disk.img 1G
qemu-system-x86_64 \
-name chr-1 \
-m 256M \
-boot once=dc\
-device e1000,netdev=ether1 \
-device e1000,netdev=ether2\
-netdev user,id=ether1,hostfwd=tcp::2020-:20,hostfwd=tcp::2121-:21,hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23,hostfwd=tcp::8291-:8291,hostfwd=tcp::8728-:8728 \
-netdev user,id=ether2 \
-drive file=hda.qcow2,if=virtio,cache=writeback,discard=ignore,format=qcow2 \
-machine type=q35,accel=kvm \
-vnc 127.0.0.1:40 \
-smp 2 \
-display gtk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment