From 074c60f99a099df0c20f2d0a3536f211f74f1212 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 12:26:43 +0200 Subject: [PATCH 01/15] Update install.sh --- src/install.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/install.sh b/src/install.sh index 24e12212..852cdad5 100644 --- a/src/install.sh +++ b/src/install.sh @@ -4,11 +4,6 @@ set -Eeuo pipefail file=$(find / -maxdepth 1 -type f -iname boot.iso | head -n 1) [ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso | head -n 1) -if [ ! -s "$file" ] && [[ "${BOOT,,}" != "http"* ]]; then - base=$(basename "$BOOT") - file="$STORAGE/$base" -fi - if [ -f "$file" ] && [ -s "$file" ]; then BOOT="$file" return 0 From fbd769e0f7c1b751bf5122fd513dda910c254b6b Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 13:51:41 +0200 Subject: [PATCH 02/15] Update network.sh --- src/network.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network.sh b/src/network.sh index ceb688b9..43eb5420 100644 --- a/src/network.sh +++ b/src/network.sh @@ -328,8 +328,8 @@ if [[ "$DHCP" == [Yy1]* ]]; then ! 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)!" + if [[ "$IP" == "172."* ]]; then + warn "your IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!" fi # Configuration for DHCP IP @@ -337,7 +337,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then else - if [[ "$GATEWAY" != "172."* ]] && [[ "$GATEWAY" != "10.8"* ]] && [[ "$GATEWAY" != "10.9"* ]]; then + if [[ "$IP" != "172."* ]] && [[ "$IP" != "10.8"* ]] && [[ "$IP" != "10.9"* ]]; then ! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19 fi From 206082b0297b7cd69ec017f09b13501590253eea Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 14:26:51 +0200 Subject: [PATCH 03/15] Update install.sh --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index 852cdad5..6b5bb31c 100644 --- a/src/install.sh +++ b/src/install.sh @@ -9,7 +9,7 @@ if [ -f "$file" ] && [ -s "$file" ]; then return 0 fi -if [ -z "$BOOT" ]; then +if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then hasDisk && return 0 error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64 fi From 1621974279e92dfc891d7462145282c8a26ddf60 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 14:32:18 +0200 Subject: [PATCH 04/15] Update install.sh --- src/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index 6b5bb31c..75ce8b35 100644 --- a/src/install.sh +++ b/src/install.sh @@ -15,7 +15,7 @@ if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then fi base=$(basename "$BOOT") -file="$STORAGE/$base" +file="$STORAGE/$base" if [ -f "$file" ] && [ -s "$file" ]; then BOOT="$file" @@ -25,7 +25,7 @@ fi base=$(basename "${BOOT%%\?*}") : "${base//+/ }"; printf -v base '%b' "${_//%/\\x}" base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g') -file="$STORAGE/$base" +file="$STORAGE/$base" if [ -f "$file" ] && [ -s "$file" ]; then BOOT="$file" From 92c51051cf46e6c26f4cbf31d795dec1aa9a53a5 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 14:59:35 +0200 Subject: [PATCH 05/15] build: Add genisoimage tools --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 06d6e109..22983e4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,7 @@ RUN set -eu && \ dnsmasq \ net-tools \ qemu-utils \ + genisoimage \ ca-certificates \ netcat-openbsd \ qemu-system-x86 && \ From 053e2057830b46111a286c8ad8ee05173e32e962 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 15:40:10 +0200 Subject: [PATCH 06/15] Update install.sh --- src/install.sh | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/install.sh b/src/install.sh index 75ce8b35..2f6617f6 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,13 +1,26 @@ #!/usr/bin/env bash set -Eeuo pipefail -file=$(find / -maxdepth 1 -type f -iname boot.iso | head -n 1) -[ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso | head -n 1) +detect () { + local dir="" + local file="$1" + [ ! -f "$file" ] && return 1 + [ ! -s "$file" ] && return 1 + + dir=$(isoinfo -f -i "$file") + + # Automaticly detect EFI-compatible ISO's + if echo "${dir^^}" | grep -qx "/BOOTMGR.EFI;1\|/EFI/BOOT/BOOTX64.EFI;1\|/EFI/BOOT/BOOTX86.EFI;1"; then + [ -z "$BOOT_MODE" ] && BOOT_MODE="uefi" + fi -if [ -f "$file" ] && [ -s "$file" ]; then - BOOT="$file" + BOOT="$file" return 0 -fi +} + +file=$(find / -maxdepth 1 -type f -iname boot.iso | head -n 1) +[ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso | head -n 1) +detect "$file" && return 0 if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then hasDisk && return 0 @@ -15,23 +28,13 @@ if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then fi base=$(basename "$BOOT") -file="$STORAGE/$base" - -if [ -f "$file" ] && [ -s "$file" ]; then - BOOT="$file" - return 0 -fi +detect "$STORAGE/$base" && return 0 base=$(basename "${BOOT%%\?*}") : "${base//+/ }"; printf -v base '%b' "${_//%/\\x}" base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g') -file="$STORAGE/$base" - -if [ -f "$file" ] && [ -s "$file" ]; then - BOOT="$file" - return 0 -fi +detect "$STORAGE/$base" && return 0 TMP="$STORAGE/${base%.*}.tmp" rm -f "$TMP" @@ -63,5 +66,6 @@ if ((size<100000)); then fi mv -f "$TMP" "$file" +! detect "$STORAGE/$base" && exit 63 return 0 From bb8d9faccbf2e5dbf2d765e6ab802faf9a788b40 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 15:41:26 +0200 Subject: [PATCH 07/15] Update install.sh --- src/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index 2f6617f6..ffabb32a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -9,12 +9,12 @@ detect () { dir=$(isoinfo -f -i "$file") - # Automaticly detect EFI-compatible ISO's + # Automaticly detect UEFI-compatible ISO's if echo "${dir^^}" | grep -qx "/BOOTMGR.EFI;1\|/EFI/BOOT/BOOTX64.EFI;1\|/EFI/BOOT/BOOTX86.EFI;1"; then [ -z "$BOOT_MODE" ] && BOOT_MODE="uefi" fi - BOOT="$file" + BOOT="$file" return 0 } From e046836a700b510daacf6df7c8873781f1f574ac Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 15:44:19 +0200 Subject: [PATCH 08/15] Update install.sh --- src/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index ffabb32a..149e5bf4 100644 --- a/src/install.sh +++ b/src/install.sh @@ -33,8 +33,8 @@ detect "$STORAGE/$base" && return 0 base=$(basename "${BOOT%%\?*}") : "${base//+/ }"; printf -v base '%b' "${_//%/\\x}" base=$(echo "$base" | sed -e 's/[^A-Za-z0-9._-]/_/g') - detect "$STORAGE/$base" && return 0 + TMP="$STORAGE/${base%.*}.tmp" rm -f "$TMP" @@ -65,7 +65,7 @@ if ((size<100000)); then error "Invalid ISO file: Size is smaller than 100 KB" && exit 62 fi -mv -f "$TMP" "$file" +mv -f "$TMP" "$STORAGE/$base" ! detect "$STORAGE/$base" && exit 63 return 0 From 69241082431763cf93982743a18fa9c806d143d3 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 15:47:42 +0200 Subject: [PATCH 09/15] Update install.sh --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index 149e5bf4..1ff61b02 100644 --- a/src/install.sh +++ b/src/install.sh @@ -11,7 +11,7 @@ detect () { # Automaticly detect UEFI-compatible ISO's if echo "${dir^^}" | grep -qx "/BOOTMGR.EFI;1\|/EFI/BOOT/BOOTX64.EFI;1\|/EFI/BOOT/BOOTX86.EFI;1"; then - [ -z "$BOOT_MODE" ] && BOOT_MODE="uefi" + [ -z "${BOOT_MODE:-}" ] && BOOT_MODE="uefi" fi BOOT="$file" From ea413f2f5588631c6489d6330692805a5bf9a4e4 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 15:57:56 +0200 Subject: [PATCH 10/15] Update install.sh --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index 1ff61b02..c8ac3fb6 100644 --- a/src/install.sh +++ b/src/install.sh @@ -10,7 +10,7 @@ detect () { dir=$(isoinfo -f -i "$file") # Automaticly detect UEFI-compatible ISO's - if echo "${dir^^}" | grep -qx "/BOOTMGR.EFI;1\|/EFI/BOOT/BOOTX64.EFI;1\|/EFI/BOOT/BOOTX86.EFI;1"; then + if echo "${dir^^}" | grep -q "^/EFI"; then [ -z "${BOOT_MODE:-}" ] && BOOT_MODE="uefi" fi From 8bb0731c1d28c6519a190f7c6838e7c6677b6d16 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 16:06:50 +0200 Subject: [PATCH 11/15] docs: Readme --- readme.md | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/readme.md b/readme.md index df216d27..f99f9eb9 100644 --- a/readme.md +++ b/readme.md @@ -103,23 +103,14 @@ kubectl apply -f kubernetes.yml By default, the machine makes use of `virtio-scsi` disks for performance reasons, and even though most Linux kernels include drivers for them, there are other operating systems that do not. - If your ISO fails to boot because of this, you can add this to your compose file: + If your ISO fails to boot because of this, you can add this to your compose file to use `virtio-blk` instead: ```yaml environment: DISK_TYPE: "blk" ``` - This will use `virtio-blk` devices instead. If it still fails to boot, you can set the value to `ide` to use IDE disks which every OS will support, at the cost of performance. - -* ### How do I boot with UEFI? - - To enable UEFI booting, add the following line to your compose file: - - ```yaml - environment: - BOOT_MODE: "uefi" - ``` + If it still fails to boot, you can set the value to `ide` to emulate a IDE drive which is compatible with almost every system. * ### How do I boot ARM images? @@ -127,14 +118,7 @@ kubectl apply -f kubernetes.yml * ### How do I boot Windows? - To enable Windows booting, add the following line to your compose file: - - ```yaml - environment: - BOOT_MODE: "windows" - ``` - - But you might want to give [dockur/windows](https://github.com/dockur/windows) a try instead, as it includes all the drivers required during installation amongst many other features. + Use [dockur/windows](https://github.com/dockur/windows) instead, as it includes all the drivers required during installation, amongst many other features. * ### How do I verify if my system supports KVM? From f133a08a8ff313dd7844a80b00b894c23cbb583d Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 16:14:57 +0200 Subject: [PATCH 12/15] Update readme.md --- readme.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index f99f9eb9..7a886631 100644 --- a/readme.md +++ b/readme.md @@ -99,26 +99,26 @@ kubectl apply -f kubernetes.yml Replace the example path `/home/user/example.iso` with the filename of the desired ISO file, the value of `BOOT` will be ignored in this case. -* ### How do I boot without SCSI support? +* ### How do I boot ARM images? - By default, the machine makes use of `virtio-scsi` disks for performance reasons, and even though most Linux kernels include drivers for them, there are other operating systems that do not. + You can use [qemu-arm](https://github.com/qemus/qemu-arm/) to run ARM64-based images. - If your ISO fails to boot because of this, you can add this to your compose file to use `virtio-blk` instead: +* ### How do I boot Windows? - ```yaml - environment: - DISK_TYPE: "blk" - ``` + Use [dockur/windows](https://github.com/dockur/windows) instead, as it includes all the drivers required during installation, amongst many other features. - If it still fails to boot, you can set the value to `ide` to emulate a IDE drive which is compatible with almost every system. +* ### How do I boot without SCSI drivers? -* ### How do I boot ARM images? + By default, the machine makes use of `virtio-scsi` disks for performance reasons, and even though most Linux kernels include the necessary driver for this device, for some other operating systems that may not always be the case. - You can use [qemu-arm](https://github.com/qemus/qemu-arm/) to run ARM64-based images. + If your ISO fails to boot because of this, you can modify your compose file to use `virtio-blk` instead: -* ### How do I boot Windows? + ```yaml + environment: + DISK_TYPE: "blk" + ``` - Use [dockur/windows](https://github.com/dockur/windows) instead, as it includes all the drivers required during installation, amongst many other features. + If it still fails to boot, you can set the value to `ide` to emulate a IDE drive, which is slow but compatible with almost every system. * ### How do I verify if my system supports KVM? From 490f1150df550fa26e805e2eb20f45477617c37c Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 16:28:25 +0200 Subject: [PATCH 13/15] Update boot.sh --- src/boot.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/boot.sh b/src/boot.sh index 2f808103..b49ef793 100644 --- a/src/boot.sh +++ b/src/boot.sh @@ -16,12 +16,6 @@ if [[ "${BOOT_MODE,,}" == "windows"* ]]; then BOOT_OPTS="$BOOT_OPTS -global ICH9-LPC.disable_s3=1" BOOT_OPTS="$BOOT_OPTS -global ICH9-LPC.disable_s4=1" - if [ -e /sys/module/kvm/parameters/ignore_msrs ]; then - if [ "$(cat /sys/module/kvm/parameters/ignore_msrs)" == "N" ]; then - echo 1 | tee /sys/module/kvm/parameters/ignore_msrs > /dev/null 2>&1 || true - fi - fi - fi case "${BOOT_MODE,,}" in From 2e07987d542e1b7b7e6b27e2c49b08468c6520b4 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 16:30:50 +0200 Subject: [PATCH 14/15] Update proc.sh --- src/proc.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/proc.sh b/src/proc.sh index 7e14d572..22d5b102 100644 --- a/src/proc.sh +++ b/src/proc.sh @@ -60,6 +60,12 @@ if [[ "$KVM" != [Nn]* ]]; then CPU_FEATURES="$CPU_FEATURES,migratable=no" fi + if [ -e /sys/module/kvm/parameters/ignore_msrs ]; then + if [ "$(cat /sys/module/kvm/parameters/ignore_msrs)" == "N" ]; then + echo 1 | tee /sys/module/kvm/parameters/ignore_msrs > /dev/null 2>&1 || true + fi + fi + if [[ "$HV" != [Nn]* ]] && [[ "${BOOT_MODE,,}" == "windows"* ]]; then HV_FEATURES="+hypervisor,hv_passthrough" From 681d5c0a456f2f62301d8ef8161f70bf827f2999 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 22 May 2024 17:05:55 +0200 Subject: [PATCH 15/15] Update network.sh --- src/network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network.sh b/src/network.sh index 43eb5420..170ee136 100644 --- a/src/network.sh +++ b/src/network.sh @@ -329,7 +329,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then ! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19 if [[ "$IP" == "172."* ]]; then - warn "your IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!" + warn "container IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!" fi # Configuration for DHCP IP