Compare commits

..

25 Commits
v7.21 ... v7.29

Author SHA1 Message Date
Kroese
5e6f931433 feat: Detect clock source (#923) 2025-03-14 14:16:10 +01:00
Kroese
beadfe720c feat: Improve CPU detection (#921)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-03-14 05:23:49 +01:00
Kroese
92b4bfc383 feat: Validate configured RAM (#920)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-03-13 11:35:08 +01:00
Kroese
092ed23085 feat: Check CPU core configuration (#919) 2025-03-13 10:47:25 +01:00
Kroese
c70fa3d00a feat: Validate specified size (#918)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-03-12 21:17:47 +01:00
Kroese
fea0ba09f6 docs: Use relative paths (#917)
Some checks failed
Update / dockerHubDescription (push) Has been cancelled
2025-03-12 12:31:50 +01:00
Kroese
7d2af63eac docs: Kubernetes deployment (#916)
Some checks failed
Update / dockerHubDescription (push) Has been cancelled
2025-03-07 00:42:29 +01:00
Kroese
2e73bf560e docs: Add link to download (#915) 2025-03-07 00:22:29 +01:00
Kroese
bfc8d7a9c6 fix: Network shutdown (#912)
Some checks failed
Build / Check (push) Has been cancelled
Build / Build (push) Has been cancelled
2025-03-05 04:59:57 +01:00
Kroese
a1e9936572 fix: Set MTU value (#911)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-03-04 15:37:37 +01:00
Kroese
3675a50129 fix: Gateway MAC generation (#910)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-03-03 13:57:53 +01:00
Kroese
91229152bd feat: Set MTU size for TAP interface (#909) 2025-03-03 13:40:15 +01:00
Kroese
a1993e590a feat: Automaticly match MTU size (#908) 2025-03-03 12:20:16 +01:00
Kroese
52fe712b6f docs: Readme (#907)
Some checks failed
Update / dockerHubDescription (push) Has been cancelled
2025-03-01 14:23:51 +01:00
Kroese
7f400b6b59 feat: Improve CPU detection (#905)
Some checks failed
Build / Check (push) Has been cancelled
Build / Build (push) Has been cancelled
2025-02-27 11:52:48 +01:00
Kroese
9cb88a99e6 feat: Allow bridge networks (#904) 2025-02-27 11:46:38 +01:00
Kroese
b967a471b5 fix: Add e2fsprogs package (#902)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-02-26 10:03:46 +01:00
Kroese
f40127df01 feat: Make app name configurable (#900)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-02-25 15:13:57 +01:00
Kroese
8c5e0ee274 fix: Generate local MAC address (#899)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-02-24 21:01:55 +01:00
Kroese
2adf0b292b fix: Preserve gateway MAC address (#898)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-02-24 03:48:42 +01:00
Kroese
1c9b793c75 fix: Move nginx config (#893)
Some checks failed
Build / Check (push) Has been cancelled
Build / Build (push) Has been cancelled
2025-02-15 02:36:07 +01:00
Kroese
00c4ef7795 feat: Remove existing TAP interface (#892)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-02-14 20:19:12 +01:00
Kroese
619657adf2 docs: Add restart policy (#888)
Some checks failed
Update / dockerHubDescription (push) Has been cancelled
2025-02-10 00:31:32 +01:00
Kroese
41db7c1035 feat: Improve CPU detection (#884)
Some checks failed
Build / Check (push) Has been cancelled
Build / Build (push) Has been cancelled
2025-02-06 02:19:39 +01:00
Kroese
d71834a777 build: Enable ARM64 platform (#873) 2025-01-10 18:44:37 +01:00
11 changed files with 199 additions and 124 deletions

View File

@@ -54,7 +54,7 @@ jobs:
labels: |
org.opencontainers.image.title=${{ vars.NAME }}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -78,7 +78,7 @@ jobs:
context: .
push: true
provenance: false
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}

View File

@@ -35,12 +35,16 @@ RUN set -eu && extra="" && \
dnsmasq \
fakeroot \
net-tools \
e2fsprogs \
qemu-utils \
iputils-ping \
ca-certificates \
netcat-openbsd \
qemu-system-x86 \
"$extra" && \
apt-get clean && \
mkdir -p /etc/qemu && \
echo "allow br0" > /etc/qemu/bridge.conf && \
unlink /etc/nginx/sites-enabled/default && \
sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf && \
echo "$VERSION_ARG" > /run/version && \
@@ -49,7 +53,7 @@ RUN set -eu && extra="" && \
COPY --chmod=755 ./src /run/
COPY --chmod=755 ./web /var/www/
COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin
COPY --chmod=744 ./web/nginx.conf /etc/nginx/sites-enabled/web.conf
COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/sites-enabled/web.conf
VOLUME /storage
EXPOSE 22 139 445 5000

View File

@@ -1,16 +1,17 @@
services:
dsm:
container_name: dsm
image: vdsm/virtual-dsm:latest
environment:
DISK_SIZE: "16G"
devices:
- /dev/kvm
- /dev/net/tun
cap_add:
- NET_ADMIN
ports:
- 5000:5000
volumes:
- /var/dsm:/storage
stop_grace_period: 2m
dsm:
container_name: dsm
image: vdsm/virtual-dsm
environment:
DISK_SIZE: "16G"
devices:
- /dev/kvm
- /dev/net/tun
cap_add:
- NET_ADMIN
ports:
- 5000:5000
volumes:
- ./dsm:/storage
restart: always
stop_grace_period: 2m

View File

@@ -10,58 +10,68 @@ spec:
requests:
storage: 16Gi
---
apiVersion: v1
kind: Pod
apiVersion: apps/v1
kind: Deployment
metadata:
name: dsm
labels:
name: dsm
spec:
containers:
- name: dsm
image: vdsm/virtual-dsm
env:
- name: RAM_SIZE
value: "1G"
- name: CPU_CORES
value: "1"
- name: DISK_SIZE
value: "16G"
ports:
- containerPort: 5000
securityContext:
capabilities:
add:
- NET_ADMIN
privileged: true
volumeMounts:
- mountPath: /storage
name: storage
- mountPath: /dev/kvm
name: dev-kvm
- mountPath: /dev/net/tun
name: dev-tun
terminationGracePeriodSeconds: 120
volumes:
- name: storage
persistentVolumeClaim:
claimName: dsm-pvc
- hostPath:
path: /dev/kvm
name: dev-kvm
- hostPath:
path: /dev/net/tun
type: CharDevice
name: dev-tun
replicas: 1
selector:
matchLabels:
app: dsm
template:
metadata:
labels:
app: dsm
spec:
containers:
- name: dsm
image: vdsm/virtual-dsm
env:
- name: DISK_SIZE
value: "16G"
ports:
- containerPort: 5000
name: http
protocol: TCP
securityContext:
capabilities:
add:
- NET_ADMIN
privileged: true
volumeMounts:
- mountPath: /storage
name: storage
- mountPath: /dev/kvm
name: dev-kvm
- mountPath: /dev/net/tun
name: dev-tun
terminationGracePeriodSeconds: 120
volumes:
- name: storage
persistentVolumeClaim:
claimName: dsm-pvc
- hostPath:
path: /dev/kvm
name: dev-kvm
- hostPath:
path: /dev/net/tun
type: CharDevice
name: dev-tun
---
apiVersion: v1
kind: Service
metadata:
name: dsm
spec:
internalTrafficPolicy: Cluster
ports:
- name: tcp-5000
port: 5000
- name: http
port: 5000
protocol: TCP
targetPort: 5000
selector:
name: dsm
type: NodePort
app: dsm
type: ClusterIP

View File

@@ -39,14 +39,15 @@ services:
ports:
- 5000:5000
volumes:
- /var/dsm:/storage
- ./dsm:/storage
restart: always
stop_grace_period: 2m
```
Via Docker CLI:
```bash
docker run -it --rm -p 5000:5000 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN --stop-timeout 120 vdsm/virtual-dsm
docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v ${PWD:-.}/dsm:/storage --stop-timeout 120 vdsm/virtual-dsm
```
Via Kubernetes:
@@ -83,10 +84,10 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
```yaml
volumes:
- /var/dsm:/storage
- ./dsm:/storage
```
Replace the example path `/var/dsm` with the desired storage folder.
Replace the example path `./dsm` with the desired storage folder or named volume.
### How do I change the size of the disk?
@@ -111,9 +112,6 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
DISK_FMT: "qcow2"
```
> [!NOTE]
> This may reduce the write performance of the disk.
### How do I add multiple disks?
To create additional disks, modify your compose file like this:
@@ -123,8 +121,8 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
DISK2_SIZE: "32G"
DISK3_SIZE: "64G"
volumes:
- /home/example:/storage2
- /mnt/data/example:/storage3
- ./example2:/storage2
- ./example3:/storage3
```
### How do I pass-through a disk?
@@ -222,7 +220,7 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
After configuring the container for [macvlan](#how-do-i-assign-an-individual-ip-address-to-the-container), it is possible for DSM to become part of your home network by requesting an IP from your router, just like your other devices.
To enable this mode, add the following lines to your compose file:
To enable this mode, in which the container and DSM will have separate IP addresses, add the following lines to your compose file:
```yaml
environment:
@@ -233,9 +231,6 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
- 'c *:* rwm'
```
> [!NOTE]
> In this mode, the container and DSM will each have their own separate IPs.
### How do I pass-through the GPU?
To pass-through your Intel GPU, add the following lines to your compose file:
@@ -247,19 +242,19 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
- /dev/dri
```
> [!TIP]
> This can be used to enable the facial recognition function in Synology Photos for example.
> [!NOTE]
> This can be used to enable the facial recognition function in Synology Photos, but does not provide hardware transcoding for video.
### How do I install a specific version of vDSM?
By default, version 7.2 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
By default, version 7.2 will be installed, but if you prefer an older version, you can add the download URL of the `.pat` file to your compose file as follows:
```yaml
environment:
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
```
With this method, it is even possible to switch between different versions while keeping all your file data intact.
With this method, it is even possible to switch back and forth between versions while keeping your file data intact.
If you don't have internet access, it's also possible to skip the download by setting URL to:
@@ -268,7 +263,7 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
URL: "DSM_VirtualDSM_42218.pat"
```
after placing a file called `DSM_VirtualDSM_42218.pat` in your `/storage` folder.
after placing a copy of [DSM_VirtualDSM_42218.pat](https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat) in the root of your `/storage` folder.
### What are the differences compared to the standard DSM?

View File

@@ -427,12 +427,13 @@ addDisk () {
[ -z "$DISK_SPACE" ] && DISK_SPACE="16G"
DISK_SPACE=$(echo "${DISK_SPACE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
[[ -z "${DISK_SPACE//[0-9]}" ]] && DISK_SPACE="${DISK_SPACE}G"
DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")
if (( DATA_SIZE < 1 )); then
if ! numfmt --from=iec "$DISK_SPACE" &>/dev/null; then
error "Invalid value for ${DISK_DESC^^}_SIZE: $DISK_SPACE" && exit 73
fi
DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")
if (( DATA_SIZE < 6442450944 )); then
error "Please increase ${DISK_DESC^^}_SIZE to at least 6 GB." && exit 73
fi

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -Eeuo pipefail
APP="Virtual DSM"
SUPPORT="https://github.com/vdsm/virtual-dsm"
: "${APP:="Virtual DSM"}"
: "${SUPPORT:="https://github.com/vdsm/virtual-dsm"}"
cd /run

View File

@@ -4,6 +4,7 @@ set -Eeuo pipefail
# Docker environment variables
: "${MAC:=""}"
: "${MTU:=""}"
: "${DHCP:="N"}"
: "${NETWORK:="Y"}"
: "${USER_PORTS:=""}"
@@ -58,6 +59,12 @@ configureDHCP() {
fi ;;
esac
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
warn "Failed to set MTU size.."
fi
fi
while ! ip link set "$VM_NET_TAP" up; do
info "Waiting for MAC address $VM_NET_MAC to become available..."
sleep 2
@@ -192,7 +199,6 @@ configureNAT() {
fi
# Create a bridge with a static IP for the VM guest
{ ip link add dev dockerbridge type bridge ; rc=$?; } || :
if (( rc != 0 )); then
@@ -213,6 +219,18 @@ configureNAT() {
error "$tuntap" && return 1
fi
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
warn "Failed to set MTU size.."
fi
fi
GATEWAY_MAC=$(echo "$VM_NET_MAC" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
if ! ip link set dev "$VM_NET_TAP" address "$GATEWAY_MAC"; then
warn "Failed to set gateway MAC address.."
fi
while ! ip link set "$VM_NET_TAP" up promisc on; do
info "Waiting for TAP to become available..."
sleep 2
@@ -260,6 +278,22 @@ configureNAT() {
return 0
}
closeBridge() {
local pid="/var/run/dnsmasq.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
[[ "${NETWORK,,}" == "user"* ]] && return 0
ip link set "$VM_NET_TAP" down promisc off &> null || true
ip link delete "$VM_NET_TAP" &> null || true
ip link set dockerbridge down &> null || true
ip link delete dockerbridge &> null || true
return 0
}
closeNetwork() {
if [[ "$DHCP" == [Yy1]* ]]; then
@@ -275,26 +309,16 @@ closeNetwork() {
exec 30<&- || true
exec 40<&- || true
if [[ "$DHCP" == [Yy1]* ]]; then
if [[ "$DHCP" != [Yy1]* ]]; then
ip link set "$VM_NET_TAP" down || true
ip link delete "$VM_NET_TAP" || true
else
local pid="/var/run/dnsmasq.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
[[ "${NETWORK,,}" == "user"* ]] && return 0
ip link set "$VM_NET_TAP" down promisc off || true
ip link delete "$VM_NET_TAP" || true
ip link set dockerbridge down || true
ip link delete dockerbridge || true
closeBridge
return 0
fi
ip link set "$VM_NET_TAP" down || true
ip link delete "$VM_NET_TAP" || true
return 0
}
@@ -338,6 +362,20 @@ getInfo() {
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27
fi
if [ -z "$MTU" ]; then
MTU=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
fi
if [ "$MTU" -gt "1500" ]; then
info "MTU size is too large: $MTU, ignoring..." && MTU="0"
fi
if [[ "${ADAPTER,,}" != "virtio-net-pci" ]]; then
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
warn "MTU size is $MTU, but cannot be set for $ADAPTER adapters!" && MTU="0"
fi
fi
if [ -z "$VM_NET_MAC" ]; then
local file="$STORAGE/dsm.mac"
[ -s "$file" ] && VM_NET_MAC=$(<"$file")
@@ -380,7 +418,10 @@ getInfo
html "Initializing network..."
if [[ "$DEBUG" == [Yy1]* ]]; then
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC"
mtu=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu"
[[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)"
info "$line"
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
echo
fi
@@ -389,6 +430,11 @@ if [[ "$IP" == "172.17."* ]]; then
warn "your container IP starts with 172.17.* which will cause conflicts when you install the Container Manager package inside DSM!"
fi
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
info "Lingering interface will be removed..."
ip link delete "$VM_NET_TAP" || true
fi
if [[ "$DHCP" == [Yy1]* ]]; then
checkOS
@@ -418,15 +464,10 @@ else
# Configure for tap interface
if ! configureNAT; then
closeBridge
NETWORK="user"
warn "falling back to usermode networking! Performance will be bad and port mapping will not work."
ip link set "$VM_NET_TAP" down promisc off &> null || true
ip link delete "$VM_NET_TAP" &> null || true
ip link set dockerbridge down &> null || true
ip link delete dockerbridge &> null || true
fi
fi
@@ -440,6 +481,7 @@ else
fi
NET_OPTS+=" -device $ADAPTER,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,id=net0"
NET_OPTS+=" -device $ADAPTER,id=net0,netdev=hostnet0,romfile=,mac=$VM_NET_MAC"
[[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU"
return 0

View File

@@ -9,6 +9,23 @@ set -Eeuo pipefail
: "${CPU_MODEL:=""}"
: "${DEF_MODEL:="qemu64"}"
CLOCKSOURCE="tsc"
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
if [ ! -f "$CLOCK" ]; then
warn "file \"$CLOCK\" cannot not found?"
else
result=$(<"$CLOCK")
case "${result,,}" in
"${CLOCKSOURCE,,}" ) ;;
"kvm-clock" ) info "Nested KVM virtualization detected.." ;;
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected.." ;;
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
esac
fi
if [[ "${ARCH,,}" != "amd64" ]]; then
KVM="N"
warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for x64 instructions, this will cause a major loss of performance."
@@ -47,7 +64,6 @@ fi
if [[ "$KVM" != [Nn]* ]]; then
CPU_FEATURES="kvm=on,l3-cache=on,+hypervisor"
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
KVM_OPTS=",accel=kvm -enable-kvm -global kvm-pit.lost_tick_policy=discard"
if ! grep -qw "sse4_2" <<< "$flags"; then
@@ -61,15 +77,6 @@ if [[ "$KVM" != [Nn]* ]]; then
CPU_FEATURES+=",migratable=no"
fi
if [ -f "$CLOCK" ]; then
CLOCK=$(<"$CLOCK")
if [[ "${CLOCK,,}" != "tsc" ]]; then
warn "unexpected clocksource: $CLOCK"
fi
else
warn "file \"$CLOCK\" cannot not found?"
fi
if grep -qw "svm" <<< "$flags"; then
# AMD processor
@@ -127,7 +134,7 @@ else
fi
if [ -z "$HOST_CPU" ]; then
HOST_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')
[[ "${CPU,,}" != "unknown" ]] && HOST_CPU="$CPU"
fi
if [ -n "$HOST_CPU" ]; then

View File

@@ -17,7 +17,6 @@ echo " For support visit $SUPPORT"
: "${TZ:=""}" # System local timezone
: "${DEBUG:="N"}" # Disable debugging mode
: "${COMMIT:="N"}" # Commit to local image
: "${COUNTRY:=""}" # Country code for mirror
: "${CONSOLE:="N"}" # Disable console mode
: "${ALLOCATE:=""}" # Preallocate diskspace
@@ -64,12 +63,18 @@ if [ -z "${CPU// /}" ] && grep -qi "model:" <<< "$CPI"; then
fi
CPU="${CPU// CPU/}"
CPU="${CPU// 8 Core/}"
CPU="${CPU// 16 Core/}"
CPU="${CPU// 32 Core/}"
CPU="${CPU// 64 Core/}"
CPU="${CPU// Processor/}"
CPU="${CPU// Quad core/}"
CPU="${CPU// Core TM/ Core}"
CPU="${CPU// with Radeon Graphics/}"
CPU="${CPU// with Radeon Vega Graphics/}"
[ -z "${CPU// /}" ] && CPU="Unknown"
[[ -n ${CPU_CORES//[0-9]} ]] && error "Invalid amount of CPU_CORES: $CPU_CORES" && exit 15
# Check system
@@ -81,13 +86,13 @@ fi
# Check folder
if [[ "$COMMIT" != [Nn]* ]]; then
if [[ "${COMMIT:-}" == [Yy1]* ]]; then
STORAGE="/local"
mkdir -p "$STORAGE"
else
if [ ! -d "$STORAGE" ]; then
error "Storage folder ($STORAGE) not found!" && exit 13
fi
fi
if [ ! -d "$STORAGE" ]; then
error "Storage folder ($STORAGE) not found!" && exit 13
fi
# Check filesystem
@@ -102,8 +107,16 @@ fi
RAM_SPARE=500000000
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}')
if [[ -z ${RAM_SIZE//[0-9]} ]]; then
[ "$RAM_SIZE" -lt "130" ] && RAM_SIZE="${RAM_SIZE}G" || RAM_SIZE="${RAM_SIZE}M"
fi
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
! numfmt --from=iec "$RAM_SIZE" &>/dev/null && error "Invalid RAM size: $RAM_SIZE" && exit 16
RAM_WANTED=$(numfmt --from=iec "$RAM_SIZE")
[ "$RAM_WANTED" -lt "136314880 " ] && error "Invalid RAM size: $RAM_SIZE" && exit 16
AVAIL_GB=$(( RAM_AVAIL/1073741824 ))
TOTAL_GB=$(( (RAM_TOTAL + 1073741823)/1073741824 ))
WANTED_GB=$(( (RAM_WANTED + 1073741823)/1073741824 ))
@@ -121,6 +134,8 @@ echo
# Check memory
[[ "${FS,,}" == "zfs" ]] && RAM_CHECK="N"
if [[ "$RAM_CHECK" != [Nn]* ]]; then
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."