mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-07 02:23:42 +08:00
Compare commits
9 Commits
v7.38
...
fefe1af9e6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fefe1af9e6 | ||
|
|
87a8cf7513 | ||
|
|
7f31cb6023 | ||
|
|
138742c953 | ||
|
|
2c6efc45f2 | ||
|
|
24d795fbe3 | ||
|
|
7fae62d286 | ||
|
|
2135df07ea | ||
|
|
521beedf1c |
@@ -28,6 +28,7 @@ RUN set -eu && \
|
|||||||
unzip \
|
unzip \
|
||||||
nginx \
|
nginx \
|
||||||
procps \
|
procps \
|
||||||
|
ethtool \
|
||||||
python3 \
|
python3 \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
python3-msgpack \
|
python3-msgpack \
|
||||||
@@ -57,7 +58,7 @@ RUN set -eu && \
|
|||||||
COPY --chmod=755 ./src /run/
|
COPY --chmod=755 ./src /run/
|
||||||
COPY --chmod=755 ./web /var/www/
|
COPY --chmod=755 ./web /var/www/
|
||||||
COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin
|
COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin
|
||||||
COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/sites-enabled/web.conf
|
COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/default.conf
|
||||||
ADD --chmod=775 https://raw.githubusercontent.com/sud0woodo/patology/refs/heads/main/patology.py /run/extract.py
|
ADD --chmod=775 https://raw.githubusercontent.com/sud0woodo/patology/refs/heads/main/patology.py /run/extract.py
|
||||||
|
|
||||||
VOLUME /storage
|
VOLUME /storage
|
||||||
@@ -65,7 +66,7 @@ EXPOSE 22 139 445 5000
|
|||||||
|
|
||||||
ENV RAM_SIZE="2G"
|
ENV RAM_SIZE="2G"
|
||||||
ENV CPU_CORES="2"
|
ENV CPU_CORES="2"
|
||||||
ENV DISK_SIZE="16G"
|
ENV DISK_SIZE="256G"
|
||||||
|
|
||||||
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
|
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ services:
|
|||||||
container_name: dsm
|
container_name: dsm
|
||||||
image: vdsm/virtual-dsm
|
image: vdsm/virtual-dsm
|
||||||
environment:
|
environment:
|
||||||
DISK_SIZE: "16G"
|
DISK_SIZE: "256G"
|
||||||
devices:
|
devices:
|
||||||
- /dev/kvm
|
- /dev/kvm
|
||||||
- /dev/net/tun
|
- /dev/net/tun
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ spec:
|
|||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 16Gi
|
storage: 256Gi
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -31,7 +31,7 @@ spec:
|
|||||||
image: vdsm/virtual-dsm
|
image: vdsm/virtual-dsm
|
||||||
env:
|
env:
|
||||||
- name: DISK_SIZE
|
- name: DISK_SIZE
|
||||||
value: "16G"
|
value: "256G"
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
name: http
|
name: http
|
||||||
|
|||||||
31
readme.md
31
readme.md
@@ -30,7 +30,7 @@ services:
|
|||||||
container_name: dsm
|
container_name: dsm
|
||||||
image: vdsm/virtual-dsm
|
image: vdsm/virtual-dsm
|
||||||
environment:
|
environment:
|
||||||
DISK_SIZE: "16G"
|
DISK_SIZE: "256G"
|
||||||
devices:
|
devices:
|
||||||
- /dev/kvm
|
- /dev/kvm
|
||||||
- /dev/net/tun
|
- /dev/net/tun
|
||||||
@@ -47,7 +47,7 @@ services:
|
|||||||
##### Via Docker CLI:
|
##### Via Docker CLI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
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
|
docker run -it --rm --name dsm -e "DISK_SIZE=256G" -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:
|
##### Via Kubernetes:
|
||||||
@@ -87,35 +87,24 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
### How do I change the size of the disk?
|
### How do I change the size of the disk?
|
||||||
|
|
||||||
To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity:
|
To expand the default size of 256 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
DISK_SIZE: "128G"
|
DISK_SIZE: "512G"
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> This can also be used to resize the existing disk to a larger capacity without any data loss.
|
> This can also be used to resize the existing disk to a larger capacity without any data loss.
|
||||||
|
|
||||||
### How do I create a growable disk?
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
DISK_FMT: "qcow2"
|
|
||||||
```
|
|
||||||
|
|
||||||
### How do I add multiple disks?
|
### How do I add multiple disks?
|
||||||
|
|
||||||
To create additional disks, modify your compose file like this:
|
To create additional disks, modify your compose file like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
DISK2_SIZE: "32G"
|
DISK2_SIZE: "500G"
|
||||||
DISK3_SIZE: "64G"
|
DISK3_SIZE: "750G"
|
||||||
volumes:
|
volumes:
|
||||||
- ./example2:/storage2
|
- ./example2:/storage2
|
||||||
- ./example3:/storage3
|
- ./example3:/storage3
|
||||||
@@ -263,14 +252,6 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses.
|
There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses.
|
||||||
|
|
||||||
### How do I run Windows in a container?
|
|
||||||
|
|
||||||
You can use [dockur/windows](https://github.com/dockur/windows) for that. It shares many of the same features, and even has completely automatic installation.
|
|
||||||
|
|
||||||
### How do I run a Linux desktop in a container?
|
|
||||||
|
|
||||||
You can use [qemus/qemu](https://github.com/qemus/qemu) in that case.
|
|
||||||
|
|
||||||
### Is this project legal?
|
### Is this project legal?
|
||||||
|
|
||||||
Yes, this project contains only open-source code and does not distribute any copyrighted material. Neither does it try to circumvent any copyright protection measures. So under all applicable laws, this project will be considered legal.
|
Yes, this project contains only open-source code and does not distribute any copyrighted material. Neither does it try to circumvent any copyright protection measures. So under all applicable laws, this project will be considered legal.
|
||||||
|
|||||||
13
src/disk.sh
13
src/disk.sh
@@ -507,13 +507,12 @@ addDevice () {
|
|||||||
physical="${physical%% *}"
|
physical="${physical%% *}"
|
||||||
|
|
||||||
if [ -n "$physical" ]; then
|
if [ -n "$physical" ]; then
|
||||||
if [[ "$physical" == "512" || "$physical" == "4096" ]]; then
|
if [[ "$physical" != "512" ]]; then
|
||||||
if [[ "$physical" == "4096" ]]; then
|
|
||||||
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
||||||
fi
|
if [[ "$physical" != "4096" && "$physical" != "32768" ]]; then
|
||||||
else
|
|
||||||
warn "Unknown physical sector size: $physical for $DISK_DEV"
|
warn "Unknown physical sector size: $physical for $DISK_DEV"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
warn "Failed to determine the sector size for $DISK_DEV"
|
warn "Failed to determine the sector size for $DISK_DEV"
|
||||||
fi
|
fi
|
||||||
@@ -535,12 +534,8 @@ case "${DISK_TYPE,,}" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$ALLOCATE" ]; then
|
if [ -z "$ALLOCATE" ]; then
|
||||||
if [[ "${DISK_FMT,,}" == "raw" ]]; then
|
|
||||||
ALLOCATE="Y"
|
|
||||||
else
|
|
||||||
ALLOCATE="N"
|
ALLOCATE="N"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||||
DISK_STYLE="growable"
|
DISK_STYLE="growable"
|
||||||
@@ -554,7 +549,7 @@ DISK_OPTS+=$(createDevice "$BOOT" "$DISK_TYPE" "1" "0xa" "raw" "$DISK_IO" "$DISK
|
|||||||
DISK_OPTS+=$(createDevice "$SYSTEM" "$DISK_TYPE" "2" "0xb" "raw" "$DISK_IO" "$DISK_CACHE" "" "")
|
DISK_OPTS+=$(createDevice "$SYSTEM" "$DISK_TYPE" "2" "0xb" "raw" "$DISK_IO" "$DISK_CACHE" "" "")
|
||||||
|
|
||||||
DISK1_FILE="$STORAGE/${DISK_NAME}"
|
DISK1_FILE="$STORAGE/${DISK_NAME}"
|
||||||
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
|
||||||
mv "$STORAGE/data${DISK_SIZE}.img" "$DISK1_FILE.img"
|
mv "$STORAGE/data${DISK_SIZE}.img" "$DISK1_FILE.img"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ configureDHCP() {
|
|||||||
|
|
||||||
while ! ip link set "$VM_NET_TAP" up; do
|
while ! ip link set "$VM_NET_TAP" up; do
|
||||||
info "Waiting for MAC address $VM_NET_MAC to become available..."
|
info "Waiting for MAC address $VM_NET_MAC to become available..."
|
||||||
|
info "If you cloned this machine, please delete the 'dsm.mac' file to generate a different MAC address."
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -172,7 +173,7 @@ getUserPorts() {
|
|||||||
|
|
||||||
getHostPorts() {
|
getHostPorts() {
|
||||||
|
|
||||||
local list=$1
|
local list="$1"
|
||||||
|
|
||||||
[ -z "$list" ] && echo "" && return 0
|
[ -z "$list" ] && echo "" && return 0
|
||||||
|
|
||||||
@@ -392,6 +393,13 @@ getInfo() {
|
|||||||
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26
|
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
NIC=$(ethtool -i "$VM_NET_DEV" | grep -m 1 -i 'driver:' | awk '{print $(2)}')
|
||||||
|
|
||||||
|
if [[ "${NIC,,}" != "veth" && "${NIC,,}" != "macvlan" ]]; then
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && info "Detected NIC: $NIC"
|
||||||
|
error "This container does not support host mode networking!" && exit 29
|
||||||
|
fi
|
||||||
|
|
||||||
BASE_IP="${VM_NET_IP%.*}."
|
BASE_IP="${VM_NET_IP%.*}."
|
||||||
|
|
||||||
if [ "${VM_NET_IP/$BASE_IP/}" -lt "3" ]; then
|
if [ "${VM_NET_IP/$BASE_IP/}" -lt "3" ]; then
|
||||||
@@ -526,7 +534,7 @@ else
|
|||||||
msg="podman detected, $msg"
|
msg="podman detected, $msg"
|
||||||
fi
|
fi
|
||||||
warn "$msg"
|
warn "$msg"
|
||||||
[ -z "$USER_PORTS" ] && info "Notice: port mapping will not work without \"USER_PORTS\" now."
|
[ -z "$USER_PORTS" ] && info "Notice: when you want to expose ports in this mode, map them using this variable: \"USER_PORTS=5000,5001\"."
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
13
src/reset.sh
13
src/reset.sh
@@ -202,19 +202,22 @@ addPackage() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
: "${WEB_PORT:="5000"}" # Webserver port
|
||||||
|
|
||||||
cp -r /var/www/* /run/shm
|
cp -r /var/www/* /run/shm
|
||||||
html "Starting $APP for Docker..."
|
html "Starting $APP for Docker..."
|
||||||
|
|
||||||
if [[ "${WEB:-}" != [Nn]* ]]; then
|
if [[ "${WEB:-}" != [Nn]* ]]; then
|
||||||
|
|
||||||
|
mkdir -p /etc/nginx/sites-enabled
|
||||||
|
cp /etc/nginx/default.conf /etc/nginx/sites-enabled/web.conf
|
||||||
|
|
||||||
|
sed -i "s/listen 5000 default_server;/listen $WEB_PORT default_server;/g" /etc/nginx/sites-enabled/web.conf
|
||||||
|
|
||||||
# shellcheck disable=SC2143
|
# shellcheck disable=SC2143
|
||||||
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
|
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
|
sed -i "s/listen $WEB_PORT default_server;/listen [::]:$WEB_PORT 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
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user