diff --git a/docker-compose.yml b/docker-compose.yml index 8aef6bc..cbbc42d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,6 @@ services: ports: - 5000:5000 volumes: - - /opt/dsm:/storage + - /var/dsm:/storage restart: on-failure stop_grace_period: 2m diff --git a/readme.md b/readme.md index 03ec6b3..1bf9d6f 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,7 @@ services: ports: - 5000:5000 volumes: - - /opt/dsm:/storage + - /var/dsm:/storage restart: on-failure stop_grace_period: 2m ``` @@ -65,14 +65,14 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti * ### How do I change the location of the virtual disk? - To change the virtual disk's location from the default Docker volume, include the following bind mount in your compose file: + To change the location of the virtual disk, include the following bind mount in your compose file: ```yaml volumes: - - /home/user/data:/storage + - /var/dsm:/storage ``` - Replace the example path `/home/user/data` with the desired storage folder. + Replace the example path `/var/dsm` with the desired storage folder. * ### How do I add multiple disks? @@ -170,7 +170,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti - 'c *:* rwm' ``` - Please note that even if you don't need DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface. + Please note that even if you don't want DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface. In that case just set a static IP from the DSM control panel after you enabled this mode. * ### How do I passthrough the GPU? diff --git a/src/cpu.sh b/src/cpu.sh index 1cad10a..0070fdc 100644 --- a/src/cpu.sh +++ b/src/cpu.sh @@ -31,7 +31,7 @@ if [[ "$ARCH" == "amd64" && "$KVM" != [Nn]* ]]; then if [ -n "$KVM_OPTS" ]; then if ! grep -qE '^flags.* (sse4_2)' /proc/cpuinfo; then - error "Your host CPU does not has the SSE4.2 instruction set that Virtual DSM requires to boot." + error "Your host CPU does not have the SSE4.2 instruction set that Virtual DSM requires to boot." error "Disable KVM by setting KVM=N to emulate a compatible CPU, at the cost of performance." [[ "$DEBUG" != [Yy1]* ]] && exit 89 fi diff --git a/src/disk.sh b/src/disk.sh index fee7afd..b04c2c2 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -3,11 +3,12 @@ set -Eeuo pipefail # Docker environment variables -: ${DISK_IO:='native'} # I/O Mode, can be set to 'native', 'threads' or 'io_turing' -: ${DISK_FMT:='raw'} # Disk file format, 'raw' by default for best performance -: ${DISK_CACHE:='none'} # Caching mode, can be set to 'writeback' for better performance -: ${DISK_DISCARD:='on'} # Controls whether unmap (TRIM) commands are passed to the host. -: ${DISK_ROTATION:='1'} # Rotation rate, set to 1 for SSD storage and increase for HDD +: ${DISK_IO:='native'} # I/O Mode, can be set to 'native', 'threads' or 'io_turing' +: ${DISK_FMT:='raw'} # Disk file format, 'raw' by default for best performance +: ${DISK_CACHE:='none'} # Caching mode, can be set to 'writeback' for better performance +: ${DISK_DISCARD:='on'} # Controls whether unmap (TRIM) commands are passed to the host. +: ${DISK_ROTATION:='1'} # Rotation rate, set to 1 for SSD storage and increase for HDD +: ${DISK_FLAGS:='nocow=on'} # Specify the options for use with the qcow2 format BOOT="$STORAGE/$BASE.boot.img" SYSTEM="$STORAGE/$BASE.system.img" @@ -137,12 +138,12 @@ convertDisk() { case "$DST_FMT" in qcow2) - CONV_FLAGS="$CONV_FLAGS -c" + CONV_FLAGS="$CONV_FLAGS -c -o $DISK_FLAGS" ;; esac # shellcheck disable=SC2086 - qemu-img convert $CONV_FLAGS -f "$SOURCE_FMT" -O "$DST_FMT" -- "$SOURCE_FILE" "$DST_FILE" + qemu-img convert -f "$SOURCE_FMT" $CONV_FLAGS -O "$DST_FMT" -- "$SOURCE_FILE" "$DST_FILE" } createDisk() { @@ -186,7 +187,7 @@ createDisk() { fi ;; qcow2) - if ! qemu-img create -f "$DISK_FMT" -- "$DISK_FILE" "$DISK_SPACE" ; then + if ! qemu-img create -f "$DISK_FMT" -o "$DISK_FLAGS" -- "$DISK_FILE" "$DISK_SPACE" ; then rm -f "$DISK_FILE" error "$FAIL" && exit 70 fi diff --git a/src/power.sh b/src/power.sh index 6fd105b..18f87c1 100644 --- a/src/power.sh +++ b/src/power.sh @@ -5,8 +5,8 @@ set -Eeuo pipefail QEMU_PORT=7100 QEMU_TIMEOUT=50 -QEMU_PID=/run/qemu.pid -QEMU_COUNT=/run/qemu.count +QEMU_PID="/run/qemu.pid" +QEMU_COUNT="/run/qemu.count" rm -f "$QEMU_PID" rm -f "$QEMU_COUNT" diff --git a/src/print.sh b/src/print.sh index 929e2c6..71be97c 100644 --- a/src/print.sh +++ b/src/print.sh @@ -7,6 +7,7 @@ error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: $1" "\E[0m\n" >&2; } file="/run/dsm.url" shutdown="/run/qemu.count" url="http://127.0.0.1:2210/read?command=10" + resp_err="Guest returned an invalid response:" jq_err="Failed to parse response from guest: jq error" @@ -19,8 +20,6 @@ do sleep 3 [ -f "$shutdown" ] && exit 1 - - # Healthcheck may have intervened [ -f "$file" ] && break # Retrieve IP from guest VM diff --git a/src/reset.sh b/src/reset.sh index e2ac97a..e6e8acf 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -43,6 +43,7 @@ rm -f /run/qemu.count # Cleanup dirs rm -rf /tmp/dsm +rm -f /tmp/server.* rm -rf "$STORAGE/tmp" # Helper functions