Compare commits
2 Commits
42f9b20c25
...
2b543fbff6
Author | SHA1 | Date | |
---|---|---|---|
2b543fbff6 | |||
a7ef8179f5 |
13
README.md
Normal file
13
README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# VMs
|
||||||
|
|
||||||
|
## HOW-TO
|
||||||
|
To start (or create) a VM, go in the desired folder and run
|
||||||
|
```console
|
||||||
|
$ ./run.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## USB Passthrough
|
||||||
|
|
||||||
|
If you need USB passthrough, uncomment and fill in the corresponding line in
|
||||||
|
`run.sh`.
|
||||||
|
[You may need root privileges](https://wiki.archlinux.org/title/QEMU#Pass-through_host_USB_device).
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash -e
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
. ./lib.sh
|
|
||||||
|
|
||||||
if [ -f hda.qcow2 ]; then
|
|
||||||
echo -e "Disk file exists. Are you sure you don't want" \
|
|
||||||
"\e[1m\e[31m./run.sh\e[0m?\nCtrl-C to interrupt" >&2
|
|
||||||
read -r
|
|
||||||
fi
|
|
||||||
|
|
||||||
qemu-img create -f qcow2 hda.qcow2 10G
|
|
||||||
|
|
||||||
CMD=(
|
|
||||||
"${CMD[@]}"
|
|
||||||
-drive file=arch.iso,index=1,media=cdrom,readonly=on
|
|
||||||
)
|
|
||||||
|
|
||||||
"${CMD[@]}"
|
|
@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
arch=''
|
|
||||||
|
|
||||||
curl -LC- \
|
|
||||||
-o arch.iso "$arch"
|
|
23
arch/lib.sh
23
arch/lib.sh
@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
RAM="$(free -g | awk '/^Mem:/{print $2 - 2}')"
|
|
||||||
|
|
||||||
if [ "$RAM" -le 2 ]; then RAM=2
|
|
||||||
elif [ "$RAM" -gt 32 ]; then RAM=32; fi
|
|
||||||
|
|
||||||
RAM="${RAM}G"
|
|
||||||
|
|
||||||
CMD=(
|
|
||||||
qemu-system-x86_64
|
|
||||||
-accel kvm
|
|
||||||
-M q35
|
|
||||||
# usb
|
|
||||||
-device qemu-xhci
|
|
||||||
-cpu host
|
|
||||||
-m "2G,maxmem=$RAM"
|
|
||||||
-vga virtio
|
|
||||||
#-drive if=virtio,file=hda.qcow2
|
|
||||||
# shared memory
|
|
||||||
-object memory-backend-ram,id=mem,size=2G,share=on
|
|
||||||
-numa node,memdev=mem
|
|
||||||
)
|
|
14
arch/run.sh
14
arch/run.sh
@ -1,12 +1,20 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
. ./lib.sh
|
. ../lib.sh
|
||||||
|
|
||||||
|
hda='https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-basic.qcow2'
|
||||||
|
|
||||||
|
if ! [ -f hda.qcow2 ]; then
|
||||||
|
ask_yn "hda does not exist. Download?" \
|
||||||
|
&& curl -LC- -o hda.qcow2 "$hda" \
|
||||||
|
|| exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
CMD=(
|
CMD=(
|
||||||
"${CMD[@]}"
|
"${CMD[@]}"
|
||||||
-nic user,model=virtio-net-pci
|
-nic user,model=virtio-net-pci
|
||||||
# usb passthrough, might need root privileges
|
# USB passthrough, might need root privileges
|
||||||
#-device usb-host,vendorid=0x058f,productid=0x6387
|
#-device usb-host,vendorid=0xffff,productid=0xffff
|
||||||
)
|
)
|
||||||
|
|
||||||
"${CMD[@]}"
|
"${CMD[@]}"
|
||||||
|
20
debian12/run.sh
Executable file
20
debian12/run.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
. ../lib.sh
|
||||||
|
|
||||||
|
hda='https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2'
|
||||||
|
|
||||||
|
if ! [ -f hda.qcow2 ]; then
|
||||||
|
ask_yn "hda does not exist. Download?" \
|
||||||
|
&& curl -LC- -o hda.qcow2 "$hda" \
|
||||||
|
|| exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CMD=(
|
||||||
|
"${CMD[@]}"
|
||||||
|
-nic user,model=virtio-net-pci
|
||||||
|
# USB passthrough, might need root privileges
|
||||||
|
#-device usb-host,vendorid=0xffff,productid=0xffff
|
||||||
|
)
|
||||||
|
|
||||||
|
"${CMD[@]}"
|
@ -1,5 +1,16 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
function ask_yn() {
|
||||||
|
local ans
|
||||||
|
|
||||||
|
printf "$1 (Y/n) " >&2
|
||||||
|
read -r ans
|
||||||
|
case "${ans,,}" in
|
||||||
|
y*|'') return 0 ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
RAM="$(free -g | awk '/^Mem:/{print $2 - 2}')"
|
RAM="$(free -g | awk '/^Mem:/{print $2 - 2}')"
|
||||||
|
|
||||||
if [ "$RAM" -le 2 ]; then RAM=2
|
if [ "$RAM" -le 2 ]; then RAM=2
|
||||||
@ -11,12 +22,12 @@ CMD=(
|
|||||||
qemu-system-x86_64
|
qemu-system-x86_64
|
||||||
-accel kvm
|
-accel kvm
|
||||||
-M q35
|
-M q35
|
||||||
# usb
|
|
||||||
-device qemu-xhci
|
|
||||||
-cpu host
|
-cpu host
|
||||||
-m "2G,maxmem=$RAM"
|
-m "2G,maxmem=$RAM"
|
||||||
-vga virtio
|
-vga virtio
|
||||||
-drive if=virtio,file=hda.qcow2
|
-drive if=virtio,file=hda.qcow2
|
||||||
|
# usb
|
||||||
|
-device qemu-xhci
|
||||||
# shared memory
|
# shared memory
|
||||||
-object memory-backend-ram,id=mem,size=2G,share=on
|
-object memory-backend-ram,id=mem,size=2G,share=on
|
||||||
-numa node,memdev=mem
|
-numa node,memdev=mem
|
15
win2k22/create.sh
Executable file → Normal file
15
win2k22/create.sh
Executable file → Normal file
@ -1,20 +1,19 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
. ./lib.sh
|
. ../lib.sh
|
||||||
|
|
||||||
if [ -f hda.qcow2 ]; then
|
if ! [ -f win2k22.iso ] || ! [ -f virtio.iso ]; then
|
||||||
echo -e "Disk file exists. Are you sure you don't want" \
|
ask_yn "win2k22.iso and/or virtio.iso not found, download?" \
|
||||||
"\e[1m\e[31m./run.sh\e[0m?\nCtrl-C to interrupt" >&2
|
&& bash ./download_isos.sh \
|
||||||
read -r
|
|| exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
qemu-img create -f qcow2 hda.qcow2 40G
|
qemu-img create -f qcow2 hda.qcow2 40G
|
||||||
|
|
||||||
CMD=(
|
CMD=(
|
||||||
"${CMD[@]}"
|
"${CMD[@]}"
|
||||||
-drive file=win2k22.iso,index=1,media=cdrom,readonly=on
|
-drive file=win2k22.iso,media=cdrom,readonly=on
|
||||||
-drive file=virtio.iso,index=2,media=cdrom,readonly=on
|
-drive file=virtio.iso,media=cdrom,readonly=on
|
||||||
#-drive file.driver=http,file.filename=http://example.com/image.qcow2
|
|
||||||
-nic none # you don't want internet access for a windows installation
|
-nic none # you don't want internet access for a windows installation
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
. ./lib.sh
|
. ../lib.sh
|
||||||
|
|
||||||
|
if ! [ -f hda.qcow2 ]; then
|
||||||
|
ask_yn "hda.qcow2 not found, create?" \
|
||||||
|
&& bash ./create.sh \
|
||||||
|
|| exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
CMD=(
|
CMD=(
|
||||||
"${CMD[@]}"
|
"${CMD[@]}"
|
||||||
-nic user,model=virtio-net-pci
|
-nic user,model=virtio-net-pci
|
||||||
# usb passthrough, might need root privileges
|
# USB passthrough, might need root privileges
|
||||||
-device usb-host,vendorid=0x058f,productid=0x6387
|
#-device usb-host,vendorid=0xffff,productid=0xffff
|
||||||
)
|
)
|
||||||
|
|
||||||
"${CMD[@]}"
|
"${CMD[@]}"
|
||||||
|
Loading…
Reference in New Issue
Block a user