mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-08 11:03:41 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c135c4cac3 | ||
|
|
fb1751ff26 | ||
|
|
34f32d4ac6 | ||
|
|
36f1e47c0a | ||
|
|
c5dd5c2e46 | ||
|
|
d1d920372a | ||
|
|
12d8fd3ed0 | ||
|
|
729aed536e |
27
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
27
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
@@ -1,35 +1,12 @@
|
|||||||
name: "\U0001F6A8 Technical issue"
|
name: "\U0001F6A8 Technical issue"
|
||||||
description: When you're experiencing problems using the container
|
description: When you're experiencing problems using the container
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Is there no existing issue for this?
|
|
||||||
description: Please search to see if no solution was already provided before.
|
|
||||||
options:
|
|
||||||
- label: I have searched the existing issues
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: cpu
|
|
||||||
attributes:
|
|
||||||
label: Machine specifications
|
|
||||||
description: The processor and RAM amount in your machine.
|
|
||||||
placeholder: e.g. Intel N5105 / 16 GB
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
- type: input
|
||||||
id: os
|
id: os
|
||||||
attributes:
|
attributes:
|
||||||
label: Operating system
|
label: Operating system
|
||||||
description: The distribution and kernel version (as shown by `uname -a`).
|
description: Your Linux distribution (can be shown by `lsb_release -a`).
|
||||||
placeholder: e.g. Ubuntu 24.04 / Kernel 6.8.0-22-generic
|
placeholder: e.g. Ubuntu 24.04
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: docker
|
|
||||||
attributes:
|
|
||||||
label: Docker version
|
|
||||||
description: The version of the Docker engine (as shown by `docker -v`).
|
|
||||||
placeholder: e.g. 26.0.1
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
7
.github/ISSUE_TEMPLATE/2-feature.yml
vendored
7
.github/ISSUE_TEMPLATE/2-feature.yml
vendored
@@ -3,13 +3,6 @@ description: Suggest an idea for improving the container
|
|||||||
title: "[Feature]: "
|
title: "[Feature]: "
|
||||||
labels: ["enhancement"]
|
labels: ["enhancement"]
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Is there no existing feature request for this?
|
|
||||||
description: Please search to see if the feature was not already requested before.
|
|
||||||
options:
|
|
||||||
- label: I have searched the existing feature requests
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: problem
|
id: problem
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
27
.github/ISSUE_TEMPLATE/3-bug.yml
vendored
27
.github/ISSUE_TEMPLATE/3-bug.yml
vendored
@@ -3,35 +3,12 @@ description: Create a report to help us improve the container
|
|||||||
title: "[Bug]: "
|
title: "[Bug]: "
|
||||||
labels: ["bug"]
|
labels: ["bug"]
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Is there no existing bug report for this?
|
|
||||||
description: Please search to see if the bug was not already reported before.
|
|
||||||
options:
|
|
||||||
- label: I have searched the existing bug reports
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: cpu
|
|
||||||
attributes:
|
|
||||||
label: Machine specifications
|
|
||||||
description: The processor and RAM amount in your machine.
|
|
||||||
placeholder: e.g. Intel N5105 / 16 GB
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
- type: input
|
||||||
id: os
|
id: os
|
||||||
attributes:
|
attributes:
|
||||||
label: Operating system
|
label: Operating system
|
||||||
description: The distribution and kernel version (as shown by `uname -a`).
|
description: Your Linux distribution (can be shown by `lsb_release -a`).
|
||||||
placeholder: e.g. Ubuntu 24.04 / Kernel 6.8.0-22-generic
|
placeholder: e.g. Ubuntu 24.04
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: docker
|
|
||||||
attributes:
|
|
||||||
label: Docker version
|
|
||||||
description: The version of the Docker engine (as shown by `docker -v`).
|
|
||||||
placeholder: e.g. 26.0.1
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
11
readme.md
11
readme.md
@@ -44,7 +44,7 @@ services:
|
|||||||
Via Docker CLI:
|
Via Docker CLI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 vdsm/virtual-dsm
|
docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 vdsm/virtual-dsm
|
||||||
```
|
```
|
||||||
|
|
||||||
Via Kubernetes:
|
Via Kubernetes:
|
||||||
@@ -115,12 +115,11 @@ kubectl apply -f kubernetes.yml
|
|||||||
|
|
||||||
* ### How do I pass-through a disk?
|
* ### How do I pass-through a disk?
|
||||||
|
|
||||||
It is possible to pass-through disk devices directly by adding them to your compose file in this way:
|
It is possible to pass-through a disk device directly, by adding it to your compose file in this way:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
devices:
|
devices:
|
||||||
- /dev/disk/by-uuid/12345-12345-12345-12345-12345:/disk2
|
- /dev/disk/by-uuid/12345-12345-12345-12345-12345:/disk2
|
||||||
- /dev/disk/by-uuid/45678-45678-45678-45678-45678:/disk3
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure to bind the disk via its UUID (obtainable via `lsblk -o name,uuid`) instead of its name (`/dev/sdc`), to prevent ever binding the wrong disk when the drive letters happen to change.
|
Make sure to bind the disk via its UUID (obtainable via `lsblk -o name,uuid`) instead of its name (`/dev/sdc`), to prevent ever binding the wrong disk when the drive letters happen to change.
|
||||||
@@ -129,11 +128,11 @@ kubectl apply -f kubernetes.yml
|
|||||||
|
|
||||||
Do NOT use this feature with the goal of sharing files from the host, they will all be lost without warning when DSM creates the volume.
|
Do NOT use this feature with the goal of sharing files from the host, they will all be lost without warning when DSM creates the volume.
|
||||||
|
|
||||||
* ### How do I increase the amount of CPU or RAM?
|
* ### How do I change the amount of CPU or RAM?
|
||||||
|
|
||||||
By default, a single CPU core and 1 GB of RAM are allocated to the container.
|
By default, the container will be allowed to use a maximum of 1 CPU core and 1 GB of RAM.
|
||||||
|
|
||||||
If there arises a need to increase this, add the following environment variables:
|
If you want to adjust this, you can specify the desired amount using the following environment variables:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ set -Eeuo pipefail
|
|||||||
DEF_OPTS="-nodefaults -boot strict=on"
|
DEF_OPTS="-nodefaults -boot strict=on"
|
||||||
RAM_OPTS=$(echo "-m ${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
RAM_OPTS=$(echo "-m ${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
CPU_OPTS="-cpu $CPU_FLAGS -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
|
CPU_OPTS="-cpu $CPU_FLAGS -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
|
||||||
MAC_OPTS="-machine type=q35,usb=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
|
MAC_OPTS="-machine type=q35,smm=off,usb=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
|
||||||
DEV_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
|
DEV_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
|
||||||
DEV_OPTS="$DEV_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"
|
DEV_OPTS="$DEV_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"
|
||||||
DEV_OPTS="$DEV_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c"
|
DEV_OPTS="$DEV_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c"
|
||||||
@@ -14,16 +14,24 @@ ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
|
|||||||
|
|
||||||
# Check available memory as the very last step
|
# Check available memory as the very last step
|
||||||
|
|
||||||
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
if [[ "$RAM_CHECK" != [Nn]* ]]; then
|
||||||
AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 ))
|
|
||||||
|
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
||||||
|
AVAIL_GB=$(( RAM_AVAIL/1073741824 ))
|
||||||
|
|
||||||
|
if (( (RAM_WANTED + RAM_SPARE) > RAM_AVAIL )); then
|
||||||
|
error "Your configured RAM_SIZE of $WANTED_GB GB is too high for the $AVAIL_GB GB of memory available, please set a lower value."
|
||||||
|
exit 17
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( (RAM_WANTED + (RAM_SPARE * 3)) > RAM_AVAIL )); then
|
||||||
|
warn "your configured RAM_SIZE of $WANTED_GB GB is very close to the $AVAIL_GB GB of memory available, please consider a lower value."
|
||||||
|
fi
|
||||||
|
|
||||||
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
|
||||||
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
|
||||||
exit 17
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( (RAM_WANTED + 1450000000) > RAM_AVAIL )); then
|
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||||
warn "your configured RAM_SIZE of $WANTED_GB GB is much too close to the $AVAIL_GB GB of memory available, please set a lower value."
|
printf "Arguments:\n\n%s" "${ARGS// -/$'\n-'}" && echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
105
src/disk.sh
105
src/disk.sh
@@ -5,6 +5,7 @@ set -Eeuo pipefail
|
|||||||
|
|
||||||
: "${DISK_IO:="native"}" # I/O Mode, can be set to 'native', 'threads' or 'io_turing'
|
: "${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_FMT:="raw"}" # Disk file format, 'raw' by default for best performance
|
||||||
|
: "${DISK_TYPE:=""}" # Device type to be used, choose "ide", "usb", "blk" or "scsi"
|
||||||
: "${DISK_FLAGS:=""}" # Specifies the options for use with the qcow2 disk format
|
: "${DISK_FLAGS:=""}" # Specifies the options for use with the qcow2 disk format
|
||||||
: "${DISK_CACHE:="none"}" # Caching mode, can be set to 'writeback' for better 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_DISCARD:="on"}" # Controls whether unmap (TRIM) commands are passed to the host.
|
||||||
@@ -16,15 +17,6 @@ SYSTEM="$STORAGE/$BASE.system.img"
|
|||||||
[ ! -s "$BOOT" ] && error "Virtual DSM boot-image does not exist ($BOOT)" && exit 81
|
[ ! -s "$BOOT" ] && error "Virtual DSM boot-image does not exist ($BOOT)" && exit 81
|
||||||
[ ! -s "$SYSTEM" ] && error "Virtual DSM system-image does not exist ($SYSTEM)" && exit 82
|
[ ! -s "$SYSTEM" ] && error "Virtual DSM system-image does not exist ($SYSTEM)" && exit 82
|
||||||
|
|
||||||
DISK_OPTS="\
|
|
||||||
-object iothread,id=io2 \
|
|
||||||
-device virtio-scsi-pci,id=hw-synoboot,iothread=io2,bus=pcie.0,addr=0xa \
|
|
||||||
-drive file=$BOOT,if=none,id=drive-synoboot,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
|
|
||||||
-device scsi-hd,bus=hw-synoboot.0,channel=0,scsi-id=0,lun=0,drive=drive-synoboot,id=synoboot0,rotation_rate=$DISK_ROTATION,bootindex=1 \
|
|
||||||
-device virtio-scsi-pci,id=hw-synosys,iothread=io2,bus=pcie.0,addr=0xb \
|
|
||||||
-drive file=$SYSTEM,if=none,id=drive-synosys,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
|
|
||||||
-device scsi-hd,bus=hw-synosys.0,channel=0,scsi-id=0,lun=0,drive=drive-synosys,id=synosys0,rotation_rate=$DISK_ROTATION,bootindex=2"
|
|
||||||
|
|
||||||
fmt2ext() {
|
fmt2ext() {
|
||||||
local DISK_FMT=$1
|
local DISK_FMT=$1
|
||||||
|
|
||||||
@@ -123,9 +115,9 @@ createDisk() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
html "Creating a $DISK_DESC image..."
|
html "Creating a $DISK_DESC image..."
|
||||||
info "Creating a $DISK_SPACE $DISK_TYPE $DISK_DESC image in $DISK_FMT format..."
|
info "Creating a $DISK_SPACE $DISK_STYLE $DISK_DESC image in $DISK_FMT format..."
|
||||||
|
|
||||||
local FAIL="Could not create a $DISK_TYPE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)"
|
local FAIL="Could not create a $DISK_STYLE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)"
|
||||||
|
|
||||||
case "${DISK_FMT,,}" in
|
case "${DISK_FMT,,}" in
|
||||||
raw)
|
raw)
|
||||||
@@ -210,7 +202,7 @@ resizeDisk() {
|
|||||||
MSG="Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..."
|
MSG="Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..."
|
||||||
info "$MSG" && html "$MSG"
|
info "$MSG" && html "$MSG"
|
||||||
|
|
||||||
local FAIL="Could not resize the $DISK_TYPE $DISK_FMT $DISK_DESC image from ${GB}G to $DISK_SPACE ($DISK_FILE)"
|
local FAIL="Could not resize the $DISK_STYLE $DISK_FMT $DISK_DESC image from ${GB}G to $DISK_SPACE ($DISK_FILE)"
|
||||||
|
|
||||||
case "${DISK_FMT,,}" in
|
case "${DISK_FMT,,}" in
|
||||||
raw)
|
raw)
|
||||||
@@ -293,7 +285,7 @@ convertDisk() {
|
|||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
if ! qemu-img convert -f "$SOURCE_FMT" $CONV_FLAGS -o "$DISK_PARAM" -O "$DST_FMT" -- "$SOURCE_FILE" "$TMP_FILE"; then
|
if ! qemu-img convert -f "$SOURCE_FMT" $CONV_FLAGS -o "$DISK_PARAM" -O "$DST_FMT" -- "$SOURCE_FILE" "$TMP_FILE"; then
|
||||||
rm -f "$TMP_FILE"
|
rm -f "$TMP_FILE"
|
||||||
error "Failed to convert $DISK_TYPE $DISK_DESC image to $DST_FMT format in $DIR, is there enough space available?" && exit 79
|
error "Failed to convert $DISK_STYLE $DISK_DESC image to $DST_FMT format in $DIR, is there enough space available?" && exit 79
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$DST_FMT" == "raw" ]]; then
|
if [[ "$DST_FMT" == "raw" ]]; then
|
||||||
@@ -356,28 +348,52 @@ checkFS () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createDevice () {
|
createDevice () {
|
||||||
|
local DISK_FILE=$1
|
||||||
local DISK_ID=$1
|
local DISK_TYPE=$2
|
||||||
local DISK_FILE=$2
|
|
||||||
local DISK_INDEX=$3
|
local DISK_INDEX=$3
|
||||||
local DISK_ADDRESS=$4
|
local DISK_ADDRESS=$4
|
||||||
local DISK_FMT=$5
|
local DISK_FMT=$5
|
||||||
local DISK_IO=$6
|
local DISK_IO=$6
|
||||||
local DISK_CACHE=$7
|
local DISK_CACHE=$7
|
||||||
|
local DISK_ID="data$DISK_INDEX"
|
||||||
|
|
||||||
local result="-drive file=$DISK_FILE,if=none,id=drive-$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on"
|
local index=""
|
||||||
|
[ -n "$DISK_INDEX" ] && index=",bootindex=$DISK_INDEX"
|
||||||
|
local result="-drive file=$DISK_FILE,id=$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on"
|
||||||
|
|
||||||
result="$result \
|
case "${DISK_TYPE,,}" in
|
||||||
-device virtio-scsi-pci,id=hw-$DISK_ID,iothread=io2,bus=pcie.0,addr=$DISK_ADDRESS \
|
"auto" )
|
||||||
-device scsi-hd,bus=hw-$DISK_ID.0,channel=0,scsi-id=0,lun=0,drive=drive-$DISK_ID,id=$DISK_ID,rotation_rate=$DISK_ROTATION,bootindex=$DISK_INDEX"
|
echo "$result"
|
||||||
|
;;
|
||||||
|
"usb" )
|
||||||
|
result="$result,if=none \
|
||||||
|
-device usb-storage,drive=${DISK_ID}${index}"
|
||||||
|
echo "$result"
|
||||||
|
;;
|
||||||
|
"ide" )
|
||||||
|
result="$result,if=none \
|
||||||
|
-device ide-hd,drive=${DISK_ID},bus=ide.$DISK_INDEX,rotation_rate=$DISK_ROTATION${index}"
|
||||||
|
echo "$result"
|
||||||
|
;;
|
||||||
|
"blk" | "virtio-blk" )
|
||||||
|
result="$result,if=none \
|
||||||
|
-device virtio-blk-pci,drive=${DISK_ID},scsi=off,bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2${index}"
|
||||||
|
echo "$result"
|
||||||
|
;;
|
||||||
|
"scsi" | "virtio-scsi" )
|
||||||
|
result="$result,if=none \
|
||||||
|
-device virtio-scsi-pci,id=${DISK_ID}b,bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2 \
|
||||||
|
-device scsi-hd,drive=${DISK_ID},bus=${DISK_ID}b.0,channel=0,scsi-id=0,lun=0,rotation_rate=$DISK_ROTATION${index}"
|
||||||
|
echo "$result"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo "$result"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
addDisk () {
|
addDisk () {
|
||||||
local DISK_BASE=$1
|
local DISK_BASE=$1
|
||||||
local DISK_EXT=$2
|
local DISK_TYPE=$2
|
||||||
local DISK_DESC=$3
|
local DISK_DESC=$3
|
||||||
local DISK_SPACE=$4
|
local DISK_SPACE=$4
|
||||||
local DISK_INDEX=$5
|
local DISK_INDEX=$5
|
||||||
@@ -385,9 +401,10 @@ addDisk () {
|
|||||||
local DISK_FMT=$7
|
local DISK_FMT=$7
|
||||||
local DISK_IO=$8
|
local DISK_IO=$8
|
||||||
local DISK_CACHE=$9
|
local DISK_CACHE=$9
|
||||||
local DISK_ID="userdata$DISK_INDEX"
|
local DISK_EXT DIR DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE OPTS
|
||||||
|
|
||||||
|
DISK_EXT=$(fmt2ext "$DISK_FMT")
|
||||||
local DISK_FILE="$DISK_BASE.$DISK_EXT"
|
local DISK_FILE="$DISK_BASE.$DISK_EXT"
|
||||||
local DIR DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE OPTS
|
|
||||||
|
|
||||||
DIR=$(dirname "$DISK_FILE")
|
DIR=$(dirname "$DISK_FILE")
|
||||||
[ ! -d "$DIR" ] && return 0
|
[ ! -d "$DIR" ] && return 0
|
||||||
@@ -440,25 +457,23 @@ addDisk () {
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OPTS=$(createDevice "$DISK_ID" "$DISK_FILE" "$DISK_INDEX" "$DISK_ADDRESS" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE")
|
OPTS=$(createDevice "$DISK_FILE" "$DISK_TYPE" "$DISK_INDEX" "$DISK_ADDRESS" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE")
|
||||||
DISK_OPTS="$DISK_OPTS $OPTS"
|
DISK_OPTS="$DISK_OPTS $OPTS"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
addDevice () {
|
addDevice () {
|
||||||
|
|
||||||
local DISK_DEV=$1
|
local DISK_DEV=$1
|
||||||
local DISK_DESC=$2
|
local DISK_TYPE=$2
|
||||||
local DISK_INDEX=$3
|
local DISK_INDEX=$3
|
||||||
local DISK_ADDRESS=$4
|
local DISK_ADDRESS=$4
|
||||||
local DISK_ID="userdata$DISK_INDEX"
|
|
||||||
|
|
||||||
[ -z "$DISK_DEV" ] && return 0
|
[ -z "$DISK_DEV" ] && return 0
|
||||||
[ ! -b "$DISK_DEV" ] && error "Device $DISK_DEV cannot be found! Please add it to the 'devices' section of your compose file." && exit 55
|
[ ! -b "$DISK_DEV" ] && error "Device $DISK_DEV cannot be found! Please add it to the 'devices' section of your compose file." && exit 55
|
||||||
|
|
||||||
local OPTS
|
local OPTS
|
||||||
OPTS=$(createDevice "$DISK_ID" "$DISK_DEV" "$DISK_INDEX" "$DISK_ADDRESS" "raw" "$DISK_IO" "$DISK_CACHE")
|
OPTS=$(createDevice "$DISK_DEV" "$DISK_TYPE" "$DISK_INDEX" "$DISK_ADDRESS" "raw" "$DISK_IO" "$DISK_CACHE")
|
||||||
DISK_OPTS="$DISK_OPTS $OPTS"
|
DISK_OPTS="$DISK_OPTS $OPTS"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -466,7 +481,11 @@ addDevice () {
|
|||||||
|
|
||||||
html "Initializing disks..."
|
html "Initializing disks..."
|
||||||
|
|
||||||
DISK_EXT=$(fmt2ext "$DISK_FMT")
|
case "${DISK_TYPE,,}" in
|
||||||
|
"" ) DISK_TYPE="scsi" ;;
|
||||||
|
"auto" | "ide" | "usb" | "blk" | "scsi" ) ;;
|
||||||
|
* ) error "Invalid DISK_TYPE, value \"$DISK_TYPE\" is unrecognized!" && exit 80 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [ -z "$ALLOCATE" ]; then
|
if [ -z "$ALLOCATE" ]; then
|
||||||
if [[ "${DISK_FMT,,}" == "raw" ]]; then
|
if [[ "${DISK_FMT,,}" == "raw" ]]; then
|
||||||
@@ -477,13 +496,17 @@ if [ -z "$ALLOCATE" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||||
DISK_TYPE="growable"
|
DISK_STYLE="growable"
|
||||||
DISK_ALLOC="preallocation=off"
|
DISK_ALLOC="preallocation=off"
|
||||||
else
|
else
|
||||||
DISK_TYPE="preallocated"
|
DISK_STYLE="preallocated"
|
||||||
DISK_ALLOC="preallocation=falloc"
|
DISK_ALLOC="preallocation=falloc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
DISK_OPTS=$(createDevice "$BOOT" "$DISK_TYPE" "1" "0xa" "raw" "$DISK_IO" "$DISK_CACHE")
|
||||||
|
OPTS=$(createDevice "$SYSTEM" "$DISK_TYPE" "2" "0xb" "raw" "$DISK_IO" "$DISK_CACHE")
|
||||||
|
DISK_OPTS="$DISK_OPTS $OPTS"
|
||||||
|
|
||||||
DISK1_FILE="$STORAGE/data"
|
DISK1_FILE="$STORAGE/data"
|
||||||
if [[ ! -f "$DISK1_FILE.img" ]] && [[ -f "$STORAGE/data${DISK_SIZE}.img" ]]; then
|
if [[ ! -f "$DISK1_FILE.img" ]] && [[ -f "$STORAGE/data${DISK_SIZE}.img" ]]; then
|
||||||
# Fallback for legacy installs
|
# Fallback for legacy installs
|
||||||
@@ -539,28 +562,30 @@ DISK4_FILE="/storage4/data4"
|
|||||||
[ -z "$DEVICE4" ] && [ -b "/dev/disk4" ] && DEVICE4="/dev/disk4"
|
[ -z "$DEVICE4" ] && [ -b "/dev/disk4" ] && DEVICE4="/dev/disk4"
|
||||||
|
|
||||||
if [ -n "$DEVICE" ]; then
|
if [ -n "$DEVICE" ]; then
|
||||||
addDevice "$DEVICE" "device" "3" "0xc" || exit $?
|
addDevice "$DEVICE" "$DISK_TYPE" "3" "0xc" || exit $?
|
||||||
else
|
else
|
||||||
addDisk "$DISK1_FILE" "$DISK_EXT" "disk" "$DISK_SIZE" "3" "0xc" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
addDisk "$DISK1_FILE" "$DISK_TYPE" "disk" "$DISK_SIZE" "3" "0xc" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$DEVICE2" ]; then
|
if [ -n "$DEVICE2" ]; then
|
||||||
addDevice "$DEVICE2" "device2" "4" "0xd" || exit $?
|
addDevice "$DEVICE2" "$DISK_TYPE" "4" "0xd" || exit $?
|
||||||
else
|
else
|
||||||
addDisk "$DISK2_FILE" "$DISK_EXT" "disk2" "$DISK2_SIZE" "4" "0xd" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
addDisk "$DISK2_FILE" "$DISK_TYPE" "disk2" "$DISK2_SIZE" "4" "0xd" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$DEVICE3" ]; then
|
if [ -n "$DEVICE3" ]; then
|
||||||
addDevice "$DEVICE3" "device3" "5" "0xe" || exit $?
|
addDevice "$DEVICE3" "$DISK_TYPE" "5" "0xe" || exit $?
|
||||||
else
|
else
|
||||||
addDisk "$DISK3_FILE" "$DISK_EXT" "disk3" "$DISK3_SIZE" "5" "0xe" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
addDisk "$DISK3_FILE" "$DISK_TYPE" "disk3" "$DISK3_SIZE" "5" "0xe" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$DEVICE4" ]; then
|
if [ -n "$DEVICE4" ]; then
|
||||||
addDevice "$DEVICE4" "device4" "6" "0xf" || exit $?
|
addDevice "$DEVICE4" "$DISK_TYPE" "6" "0xf" || exit $?
|
||||||
else
|
else
|
||||||
addDisk "$DISK4_FILE" "$DISK_EXT" "disk4" "$DISK4_SIZE" "6" "0xf" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
addDisk "$DISK4_FILE" "$DISK_TYPE" "disk4" "$DISK4_SIZE" "6" "0xf" "$DISK_FMT" "$DISK_IO" "$DISK_CACHE" || exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
DISK_OPTS="$DISK_OPTS -object iothread,id=io2"
|
||||||
|
|
||||||
html "Initialized disks successfully..."
|
html "Initialized disks successfully..."
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ cd /run
|
|||||||
trap - ERR
|
trap - ERR
|
||||||
|
|
||||||
info "Booting ${APP}..."
|
info "Booting ${APP}..."
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Arguments: $ARGS" && echo
|
|
||||||
|
|
||||||
if [[ "$CONSOLE" == [Yy]* ]]; then
|
if [[ "$CONSOLE" == [Yy]* ]]; then
|
||||||
exec qemu-system-x86_64 ${ARGS:+ $ARGS}
|
exec qemu-system-x86_64 ${ARGS:+ $ARGS}
|
||||||
@@ -33,4 +32,4 @@ tail -fn +0 "$QEMU_LOG" 2>/dev/null &
|
|||||||
cat "$QEMU_TERM" 2>/dev/null & wait $! || :
|
cat "$QEMU_TERM" 2>/dev/null & wait $! || :
|
||||||
|
|
||||||
sleep 1 & wait $!
|
sleep 1 & wait $!
|
||||||
finish 0
|
[ ! -f "$QEMU_END" ] && finish 0
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ rm -f "$STORAGE/$BASE.agent"
|
|||||||
rm -f "$STORAGE/$BASE.boot.img"
|
rm -f "$STORAGE/$BASE.boot.img"
|
||||||
rm -f "$STORAGE/$BASE.system.img"
|
rm -f "$STORAGE/$BASE.system.img"
|
||||||
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && set -x
|
|
||||||
|
|
||||||
# Check filesystem
|
# Check filesystem
|
||||||
FS=$(stat -f -c %T "$STORAGE")
|
FS=$(stat -f -c %T "$STORAGE")
|
||||||
|
|
||||||
@@ -399,8 +397,5 @@ fi
|
|||||||
mv -f "$BOOT" "$STORAGE/$BASE.boot.img"
|
mv -f "$BOOT" "$STORAGE/$BASE.boot.img"
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo
|
|
||||||
|
|
||||||
html "Installation finished successfully..."
|
html "Installation finished successfully..."
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ set -Eeuo pipefail
|
|||||||
: "${VM_NET_DEV:=""}"
|
: "${VM_NET_DEV:=""}"
|
||||||
: "${VM_NET_TAP:="dsm"}"
|
: "${VM_NET_TAP:="dsm"}"
|
||||||
: "${VM_NET_MAC:="$MAC"}"
|
: "${VM_NET_MAC:="$MAC"}"
|
||||||
|
: "${VM_NET_IP:="20.20.20.21"}"
|
||||||
: "${VM_NET_HOST:="VirtualDSM"}"
|
: "${VM_NET_HOST:="VirtualDSM"}"
|
||||||
|
|
||||||
: "${DNSMASQ_OPTS:=""}"
|
: "${DNSMASQ_OPTS:=""}"
|
||||||
@@ -146,15 +147,13 @@ configureNAT() {
|
|||||||
|
|
||||||
# Create a bridge with a static IP for the VM guest
|
# Create a bridge with a static IP for the VM guest
|
||||||
|
|
||||||
VM_NET_IP='20.20.20.21'
|
|
||||||
|
|
||||||
{ ip link add dev dockerbridge type bridge ; rc=$?; } || :
|
{ ip link add dev dockerbridge type bridge ; rc=$?; } || :
|
||||||
|
|
||||||
if (( rc != 0 )); then
|
if (( rc != 0 )); then
|
||||||
error "Failed to create bridge. $ADD_ERR --cap-add NET_ADMIN" && exit 23
|
error "Failed to create bridge. $ADD_ERR --cap-add NET_ADMIN" && exit 23
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge
|
ip address add "${VM_NET_IP%.*}.1/24" broadcast "${VM_NET_IP%.*}.255" dev dockerbridge
|
||||||
|
|
||||||
while ! ip link set dockerbridge up; do
|
while ! ip link set dockerbridge up; do
|
||||||
info "Waiting for IP address to become available..."
|
info "Waiting for IP address to become available..."
|
||||||
@@ -260,8 +259,13 @@ checkOS() {
|
|||||||
getInfo() {
|
getInfo() {
|
||||||
|
|
||||||
if [ -z "$VM_NET_DEV" ]; then
|
if [ -z "$VM_NET_DEV" ]; then
|
||||||
|
# Give Kubernetes priority over the default interface
|
||||||
|
[ -d "/sys/class/net/net0" ] && VM_NET_DEV="net0"
|
||||||
|
[ -d "/sys/class/net/net1" ] && VM_NET_DEV="net1"
|
||||||
|
[ -d "/sys/class/net/net2" ] && VM_NET_DEV="net2"
|
||||||
|
[ -d "/sys/class/net/net3" ] && VM_NET_DEV="net3"
|
||||||
# Automaticly detect the default network interface
|
# Automaticly detect the default network interface
|
||||||
VM_NET_DEV=$(awk '$2 == 00000000 { print $1 }' /proc/net/route)
|
[ -z "$VM_NET_DEV" ] && VM_NET_DEV=$(awk '$2 == 00000000 { print $1 }' /proc/net/route)
|
||||||
[ -z "$VM_NET_DEV" ] && VM_NET_DEV="eth0"
|
[ -z "$VM_NET_DEV" ] && VM_NET_DEV="eth0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -292,7 +296,7 @@ getInfo() {
|
|||||||
error "Invalid MAC address: '$VM_NET_MAC', should be 12 or 17 digits long!" && exit 28
|
error "Invalid MAC address: '$VM_NET_MAC', should be 12 or 17 digits long!" && exit 28
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GATEWAY=$(ip r | grep default | awk '{print $3}')
|
GATEWAY=$(ip route list dev "$VM_NET_DEV" | awk ' /^default/ {print $3}')
|
||||||
IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
|
IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
|
||||||
echo "$IP" > /run/shm/qemu.ip
|
echo "$IP" > /run/shm/qemu.ip
|
||||||
|
|
||||||
@@ -323,10 +327,10 @@ fi
|
|||||||
|
|
||||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
|
|
||||||
! checkOS && exit 19
|
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
||||||
|
|
||||||
if [[ "$GATEWAY" == "172."* ]]; then
|
if [[ "$IP" == "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)!"
|
warn "container IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configuration for DHCP IP
|
# Configuration for DHCP IP
|
||||||
@@ -337,8 +341,8 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
if [[ "$GATEWAY" != "172."* ]]; then
|
if [[ "$IP" != "172."* ]] && [[ "$IP" != "10.8"* ]] && [[ "$IP" != "10.9"* ]]; then
|
||||||
! checkOS && exit 19
|
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Shutdown nginx
|
# Shutdown nginx
|
||||||
|
|||||||
15
src/reset.sh
15
src/reset.sh
@@ -23,6 +23,7 @@ echo "❯ For support visit $SUPPORT"
|
|||||||
: "${ARGUMENTS:=""}" # Extra QEMU parameters
|
: "${ARGUMENTS:=""}" # Extra QEMU parameters
|
||||||
: "${CPU_CORES:="1"}" # Amount of CPU cores
|
: "${CPU_CORES:="1"}" # Amount of CPU cores
|
||||||
: "${RAM_SIZE:="1G"}" # Maximum RAM amount
|
: "${RAM_SIZE:="1G"}" # Maximum RAM amount
|
||||||
|
: "${RAM_CHECK:="Y"}" # Check available RAM
|
||||||
: "${DISK_SIZE:="16G"}" # Initial data disk size
|
: "${DISK_SIZE:="16G"}" # Initial data disk size
|
||||||
|
|
||||||
# Helper variables
|
# Helper variables
|
||||||
@@ -42,7 +43,8 @@ HOST=$(hostname -s)
|
|||||||
KERNEL=$(echo "$SYS" | cut -b 1)
|
KERNEL=$(echo "$SYS" | cut -b 1)
|
||||||
MINOR=$(echo "$SYS" | cut -d '.' -f2)
|
MINOR=$(echo "$SYS" | cut -d '.' -f2)
|
||||||
ARCH=$(dpkg --print-architecture)
|
ARCH=$(dpkg --print-architecture)
|
||||||
CPU=$(lscpu | grep -m 1 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
|
SOCKETS=$(lscpu | grep -m 1 -i 'socket(s)' | awk '{print $(2)}')
|
||||||
|
CPU=$(lscpu | grep -m 1 -i 'model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
|
||||||
|
|
||||||
# Check system
|
# Check system
|
||||||
|
|
||||||
@@ -67,11 +69,12 @@ if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Read memory
|
# Read memory
|
||||||
|
RAM_SPARE=500000000
|
||||||
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
||||||
RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}')
|
RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}')
|
||||||
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
RAM_WANTED=$(numfmt --from=iec "$RAM_SIZE")
|
RAM_WANTED=$(numfmt --from=iec "$RAM_SIZE")
|
||||||
AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 ))
|
AVAIL_GB=$(( RAM_AVAIL/1073741824 ))
|
||||||
TOTAL_GB=$(( (RAM_TOTAL + 1073741823)/1073741824 ))
|
TOTAL_GB=$(( (RAM_TOTAL + 1073741823)/1073741824 ))
|
||||||
WANTED_GB=$(( (RAM_WANTED + 1073741823)/1073741824 ))
|
WANTED_GB=$(( (RAM_WANTED + 1073741823)/1073741824 ))
|
||||||
|
|
||||||
@@ -86,9 +89,11 @@ echo
|
|||||||
|
|
||||||
# Check memory
|
# Check memory
|
||||||
|
|
||||||
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
if [[ "$RAM_CHECK" != [Nn]* ]]; then
|
||||||
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
if (( (RAM_WANTED + RAM_SPARE) > RAM_AVAIL )); then
|
||||||
exit 17
|
error "Your configured RAM_SIZE of $WANTED_GB GB is too high for the $AVAIL_GB GB of memory available, please set a lower value."
|
||||||
|
exit 17
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup files
|
# Cleanup files
|
||||||
|
|||||||
Reference in New Issue
Block a user