mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-09 03:23:40 +08:00
Compare commits
6 Commits
7ad5c7fa70
...
v7.31
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4018eeadb4 | ||
|
|
a8e4647fa6 | ||
|
|
36d3fca4fc | ||
|
|
89b28f36d3 | ||
|
|
b4f7d70a7a | ||
|
|
902bafbd0c |
21
readme.md
21
readme.md
@@ -72,9 +72,11 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
Very simple! These are the steps:
|
Very simple! These are the steps:
|
||||||
|
|
||||||
- Start the container and connect to [port 5000](http://localhost:5000) using your web browser.
|
- Start the container and connect to [port 5000](http://127.0.0.1:5000/) using your web browser.
|
||||||
|
|
||||||
- Wait until DSM is ready, choose an username and password, and you will be taken to the desktop.
|
- Wait until DSM finishes its installation
|
||||||
|
|
||||||
|
- Choose an username and password, and you will be taken to the desktop.
|
||||||
|
|
||||||
Enjoy your brand new NAS, and don't forget to star this repo!
|
Enjoy your brand new NAS, and don't forget to star this repo!
|
||||||
|
|
||||||
@@ -103,7 +105,7 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
### How do I create a growable disk?
|
### How do I create a growable disk?
|
||||||
|
|
||||||
By default, the entire capacity of the disk is reserved in advance.
|
By default, the entire capacity of the disk will be reserved in advance.
|
||||||
|
|
||||||
To create a growable disk that only allocates space that is actually used, add the following environment variable:
|
To create a growable disk that only allocates space that is actually used, add the following environment variable:
|
||||||
|
|
||||||
@@ -127,20 +129,21 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
### How do I pass-through a disk?
|
### How do I pass-through a disk?
|
||||||
|
|
||||||
It is possible to pass-through a disk device directly, by adding it to your compose file in this way:
|
It is possible to pass-through a disk device directly, which can be useful when your host is a virtual machine, as it removes an extra layer and allows for easier management. For use with physical disks this method provides little advantage and is not recommended.
|
||||||
|
|
||||||
|
You can add the virtual device to your compose file like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
devices:
|
devices:
|
||||||
- /dev/disk/by-uuid/12345-12345-12345-12345-12345:/disk2
|
- /dev/disk/by-uuid/12345-12345-12345-12345-12345:/disk2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The device needs to be totally empty (without any partition table) otherwise DSM does not always format it into a volume.
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
> [!IMPORTANT]
|
|
||||||
> The device needs to be totally empty (without any partition table) otherwise DSM does not always format it into a volume.
|
|
||||||
|
|
||||||
> [!CAUTION]
|
> [!CAUTION]
|
||||||
> 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 might all get lost without warning when DSM creates the volume.
|
||||||
|
|
||||||
### How do I change the amount of CPU or RAM?
|
### How do I change the amount of CPU or RAM?
|
||||||
|
|
||||||
@@ -256,7 +259,7 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
With this method, it is even possible to switch back and forth between versions while keeping 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:
|
If you don't have internet access, it's also possible to skip the download by setting `URL` to:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
22
src/disk.sh
22
src/disk.sh
@@ -141,10 +141,12 @@ createDisk() {
|
|||||||
else
|
else
|
||||||
|
|
||||||
# Create an empty file
|
# Create an empty file
|
||||||
if ! fallocate -l "$DATA_SIZE" "$DISK_FILE"; then
|
if ! fallocate -l "$DATA_SIZE" "$DISK_FILE" &>/dev/null; then
|
||||||
if ! truncate -s "$DATA_SIZE" "$DISK_FILE"; then
|
if ! fallocate -l -x "$DATA_SIZE" "$DISK_FILE"; then
|
||||||
rm -f "$DISK_FILE"
|
if ! truncate -s "$DATA_SIZE" "$DISK_FILE"; then
|
||||||
error "$FAIL" && exit 77
|
rm -f "$DISK_FILE"
|
||||||
|
error "$FAIL" && exit 77
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -219,9 +221,11 @@ resizeDisk() {
|
|||||||
else
|
else
|
||||||
|
|
||||||
# Resize file by allocating more space
|
# Resize file by allocating more space
|
||||||
if ! fallocate -l "$DATA_SIZE" "$DISK_FILE"; then
|
if ! fallocate -l "$DATA_SIZE" "$DISK_FILE" &>/dev/null; then
|
||||||
if ! truncate -s "$DATA_SIZE" "$DISK_FILE"; then
|
if ! fallocate -l -x "$DATA_SIZE" "$DISK_FILE"; then
|
||||||
error "$FAIL" && exit 75
|
if ! truncate -s "$DATA_SIZE" "$DISK_FILE"; then
|
||||||
|
error "$FAIL" && exit 75
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -296,8 +300,10 @@ convertDisk() {
|
|||||||
if [[ "$ALLOCATE" != [Nn]* ]]; then
|
if [[ "$ALLOCATE" != [Nn]* ]]; then
|
||||||
# Work around qemu-img bug
|
# Work around qemu-img bug
|
||||||
CUR_SIZE=$(stat -c%s "$TMP_FILE")
|
CUR_SIZE=$(stat -c%s "$TMP_FILE")
|
||||||
if ! fallocate -l "$CUR_SIZE" "$TMP_FILE"; then
|
if ! fallocate -l "$CUR_SIZE" "$TMP_FILE" &>/dev/null; then
|
||||||
|
if ! fallocate -l -x "$CUR_SIZE" "$TMP_FILE"; then
|
||||||
error "Failed to allocate $CUR_SIZE bytes for $DISK_DESC image $TMP_FILE"
|
error "Failed to allocate $CUR_SIZE bytes for $DISK_DESC image $TMP_FILE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -328,10 +328,12 @@ if [[ "${FS,,}" == "btrfs" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! fallocate -l "$SYSTEM_SIZE" "$SYSTEM"; then
|
if ! fallocate -l "$SYSTEM_SIZE" "$SYSTEM" &>/dev/null; then
|
||||||
if ! truncate -s "$SYSTEM_SIZE" "$SYSTEM"; then
|
if ! fallocate -l -x "$SYSTEM_SIZE" "$SYSTEM"; then
|
||||||
rm -f "$SYSTEM"
|
if ! truncate -s "$SYSTEM_SIZE" "$SYSTEM"; then
|
||||||
error "Could not allocate file $SYSTEM for the system disk." && exit 98
|
rm -f "$SYSTEM"
|
||||||
|
error "Could not allocate file $SYSTEM for the system disk." && exit 98
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,12 @@ configureDNS() {
|
|||||||
|
|
||||||
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
||||||
|
|
||||||
|
if [[ "${DEBUG_DNS:-}" == [Yy1]* ]]; then
|
||||||
|
DNSMASQ_OPTS+=" -d"
|
||||||
|
$DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} &
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
|
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
|
||||||
error "Failed to start dnsmasq, reason: $?" && return 1
|
error "Failed to start dnsmasq, reason: $?" && return 1
|
||||||
fi
|
fi
|
||||||
@@ -206,7 +212,7 @@ configureNAT() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if ! ip address add "${VM_NET_IP%.*}.1/24" broadcast "${VM_NET_IP%.*}.255" dev dockerbridge; then
|
if ! ip address add "${VM_NET_IP%.*}.1/24" broadcast "${VM_NET_IP%.*}.255" dev dockerbridge; then
|
||||||
error "Failed to add IP address!" && return 1
|
error "Failed to add IP address pool!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while ! ip link set dockerbridge up; do
|
while ! ip link set dockerbridge up; do
|
||||||
@@ -255,7 +261,7 @@ configureNAT() {
|
|||||||
error "Failed to configure IP tables!" && return 1
|
error "Failed to configure IP tables!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! iptables -t nat -A PREROUTING -i "$VM_NET_DEV" -d "$IP" -p udp -j DNAT --to "$VM_NET_IP"; then
|
if ! iptables -t nat -A PREROUTING -i "$VM_NET_DEV" -d "$IP" -p udp -j DNAT --to "$VM_NET_IP"; then
|
||||||
error "Failed to configure IP tables!" && return 1
|
error "Failed to configure IP tables!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -398,8 +404,16 @@ 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 route list dev "$VM_NET_DEV" | awk ' /^default/ {print $3}')
|
GATEWAY=$(ip route list dev "$VM_NET_DEV" | awk ' /^default/ {print $3}' | head -n 1)
|
||||||
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/ | head -n 1)
|
||||||
|
|
||||||
|
IP6=""
|
||||||
|
# shellcheck disable=SC2143
|
||||||
|
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
|
||||||
|
IP6=$(ip -6 addr show dev "$VM_NET_DEV" scope global up)
|
||||||
|
[ -n "$IP6" ] && IP6=$(echo "$IP6" | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | head -n 1)
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$IP" > /run/shm/qemu.ip
|
echo "$IP" > /run/shm/qemu.ip
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -431,8 +445,8 @@ if [[ "$IP" == "172.17."* ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
|
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
|
||||||
info "Lingering interface will be removed..."
|
info "Lingering interface will be removed..."
|
||||||
ip link delete "$VM_NET_TAP" || true
|
ip link delete "$VM_NET_TAP" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
@@ -466,7 +480,7 @@ else
|
|||||||
|
|
||||||
closeBridge
|
closeBridge
|
||||||
NETWORK="user"
|
NETWORK="user"
|
||||||
warn "falling back to usermode networking! Performance will be bad and port mapping will not work."
|
warn "falling back to user-mode networking! Performance will be bad and port mapping will not work."
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -474,7 +488,7 @@ else
|
|||||||
|
|
||||||
if [[ "${NETWORK,,}" == "user"* ]]; then
|
if [[ "${NETWORK,,}" == "user"* ]]; then
|
||||||
|
|
||||||
# Configure for usermode networking (slirp)
|
# Configure for user-mode networking (slirp)
|
||||||
configureUser || exit 24
|
configureUser || exit 24
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
18
src/reset.sh
18
src/reset.sh
@@ -63,10 +63,17 @@ if [ -z "${CPU// /}" ] && grep -qi "model:" <<< "$CPI"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
CPU="${CPU// CPU/}"
|
CPU="${CPU// CPU/}"
|
||||||
|
CPU="${CPU// 6 Core/}"
|
||||||
CPU="${CPU// 8 Core/}"
|
CPU="${CPU// 8 Core/}"
|
||||||
CPU="${CPU// 16 Core/}"
|
CPU="${CPU// 16 Core/}"
|
||||||
CPU="${CPU// 32 Core/}"
|
CPU="${CPU// 32 Core/}"
|
||||||
CPU="${CPU// 64 Core/}"
|
CPU="${CPU// 64 Core/}"
|
||||||
|
CPU="${CPU//10th Gen /}"
|
||||||
|
CPU="${CPU//11th Gen /}"
|
||||||
|
CPU="${CPU//12th Gen /}"
|
||||||
|
CPU="${CPU//13th Gen /}"
|
||||||
|
CPU="${CPU//14th Gen /}"
|
||||||
|
CPU="${CPU//15th Gen /}"
|
||||||
CPU="${CPU// Processor/}"
|
CPU="${CPU// Processor/}"
|
||||||
CPU="${CPU// Quad core/}"
|
CPU="${CPU// Quad core/}"
|
||||||
CPU="${CPU// Core TM/ Core}"
|
CPU="${CPU// Core TM/ Core}"
|
||||||
@@ -319,6 +326,17 @@ addPackage() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shellcheck disable=SC2143
|
||||||
|
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
|
||||||
|
|
||||||
|
sed -i "s/listen 5000 default_server;/listen [::]:5000 default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
sed -i "s/listen [::]:5000 default_server ipv6only=off;/listen 5000 default_server;/g" /etc/nginx/sites-enabled/web.conf
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Start webserver
|
# Start webserver
|
||||||
cp -r /var/www/* /run/shm
|
cp -r /var/www/* /run/shm
|
||||||
html "Starting $APP for Docker..."
|
html "Starting $APP for Docker..."
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
|
||||||
listen 5000 default_server;
|
listen 5000 default_server;
|
||||||
|
|
||||||
autoindex on;
|
autoindex on;
|
||||||
|
|||||||
Reference in New Issue
Block a user