melawy-archiso-config/boot/melawy1-systemd-boot.sh

72 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
name=$(basename -s .sh $0)
numberofcores=$(grep -c ^processor /proc/cpuinfo)
virt_cpu=$(( $numberofcores/2 ))
smp=$(( $virt_cpu / 2 ))
sockets=$(( $virt_cpu / 2 ))
mem=$(expr $(cat /proc/meminfo | grep "MemFree" | awk '{print $2}') / 1024 - $(( 2 * 1024 )) )
if [[ $mem -lt 6144 ]]; then
mem=6144
fi
fd="$name-OVMF_VARS.fd"
if [ ! -f "./fd/$fd" ]; then
cp -av -- '/usr/share/edk2-ovmf/x64/OVMF_VARS.fd' "./fd/$fd"
fi
iso=$(find ./iso -name "*.iso" | grep -i "melawy" | tail -n 1)
qcow2="$name.qcow2"
if [ ! -f "./qcow2/$qcow2" ]; then
qemu-img create -f qcow2 "./qcow2/$qcow2" 50G
fi
echo "CPU: $virt_cpu; MEM: $mem; ISO: $iso; DISK: $qcow2; NVRAM: $fd"
random_num=$((1 + $RANDOM % 100))
qemu-system-x86_64 \
-name MelawyLinux_$random_num,process=archiso_$random_num,guest=MelawyLinux_$random_num,debug-threads=on \
-drive "if=pflash,format=raw,unit=0,file=/usr/share/edk2-ovmf/x64/OVMF_CODE.fd,read-only=on" \
-drive "if=pflash,format=raw,unit=1,file=./fd/$fd" \
-global "driver=cfi.pflash01,property=secure,value=off" \
-global ICH9-LPC.disable_s3=1 \
-cdrom ${iso} \
-drive file="./qcow2/$qcow2,index=0,media=disk,format=qcow2" \
-boot order=d,menu=on,reboot-timeout=5000 \
-smbios type=0,uefi=on \
-smp $smp,sockets=$sockets,cores=1,threads=1 \
-rtc base=utc,driftfix=slew \
-cpu host,migratable=on \
-m "size=$mem,slots=0,maxmem=$(($mem*1024*1024))" \
-usb \
-k en-us \
-vga virtio \
-display gtk,full-screen=off,grab-on-hover=on,show-cursor=on,window-close=on \
-audiodev pipewire,id=snd0 \
-device ich9-intel-hda \
-device hda-output,audiodev=snd0 \
-device virtio-net-pci,romfile=,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::60022-:22 \
-machine type=pc-q35-8.1,smm=on,accel=kvm,usb=on,vmport=off,dump-guest-core=off,hpet=off,acpi=on,pcspk-audiodev=snd0 \
-enable-kvm \
-msg timestamp=on
# -netdev user,id=net0 \
# -drive file=shared.img,index=1,media=disk,format=raw \
# -netdev user,id=net0,hostfwd=tcp::60022-:22 \
# -serial stdio
# -m 8192 \
# -display sdl,gl=on,show-cursor=on,window-close=on \
# -full-screen \
# -audiodev pa,id=snd0 \
# -net nic,vlan=0 -net user,vlan=0
# -net nic,vlan=0 -net user,vlan=0 -netdev user,id=user.0 -device e1000,netdev=user.0