mirror of
https://github.com/AuxXxilium/arv-v-dsm.git
synced 2024-11-23 15:00:57 +07:00
fix: Device support (#552)
This commit is contained in:
parent
a407d2d94d
commit
6a0c708224
17
readme.md
17
readme.md
@ -188,6 +188,23 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
|
||||
|
||||
This can be used to enable the facial recognition function in Synology Photos for example.
|
||||
|
||||
* ### How do I passthrough a disk?
|
||||
|
||||
When running the container inside a virtualized environment, it is recommended to passthrough disk devices directly instead of binding folders containing images, as these devices are already based on an image.
|
||||
|
||||
This allows for easier management and higher performance. To do so, you can add those devices to your compose file:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
DEVICE: "/dev/sda"
|
||||
DEVICE2: "/dev/sdb"
|
||||
devices:
|
||||
- /dev/sda
|
||||
- /dev/sdb
|
||||
```
|
||||
|
||||
Please beware that any existing data on the device will be wiped, as DSM will format its partition table during first use. Do NOT passthrough devices containing valueable data.
|
||||
|
||||
* ### How do I install a specific version of vDSM?
|
||||
|
||||
By default, version 7.2.1 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
|
||||
|
81
src/disk.sh
81
src/disk.sh
@ -401,6 +401,25 @@ addDisk () {
|
||||
return 0
|
||||
}
|
||||
|
||||
addDevice () {
|
||||
|
||||
local DISK_ID=$1
|
||||
local DISK_DEV=$2
|
||||
local DISK_DESC=$3
|
||||
local DISK_INDEX=$4
|
||||
local DISK_ADDRESS=$5
|
||||
|
||||
[ -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
|
||||
|
||||
DISK_OPTS="$DISK_OPTS \
|
||||
-device virtio-scsi-pci,id=hw-$DISK_ID,iothread=io2,bus=pcie.0,addr=$DISK_ADDRESS \
|
||||
-drive file=$DISK_DEV,if=none,id=drive-$DISK_ID,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
|
||||
-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"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
DISK_EXT="$(fmt2ext "$DISK_FMT")" || exit $?
|
||||
|
||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||
@ -444,52 +463,38 @@ if [ ! -f "$DISK3_FILE.img" ]; then
|
||||
fi
|
||||
|
||||
DISK4_FILE="/storage4/data4"
|
||||
DISK5_FILE="/storage5/data5"
|
||||
DISK6_FILE="/storage6/data6"
|
||||
|
||||
: ${DISK2_SIZE:=''}
|
||||
: ${DISK3_SIZE:=''}
|
||||
: ${DISK4_SIZE:=''}
|
||||
: ${DISK5_SIZE:=''}
|
||||
: ${DISK6_SIZE:=''}
|
||||
|
||||
addDisk "userdata" "$DISK1_FILE" "$DISK_EXT" "disk" "$DISK_SIZE" "3" "0xc" "$DISK_FMT" || exit $?
|
||||
addDisk "userdata2" "$DISK2_FILE" "$DISK_EXT" "disk2" "$DISK2_SIZE" "4" "0xd" "$DISK_FMT" || exit $?
|
||||
addDisk "userdata3" "$DISK3_FILE" "$DISK_EXT" "disk3" "$DISK3_SIZE" "5" "0xe" "$DISK_FMT" || exit $?
|
||||
addDisk "userdata4" "$DISK4_FILE" "$DISK_EXT" "disk4" "$DISK4_SIZE" "9" "0x7" "$DISK_FMT" || exit $?
|
||||
addDisk "userdata5" "$DISK5_FILE" "$DISK_EXT" "disk5" "$DISK5_SIZE" "10" "0x8" "$DISK_FMT" || exit $?
|
||||
addDisk "userdata6" "$DISK6_FILE" "$DISK_EXT" "disk6" "$DISK6_SIZE" "11" "0x9" "$DISK_FMT" || exit $?
|
||||
|
||||
addDevice () {
|
||||
|
||||
local DISK_ID=$1
|
||||
local DISK_DEV=$2
|
||||
local DISK_INDEX=$3
|
||||
local DISK_ADDRESS=$4
|
||||
|
||||
[ -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
|
||||
|
||||
DISK_OPTS="$DISK_OPTS \
|
||||
-device virtio-scsi-pci,id=hw-$DISK_ID,iothread=io2,bus=pcie.0,addr=$DISK_ADDRESS \
|
||||
-drive file=$DISK_DEV,if=none,id=drive-$DISK_ID,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
|
||||
-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"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
: ${DEVICE:=''} # Docker variable to passthrough a block device, like /dev/vdc1.
|
||||
: ${DEVICE:=''} # Docker variables to passthrough a block device, like /dev/vdc1.
|
||||
: ${DEVICE2:=''}
|
||||
: ${DEVICE3:=''}
|
||||
: ${DEVICE4:=''}
|
||||
: ${DEVICE5:=''}
|
||||
: ${DEVICE6:=''}
|
||||
|
||||
addDevice "userdata7" "$DEVICE" "6" "0xf" || exit $?
|
||||
addDevice "userdata8" "$DEVICE2" "7" "0x5" || exit $?
|
||||
addDevice "userdata9" "$DEVICE3" "8" "0x6" || exit $?
|
||||
addDevice "userdata4" "$DEVICE4" "9" "0x7" || exit $?
|
||||
addDevice "userdata5" "$DEVICE5" "10" "0x8" || exit $?
|
||||
addDevice "userdata6" "$DEVICE6" "11" "0x9" || exit $?
|
||||
if [ -n "$DEVICE" ]; then
|
||||
addDevice "userdata" "$DEVICE" "device" "3" "0xc" || exit $?
|
||||
else
|
||||
addDisk "userdata" "$DISK1_FILE" "$DISK_EXT" "disk" "$DISK_SIZE" "3" "0xc" "$DISK_FMT" || exit $?
|
||||
fi
|
||||
|
||||
if [ -n "$DEVICE2" ]; then
|
||||
addDevice "userdata2" "$DEVICE2" "device2" "4" "0xd" || exit $?
|
||||
else
|
||||
addDisk "userdata2" "$DISK2_FILE" "$DISK_EXT" "disk2" "$DISK2_SIZE" "4" "0xd" "$DISK_FMT" || exit $?
|
||||
fi
|
||||
|
||||
if [ -n "$DEVICE3" ]; then
|
||||
addDevice "userdata3" "$DEVICE3" "device3" "5" "0xe" || exit $?
|
||||
else
|
||||
addDisk "userdata3" "$DISK3_FILE" "$DISK_EXT" "disk3" "$DISK3_SIZE" "5" "0xe" "$DISK_FMT" || exit $?
|
||||
fi
|
||||
|
||||
if [ -n "$DEVICE4" ]; then
|
||||
addDevice "userdata4" "$DEVICE4" "device4" "6" "0xf" || exit $?
|
||||
else
|
||||
addDisk "userdata4" "$DISK4_FILE" "$DISK_EXT" "disk4" "$DISK4_SIZE" "6" "0xf" "$DISK_FMT" || exit $?
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user