diff --git a/readme.md b/readme.md index 5092a30..65bb2ac 100644 --- a/readme.md +++ b/readme.md @@ -11,9 +11,11 @@ -QEMU in a docker container for running ARM-based virtual machines, for devices like the Raspberry Pi 5 and many others. +Docker container for running ARM-based virtual machines using QEMU, for devices like the Raspberry Pi 5 and many others. -It uses high-performance QEMU options (like KVM acceleration, kernel-mode networking, IO threading, etc.) to achieve near-native speed. +It allows you to create VM's which behave just like normal containers, meaning you can manage them using all your existing tools (like Portainer) and configure them in a language (YAML) you are already familiar with. + +This greatly reduces the learning curve and also eliminates the need for a dedicated Proxmox or ESXi server in many cases. It uses high-performance QEMU options (like KVM acceleration, kernel-mode networking, IO threading, etc.) to achieve near-native speed. Note: for KVM acceleration you need a Linux-based operating system, as it's not available on MacOS unfortunately. @@ -121,17 +123,6 @@ kubectl apply -f kubernetes.yml DISK_TYPE: "blk" ``` -* ### How do I verify if my system supports KVM? - - To verify if your system supports KVM, run the following commands: - - ```bash - sudo apt install cpu-checker - sudo kvm-ok - ``` - - If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS. - * ### How do I change the amount of CPU or RAM? By default, the container will be allowed to use a maximum of 1 CPU core and 1 GB of RAM. @@ -143,7 +134,20 @@ kubectl apply -f kubernetes.yml RAM_SIZE: "4G" CPU_CORES: "4" ``` - + +* ### How do I verify if my system supports KVM? + + To verify that your system supports KVM, run the following commands: + + ```bash + sudo apt install cpu-checker + sudo kvm-ok + ``` + + If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check whether virtualization extensions are enabled in your BIOS. If you are running the container inside a VM instead of directly on the host, you will also need to enable nested virtualization in its settings. If you are using a cloud provider, you may be out of luck as most of them do not allow nested virtualization for their VPS's. If you are using MacOS, you are also out of luck, as only Linux and Windows support KVM. + + If you don't receive any error from `kvm-ok` at all, but the container still complains that `/dev/kvm` is missing, it might help to add `privileged: true` to your compose file (or `--privileged` to your `run` command), to rule out any permission issue. + * ### How do I assign an individual IP address to the container? By default, the container uses bridge networking, which shares the IP address with the host. diff --git a/src/disk.sh b/src/disk.sh index 341e380..11824ed 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -373,7 +373,8 @@ createDevice () { ;; "ide" ) result+=",if=none \ - -device ide-hd,drive=${DISK_ID},bus=ide.$DISK_INDEX,rotation_rate=$DISK_ROTATION${index}" + -device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS,iothread=io2 \ + -device ide-hd,drive=${DISK_ID},bus=ahci$DISK_INDEX.0,rotation_rate=$DISK_ROTATION${index}" echo "$result" ;; "blk" | "virtio-blk" ) @@ -416,7 +417,8 @@ addMedia () { ;; "ide" ) result+=",if=none \ - -device ide-cd,drive=${DISK_ID},bus=ide.${DISK_BUS}${index}" + -device ich9-ahci,id=ahci${DISK_BUS},addr=$DISK_ADDRESS,iothread=io2 \ + -device ide-cd,drive=${DISK_ID},bus=ahci${DISK_BUS}.0${index}" echo "$result" ;; "blk" | "virtio-blk" ) @@ -529,10 +531,30 @@ html "Initializing disks..." case "${DISK_TYPE,,}" in "ide" | "usb" | "scsi" | "blk" | "auto" ) ;; - * ) error "Invalid DISK_TYPE, value \"$DISK_TYPE\" is unrecognized!" && exit 80 ;; + * ) error "Invalid DISK_TYPE specified, value \"$DISK_TYPE\" is unrecognized!" && exit 80 ;; esac -[[ "${MACHINE,,}" != "virt" ]] && MEDIA_TYPE="ide" || MEDIA_TYPE="auto" +if [ -z "${MEDIA_TYPE:-}" ]; then + case "${DISK_TYPE,,}" in + "ide" | "usb" | "scsi" ) + if [[ "${MACHINE,,}" == "virt" ]]; then + MEDIA_TYPE="auto" + else + MEDIA_TYPE="$DISK_TYPE" + fi ;; + "blk" | "auto" ) + if [[ "${MACHINE,,}" != "virt" ]] && [[ "${MACHINE,,}" != "pc-i440fx-2"* ]]; then + MEDIA_TYPE="ide" + else + MEDIA_TYPE="auto" + fi ;; + esac +fi + +case "${MEDIA_TYPE,,}" in + "ide" | "usb" | "scsi" | "blk" | "auto" ) ;; + * ) error "Invalid MEDIA_TYPE specified, value \"$MEDIA_TYPE\" is unrecognized!" && exit 80 ;; +esac if [ -f "$BOOT" ] && [ -s "$BOOT" ]; then ADD_OPTS=$(addMedia "$BOOT" "$MEDIA_TYPE" "0" "$BOOT_INDEX" "0x5") @@ -543,7 +565,12 @@ DRIVERS="/drivers.iso" [ ! -f "$DRIVERS" ] || [ ! -s "$DRIVERS" ] && DRIVERS="$STORAGE/drivers.iso" if [ -f "$DRIVERS" ] && [ -s "$DRIVERS" ]; then - ADD_OPTS=$(addMedia "$DRIVERS" "$MEDIA_TYPE" "1" "" "0x6") + if [[ "${MACHINE,,}" != "virt" ]] && [[ "${MACHINE,,}" != "pc-i440fx-2"* ]]; then + DRIVER_TYPE="ide" + else + DRIVER_TYPE="auto" + fi + ADD_OPTS=$(addMedia "$DRIVERS" "$DRIVER_TYPE" "1" "" "0x6") DISK_OPTS+=" $ADD_OPTS" fi diff --git a/src/proc.sh b/src/proc.sh index a8c9cfd..97d2332 100644 --- a/src/proc.sh +++ b/src/proc.sh @@ -45,7 +45,7 @@ if [[ "$KVM" != [Nn]* ]]; then warn "you are using Windows 10 which has no KVM support, this will cause a major loss of performance." else error "KVM acceleration not available $KVM_ERR, this will cause a major loss of performance." - error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)." + error "See the FAQ on how to diagnose the cause, or continue without KVM by setting KVM=N (not recommended)." [[ "$DEBUG" != [Yy1]* ]] && exit 88 fi fi