feat: Set NOCOW flag for btrfs

feat: Set NOCOW flag for btrfs
This commit is contained in:
Kroese 2023-12-17 11:42:08 +01:00 committed by GitHub
commit e3942da906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 19 deletions

View File

@ -18,6 +18,6 @@ services:
ports:
- 5000:5000
volumes:
- /opt/dsm:/storage
- /var/dsm:/storage
restart: on-failure
stop_grace_period: 2m

View File

@ -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?

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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