浏览代码

Update haos-vm-v4.sh

add option to set machine type
tteckster 2 年之前
父节点
当前提交
3dacb89b25
共有 1 个文件被更改,包括 20 次插入3 次删除
  1. 20 3
      vm/haos-vm-v4.sh

+ 20 - 3
vm/haos-vm-v4.sh

@@ -91,6 +91,9 @@ function default_settings() {
         BRANCH=${STABLE}
         BRANCH=${STABLE}
         echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}"
         echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}"
         VMID=$NEXTID
         VMID=$NEXTID
+        echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}"
+        FORMAT=",efitype=4m"
+        MACHINE=""
         echo -e "${DGN}Using Hostname: ${BGN}haos${STABLE}${CL}"
         echo -e "${DGN}Using Hostname: ${BGN}haos${STABLE}${CL}"
         HN=haos${STABLE}
         HN=haos${STABLE}
         echo -e "${DGN}Allocated Cores: ${BGN}2${CL}"
         echo -e "${DGN}Allocated Cores: ${BGN}2${CL}"
@@ -122,6 +125,20 @@ if [ -z $VMID ]; then VMID="$NEXTID"; echo -e "${DGN}Virtual Machine: ${BGN}$VMI
 else
 else
   if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi;
   if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi;
 fi
 fi
+MACH=$(whiptail --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 8 58 2 \
+"i440fx" "Machine i440fx" ON \
+"q35" "Machine q35" OFF \
+3>&1 1>&2 2>&3)
+exitstatus=$?
+if [ $MACH = q35 ]; then
+  echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
+  FORMAT=",format=raw"
+  MACHINE=" -machine q35"
+  else
+  echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
+  FORMAT=",efitype=4m"
+  MACHINE=""
+fi
 VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
 VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
 exitstatus=$?
 exitstatus=$?
 if [ -z $VM_NAME ]; then HN="haos${BRANCH}"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}";
 if [ -z $VM_NAME ]; then HN="haos${BRANCH}"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}";
@@ -255,12 +272,12 @@ for i in {0,1}; do
 done
 done
 msg_ok "Extracted KVM Disk Image"
 msg_ok "Extracted KVM Disk Image"
 msg_info "Creating HAOS VM"
 msg_info "Creating HAOS VM"
-qm create $VMID -agent 1 -tablet 0 -localtime 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $HN -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN \
+qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $HN -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN \
   -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
   -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
 pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
 pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
 qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
 qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
-qm set $VMID \
-  -efidisk0 ${DISK0_REF},efitype=4m,size=4M \
+  qm set $VMID \
+  -efidisk0 ${DISK0_REF}${FORMAT} \
   -scsi0 ${DISK1_REF},discard=on,size=32G,ssd=1 >/dev/null
   -scsi0 ${DISK1_REF},discard=on,size=32G,ssd=1 >/dev/null
 qm set $VMID \
 qm set $VMID \
   -boot order=scsi0 >/dev/null
   -boot order=scsi0 >/dev/null