Unverified Commit 30f02c25 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Add support for USB booting (#515)

parent e93986e2
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -391,18 +391,24 @@ addMedia () {
  local index=""
  local DISK_ID="cdrom$DISK_BUS"
  [ -n "$DISK_INDEX" ] && index=",bootindex=$DISK_INDEX"
  local result="-drive file=$DISK_FILE,id=$DISK_ID,if=none,format=raw,media=cdrom,readonly=on"
  local result="-drive file=$DISK_FILE,id=$DISK_ID,if=none,format=raw,readonly=on,media=cdrom"

  case "${DISK_TYPE,,}" in
    "usb" )
      result="$result \
      -device usb-storage,drive=${DISK_ID}${index}"
      -device usb-storage,drive=${DISK_ID}${index},removable=on"
      echo "$result"
      ;;
    "ide" | "blk" | "virtio-blk" )
    "ide" )
      result="$result \
      -device ide-cd,drive=${DISK_ID},bus=ide.${DISK_BUS}${index}"
      echo "$result"
      ;;
    "blk" | "virtio-blk" )
      result="$result \
      -device virtio-blk-pci,drive=${DISK_ID},scsi=off,bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2${index}"
      echo "$result"
      ;;
    "scsi" | "virtio-scsi" )
      result="$result \
      -device virtio-scsi-pci,id=${DISK_ID}b,bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2 \
@@ -516,7 +522,11 @@ DRIVERS="/drivers.iso"
[ ! -f "$DRIVERS" ] || [ ! -s "$DRIVERS" ] && DRIVERS="/run/drivers.iso"

if [ -f "$DRIVERS" ]; then
  if [[ "${BOOT_MODE,,}" != "legacy" ]] && [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
    DRIVER_OPTS=$(addMedia "$DRIVERS" "usb" "1" "" "0x6")
  else
    DRIVER_OPTS=$(addMedia "$DRIVERS" "ide" "1" "" "0x6")
  fi
  DISK_OPTS="$DISK_OPTS $DRIVER_OPTS"
fi

+3 −3
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ fi

if [[ "$DHCP" == [Yy1]* ]]; then

  ! checkOS && exit 19
  ! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19

  if [[ "$GATEWAY" == "172."* ]]; then
    warn "your gateway IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
@@ -337,8 +337,8 @@ if [[ "$DHCP" == [Yy1]* ]]; then

else

  if [[ "$GATEWAY" != "172."* ]] && [[ "$GATEWAY" != "10."* ]]; then
    ! checkOS && exit 19
  if [[ "$GATEWAY" != "172."* ]] && [[ "$GATEWAY" != "10.8"* ]] && [[ "$GATEWAY" != "10.9"* ]]; then
    ! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
  fi

  # Configuration for static IP