mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-06 18:13:43 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ce14f6c2d | ||
|
|
272e491281 | ||
|
|
0518e1100b | ||
|
|
8aa797b557 | ||
|
|
4356e5ebf9 | ||
|
|
502c068d30 | ||
|
|
d5e3ed8907 | ||
|
|
f0e5a61e73 | ||
|
|
b07577b60d | ||
|
|
4571fe9c4f | ||
|
|
9f6fbc3f7c | ||
|
|
bbc033f032 | ||
|
|
160e5a07be | ||
|
|
0cca2a7079 | ||
|
|
64257d1a6f | ||
|
|
d6dde093b2 | ||
|
|
d1957f5eb7 | ||
|
|
f3f9a9f480 | ||
|
|
15d67203c9 | ||
|
|
c33c63114e | ||
|
|
80169e6b50 | ||
|
|
61f733fe66 | ||
|
|
03da1f38f4 | ||
|
|
8543ea5dad | ||
|
|
36ebb950eb | ||
|
|
76ad3ff502 | ||
|
|
4673feb282 | ||
|
|
df6436bf6a | ||
|
|
d904ebfc85 |
@@ -143,9 +143,11 @@ else
|
||||
MSG="http://${IP}:5000"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
info "--------------------------------------------------------"
|
||||
info " You can now login to DSM at ${MSG}"
|
||||
info "--------------------------------------------------------"
|
||||
echo ""
|
||||
|
||||
# Wait for NMI interrupt as a shutdown signal
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
|
||||
DISK_SIZE: "256G"
|
||||
```
|
||||
|
||||
This can also be used to resize the existing disk to a larger capacity without data loss.
|
||||
|
||||
* ### 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:
|
||||
|
||||
19
run/disk.sh
19
run/disk.sh
@@ -39,7 +39,9 @@ if [ -f "${DATA}" ]; then
|
||||
if [[ "${ALLOCATE}" == [Nn]* ]]; then
|
||||
|
||||
# Resize file by changing its length
|
||||
truncate -s "${DATA_SIZE}" "${DATA}";
|
||||
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
|
||||
error "Could not resize the file for the virtual disk." && exit 85
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
@@ -55,7 +57,9 @@ if [ -f "${DATA}" ]; then
|
||||
|
||||
# Resize file by allocating more space
|
||||
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
|
||||
error "Could not allocate a file for the virtual disk." && exit 85
|
||||
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
|
||||
error "Could not resize the file for the virtual disk." && exit 85
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${ALLOCATE}" == [Zz]* ]]; then
|
||||
@@ -84,7 +88,10 @@ if [ ! -f "${DATA}" ]; then
|
||||
if [[ "${ALLOCATE}" == [Nn]* ]]; then
|
||||
|
||||
# Create an empty file
|
||||
truncate -s "${DATA_SIZE}" "${DATA}"
|
||||
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
|
||||
rm -f "${DATA}"
|
||||
error "Could not create a file for the virtual disk." && exit 87
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
@@ -98,8 +105,10 @@ if [ ! -f "${DATA}" ]; then
|
||||
|
||||
# Create an empty file
|
||||
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
|
||||
rm -f "${DATA}"
|
||||
error "Could not allocate a file for the virtual disk." && exit 87
|
||||
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
|
||||
rm -f "${DATA}"
|
||||
error "Could not create a file for the virtual disk." && exit 87
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${ALLOCATE}" == [Zz]* ]]; then
|
||||
|
||||
@@ -10,7 +10,7 @@ DL="https://global.synologydownload.com/download/DSM"
|
||||
if [ -z "$URL" ]; then
|
||||
|
||||
if [ "$ARCH" == "amd64" ]; then
|
||||
URL="$DL/release/7.2/64561/DSM_VirtualDSM_64561.pat"
|
||||
URL="$DL/release/7.2/64570-1/DSM_VirtualDSM_64570.pat"
|
||||
else
|
||||
URL="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
|
||||
fi
|
||||
@@ -179,7 +179,9 @@ SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1)
|
||||
(( SYSTEM_SIZE > SPACE )) && error "Not enough free space to create a 4 GB system disk." && exit 87
|
||||
|
||||
if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then
|
||||
rm -f "${SYSTEM}" && error "Could not allocate a file for the system disk." && exit 88
|
||||
if ! truncate -s "${SYSTEM_SIZE}" "${SYSTEM}"; then
|
||||
rm -f "${SYSTEM}" && error "Could not allocate a file for the system disk." && exit 88
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${ALLOCATE}" == [Zz]* ]]; then
|
||||
|
||||
@@ -31,7 +31,10 @@ configureDHCP() {
|
||||
error "and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 16
|
||||
fi
|
||||
|
||||
ip link set "${VM_NET_TAP}" up
|
||||
while ! ip link set "${VM_NET_TAP}" up; do
|
||||
info "Waiting for address to become available..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
TAP_NR=$(</sys/class/net/"${VM_NET_TAP}"/ifindex)
|
||||
TAP_PATH="/dev/tap${TAP_NR}"
|
||||
@@ -127,11 +130,20 @@ configureNAT () {
|
||||
fi
|
||||
|
||||
ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge
|
||||
ip link set dockerbridge up
|
||||
|
||||
while ! ip link set dockerbridge up; do
|
||||
info "Waiting for address to become available..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# QEMU Works with taps, set tap to the bridge created
|
||||
ip tuntap add dev "${VM_NET_TAP}" mode tap
|
||||
ip link set "${VM_NET_TAP}" up promisc on
|
||||
|
||||
while ! ip link set "${VM_NET_TAP}" up promisc on; do
|
||||
info "Waiting for tap to become available..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
ip link set dev "${VM_NET_TAP}" master dockerbridge
|
||||
|
||||
# Add internet connection to the VM
|
||||
@@ -165,6 +177,24 @@ configureNAT () {
|
||||
return 0
|
||||
}
|
||||
|
||||
closeNetwork () {
|
||||
|
||||
if [[ "${DHCP}" == [Yy1]* ]]; then
|
||||
|
||||
ip link set "${VM_NET_TAP}" down || true
|
||||
ip link delete "${VM_NET_TAP}" || true
|
||||
|
||||
else
|
||||
|
||||
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
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
# ######################################
|
||||
# Configure Network
|
||||
# ######################################
|
||||
|
||||
@@ -81,6 +81,8 @@ _graceful_shutdown() {
|
||||
echo && echo "❯ Quitting..."
|
||||
echo 'quit' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" >/dev/null 2>&1 || true
|
||||
|
||||
closeNetwork
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
14
run/run.sh
14
run/run.sh
@@ -6,6 +6,7 @@ set -Eeuo pipefail
|
||||
: ${URL:=''} # URL of the PAT file
|
||||
: ${DEBUG:='N'} # Enable debug mode
|
||||
: ${ALLOCATE:='Y'} # Preallocate diskspace
|
||||
: ${ARGUMENTS:=''} # Extra QEMU parameters
|
||||
: ${CPU_CORES:='1'} # Amount of CPU cores
|
||||
: ${DISK_SIZE:='16G'} # Initial data disk size
|
||||
: ${RAM_SIZE:='512M'} # Maximum RAM amount
|
||||
@@ -21,6 +22,7 @@ trap 'error "Status $? while: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR
|
||||
|
||||
STORAGE="/storage"
|
||||
KERNEL=$(uname -r | cut -b 1)
|
||||
MINOR=$(uname -r | cut -d '.' -f2)
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1)
|
||||
|
||||
@@ -79,7 +81,7 @@ EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
|
||||
EXTRA_OPTS="$EXTRA_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"
|
||||
EXTRA_OPTS="$EXTRA_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c"
|
||||
|
||||
ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${MAC_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}"
|
||||
ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${MAC_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS} ${ARGUMENTS}"
|
||||
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
|
||||
|
||||
trap - ERR
|
||||
@@ -92,8 +94,8 @@ set -m
|
||||
)
|
||||
set +m
|
||||
|
||||
if (( KERNEL > 4 )); then
|
||||
pidwait -F "${_QEMU_PID}" & wait $!
|
||||
else
|
||||
tail --pid "$(cat "${_QEMU_PID}")" --follow /dev/null & wait $!
|
||||
fi
|
||||
#if (( KERNEL > 5 )) || ( (( KERNEL == 5 )) && (( MINOR > 2 )) ); then
|
||||
# pidwait -F "${_QEMU_PID}" & wait $!
|
||||
#else
|
||||
|
||||
tail --pid "$(cat "${_QEMU_PID}")" --follow /dev/null & wait $!
|
||||
|
||||
@@ -31,7 +31,7 @@ HOST_ARGS=()
|
||||
HOST_ARGS+=("-cpu=${CPU_CORES}")
|
||||
HOST_ARGS+=("-cpu_arch=${HOST_CPU}")
|
||||
|
||||
[ -n "$HOST_MAC" ] && HOST_ARGS+=("-mac=${HOST_MAC//:/-}")
|
||||
[ -n "$HOST_MAC" ] && HOST_ARGS+=("-mac=${HOST_MAC}")
|
||||
[ -n "$HOST_BUILD" ] && HOST_ARGS+=("-build=${HOST_BUILD}")
|
||||
[ -n "$HOST_MODEL" ] && HOST_ARGS+=("-model=${HOST_MODEL}")
|
||||
[ -n "$HOST_SERIAL" ] && HOST_ARGS+=("-hostsn=${HOST_SERIAL}")
|
||||
|
||||
Reference in New Issue
Block a user