Unverified Commit 72ae2e63 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Select Operating Systems (#688)

parent 29487e54
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ services:
    image: qemux/qemu
    container_name: qemu
    environment:
      BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
      BOOT: "mint"
    devices:
      - /dev/kvm
      - /dev/net/tun
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ spec:
        image: qemux/qemu
        env:
        - name: BOOT
          value: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
          value: "mint"
        - name: DISK_SIZE
          value: "16G"
        ports:
+84 −34
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ services:
    image: qemux/qemu
    container_name: qemu
    environment:
      BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
      BOOT: "mint"
    devices:
      - /dev/kvm
      - /dev/net/tun
@@ -48,7 +48,7 @@ services:
Via Docker CLI:

```bash
docker run -it --rm --name qemu -e "BOOT=http://example.com/image.iso" -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v ${PWD:-.}/qemu:/storage --stop-timeout 120 qemux/qemu
docker run -it --rm --name qemu -e "BOOT=mint" -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v ${PWD:-.}/qemu:/storage --stop-timeout 120 qemux/qemu
```

Via Kubernetes:
@@ -73,7 +73,7 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu/refs/heads/master/

  Very simple! These are the steps:

  - Set the `BOOT` environment variable to the URL of any [disk image](#what-image-formats-are-supported) you want to install.
  - Set the `BOOT` variable to the [operating system](#how-do-i-select-the-operating-system) you want to install.

  - Start the container and connect to [port 8006](http://localhost:8006) using your web browser.

@@ -81,7 +81,51 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu/refs/heads/master/

  Enjoy your brand new machine, and don't forget to star this repo!

### What image formats are supported?
### How do I select the operating system?

  You can use the `BOOT` environment variable in order to specify the operating system to be installed:

  ```yaml
  environment:
    BOOT: "mint"
  ```

  Select from the values below:
  
  | **Value**  | **Operating System** | **Size** |
  |---|---|---|
  | `alma`     | Alma Linux      | 2.2 GB  |
  | `alpine`   | Alpine Linux    | 60 MB    |
  | `arch`     | Arch Linux      | 1.2 GB   |
  | `cachy`    | CachyOS         | 2.6 GB   |
  | `centos`   | CentOS Stream   | 7.0 GB   |
  | `debian`   | Debian          | 3.3 GB   |
  | `endeavour`| EndeavourOS     | 3.0 GB   |
  | `fedora`   | Fedora          | 2.3 GB   |
  | `gentoo`   | Gentoo          | 3.6 GB   |
  | `kali`     | Kali Linux      | 3.8 GB   |
  | `kubuntu`  | Kubuntu         | 4.4 GB   |
  | `mint`     | Linux Mint      | 2.8 GB   |
  | `manjaro`  | Manjaro         | 4.1 GB   |
  | `mx`       | MX Linux        | 2.2 GB   |
  | `nixos`    | NixOS           | 2.4 GB   |
  | `opensuse` | OpenSUSE        | 1.0 GB   |
  | `oracle`   | Oracle Linux    | 1.1 GB   |
  | `rocky`    | Rocky Linux     | 2.1 GB   |
  | `slack`    | Slackware       | 3.7 GB   |
  | `tails`    | Tails           | 1.5 GB   |
  | `ubuntu`   | Ubuntu Desktop  | 6.0 GB   |
  | `ubuntus`  | Ubuntu Server   | 3.0 GB   |
  | `xubuntu`  | Xubuntu         | 4.0 GB   |
  
### How can I use my own image?

  If you want to boot an operating system that is not in the list, you can set the `BOOT` variable to the URL of the image:

  ```yaml
  environment:
    BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
  ```

  The `BOOT` URL accepts files in any of the following formats:
  
@@ -96,8 +140,16 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu/refs/heads/master/
  | `.vhdx`       | Hyper-V     |
  | `.vdi`        | VirtualBox  |

> [!TIP]
> It will also accept `.img.gz`, `.qcow2.xz`, `.iso.zip` and many more, as it automaticly extracts compressed files.
  It will also accept `.img.gz`, `.qcow2.xz`, `.iso.zip` and many more, as it automaticly extracts compressed files.

  You can also use a local image file directly, and skip the download altogether, by binding it in your compose file like this:
  
  ```yaml
  volumes:
    - ./example.iso:/boot.iso
  ```

  This way you can supply a `/boot.iso`, `/boot.img` or a `/boot.qcow2` file. The value of `BOOT` will be ignored in this case.

### How do I change the storage location?

@@ -122,17 +174,18 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu/refs/heads/master/
> [!TIP]
> This can also be used to resize the existing disk to a larger capacity without any data loss.

### How do I boot a local image?
### 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.

  You can use a local image file directly, and skip the download altogether, by binding it in your compose file:
  If you want to adjust this, you can specify the desired amount using the following environment variables:

  ```yaml
  volumes:
    - ./example.iso:/boot.iso
  environment:
    RAM_SIZE: "4G"
    CPU_CORES: "4"
  ```

  You can supply a `boot.iso`, `boot.img` or `boot.qcow2` file by replacing the example path `./example.iso` with the filename of your desired image. The value of `BOOT` will be ignored in this case.

### How do I boot ARM64 images?

  You can use the [qemu-arm](https://github.com/qemus/qemu-arm/) container to run ARM64-based images.
@@ -145,31 +198,28 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu/refs/heads/master/

  Use [dockur/macos](https://github.com/dockur/macos) instead, as it uses all the right settings and automaticly downloads the installation files.

### How do I boot without VirtIO drivers?

  By default, the machine makes use of `virtio-scsi` drives for performance reasons, and even though most Linux kernels bundle the necessary driver for this device, that may not always be the case for other operating systems.
### How do I boot without UEFI?

  If your machine fails to detect the hard drive, you can modify your compose file to use `virtio-blk` instead:
  By default, the machine will boot with UEFI enabled. If your OS does not support that, you can boot with a legacy BIOS:
  
  ```yaml
  environment:
    DISK_TYPE: "blk"
    BOOT_MODE: "legacy"
  ```
  
  If it still fails to boot, you can set the value to `ide` to emulate a IDE drive, which is relatively slow but requires no drivers and is compatible with almost every system.

### How do I change the amount of CPU or RAM?
### How do I boot without VirtIO drivers?

  By default, the container will be allowed to use a maximum of 1 CPU core and 1 GB of RAM.
  By default, the machine makes use of `virtio-scsi` drives for performance reasons, and even though most Linux kernels bundle the necessary driver for this device, that may not always be the case for other operating systems.

  If you want to adjust this, you can specify the desired amount using the following environment variables:
  If your machine fails to detect the hard drive, you can modify your compose file to use `virtio-blk` instead:

  ```yaml
  environment:
    RAM_SIZE: "4G"
    CPU_CORES: "4"
    DISK_TYPE: "blk"
  ```

  If it still fails to boot, you can set the value to `ide` to emulate a IDE drive, which is relatively slow but requires no drivers and is compatible with almost every system.

### How do I verify if my system supports KVM?

  Only Linux and Windows 11 support KVM virtualization, macOS and Windows 10 do not unfortunately.

src/define.sh

0 → 100644
+97 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
set -Eeuo pipefail

getURL() {
  local id="${1/ /}"
  local ret="$2"
  local url=""
  local name=""

  case "${id,,}" in
    "alma" )
      name="AlmaLinux"
      url="https://repo.almalinux.org/almalinux/9/live/x86_64/AlmaLinux-9.5-x86_64-Live-GNOME.iso" ;;
    "alpine" )
      name="Alpine Linux"
      url="https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso" ;;
    "arch" )
      name="Arch Linux"
      url="https://geo.mirror.pkgbuild.com/iso/2025.03.01/archlinux-x86_64.iso" ;;
    "cachy" | "cachyos" )
      name="CachyOS"
      url="https://cdn77.cachyos.org/ISO/desktop/250202/cachyos-desktop-linux-250202.iso" ;;
    "centos" )
      name="CentOS Stream"
      url="https://mirrors.xtom.de/centos-stream/10-stream/BaseOS/x86_64/iso/CentOS-Stream-10-latest-x86_64-dvd1.iso" ;;
    "debian" )
      name="Debian"
      url="https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-12.9.0-amd64-gnome.iso" ;;
    "endeavour" | "endeavouros" )
      name="EndeavourOS"
      url="https://mirrors.gigenet.com/endeavouros/iso/EndeavourOS_Mercury-2025.02.08.iso" ;;
    "fedora" )
      name="Fedora Linux"
      url="https://download.fedoraproject.org/pub/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-41-1.4.iso" ;;
    "gentoo" )
      name="Gentoo Linux"
      url="https://distfiles.gentoo.org/releases/amd64/autobuilds/20250309T170330Z/livegui-amd64-20250309T170330Z.iso" ;;
    "kali" )
      name="Kali Linux"
      url="https://cdimage.kali.org/kali-2024.4/kali-linux-2024.4-live-amd64.iso" ;;
    "kubuntu" )
      name="Kubuntu"
      url="https://cdimage.ubuntu.com/kubuntu/releases/24.10/release/kubuntu-24.10-desktop-amd64.iso" ;;
    "macos" | "osx" )
      name="macOS"
      error "To install $name use: https://github.com/dockur/macos" && return 1 ;;
    "mint" | "linuxmint" )
      name="Linux Mint"
      url="https://mirrors.layeronline.com/linuxmint/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso" ;;
    "manjaro" )
      name="Manjaro"
      url="https://download.manjaro.org/kde/24.2.1/manjaro-kde-24.2.1-241216-linux612.iso" ;;
    "mx" )
      name="MX Linux"
      url="https://mirror.umd.edu/mxlinux-iso/MX/Final/Xfce/MX-23.5_x64.iso" ;;
    "nixos" )
      name="NixOS"
      url="https://channels.nixos.org/nixos-24.11/latest-nixos-gnome-x86_64-linux.iso" ;;
    "opensuse" | "suse" )
      name="OpenSUSE"
      url="https://download.opensuse.org/distribution/leap/15.0/live/openSUSE-Leap-15.0-GNOME-Live-x86_64-Current.iso" ;;
    "oracle" )
      name="Oracle Linux"
      url="https://yum.oracle.com/ISOS/OracleLinux/OL9/u5/x86_64/OracleLinux-R9-U5-x86_64-boot.iso" ;;
    "rocky" )
      name="Rocky Linux"
      url="https://dl.rockylinux.org/pub/rocky/9/live/x86_64/Rocky-9-Workstation-x86_64-latest.iso" ;;
    "slack" | "slackware" )
      name="Slackware"
      url="https://slackware.nl/slackware-live/slackware64-15.0-live/slackware64-live-15.0.iso" ;;
    "tails" )
      name="Tails"
      url="https://download.tails.net/tails/stable/tails-amd64-6.13/tails-amd64-6.13.img" ;;
    "ubuntu" | "ubuntu-desktop" )
      name="Ubuntu Desktop"
      url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-desktop-amd64.iso" ;;
    "ubuntus" | "ubuntu-server")
      name="Ubuntu Server"
      url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-live-server-amd64.iso" ;;
    "windows" )
      name="Windows"
      error "To install $name use: https://github.com/dockur/windows" && return 1 ;;
    "xubuntu" )
      name="Xubuntu"
      url="https://mirror.us.leaseweb.net/ubuntu-cdimage/xubuntu/releases/24.04/release/xubuntu-24.04.2-desktop-amd64.iso" ;;
  esac

  case "${ret,,}" in
    "test" ) ;;
    "name" ) echo "$name" ;;
    *) echo "$url";;
  esac

  return 0
}

return 0
+6 −2
Original line number Diff line number Diff line
@@ -610,10 +610,14 @@ DISK4_FILE="/storage4/${DISK_NAME}4"
if [ -z "$DISK_FMT" ]; then
  if [ -f "$DISK1_FILE.qcow2" ]; then
    DISK_FMT="qcow2"
  else
    if [[ "$BOOT" ==  *".qcow2" ]] && [ ! -f "$DISK1_FILE.img" ]; then
      DISK_FMT="qcow2"
    else
      DISK_FMT="raw"
    fi
  fi
fi

if [ -z "$ALLOCATE" ]; then
  ALLOCATE="N"
Loading