From 5e3d4e8b3c9136edf540da82973dbe13d15e8038 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 10 Oct 2023 06:29:03 +0200 Subject: [PATCH 1/2] feat: Mount block device --- run/disk.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/run/disk.sh b/run/disk.sh index 90865a23..3f1b41ea 100644 --- a/run/disk.sh +++ b/run/disk.sh @@ -163,6 +163,10 @@ if [ -f "${DATA2}" ]; then -drive file=${DATA2},if=none,id=drive-userdata2,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ -device scsi-hd,bus=hw-userdata2.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata2,id=userdata2,rotation_rate=${DISK_ROTATION},bootindex=4" +else + + [ -d "/storage2" ] && error "Disk image ${DATA2} does not exist! Use an empty file of at least 6 GB." && exit 53 + fi DATA3="/storage3/data.img" @@ -174,11 +178,17 @@ if [ -f "${DATA3}" ]; then -drive file=${DATA3},if=none,id=drive-userdata3,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ -device scsi-hd,bus=hw-userdata3.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata3,id=userdata3,rotation_rate=${DISK_ROTATION},bootindex=5" +else + + [ -d "/storage3" ] && error "Disk image ${DATA3} does not exist! Use an empty file of at least 6 GB." && exit 54 + fi -DEVICE="/device" +: ${DEVICE:=''} # Docker variable to passthrough a block device, like /dev/vdc1. + +if [ -n "${DEVICE}" ]; then -if [ -d "${DEVICE}" ]; then + [ ! -b "${DEVICE}" ] && error "Device ${DEVICE} 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-userdata4,bus=pcie.0,addr=0xf \ From 75fc1ab57003e27cbb97116bb615d06c07444e87 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 10 Oct 2023 06:39:59 +0200 Subject: [PATCH 2/2] feat: Mount block device --- run/disk.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/run/disk.sh b/run/disk.sh index 3f1b41ea..2470f96d 100644 --- a/run/disk.sh +++ b/run/disk.sh @@ -154,33 +154,33 @@ DISK_OPTS="\ -drive file=${DATA},if=none,id=drive-userdata,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ -device scsi-hd,bus=hw-userdata.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata,id=userdata0,rotation_rate=${DISK_ROTATION},bootindex=3" -DATA2="/storage2/data.img" +EXTRA_DISK="/storage2/data.img" -if [ -f "${DATA2}" ]; then +if [ -f "${EXTRA_DISK}" ]; then DISK_OPTS="${DISK_OPTS} \ -device virtio-scsi-pci,id=hw-userdata2,bus=pcie.0,addr=0xd \ - -drive file=${DATA2},if=none,id=drive-userdata2,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ + -drive file=${EXTRA_DISK},if=none,id=drive-userdata2,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ -device scsi-hd,bus=hw-userdata2.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata2,id=userdata2,rotation_rate=${DISK_ROTATION},bootindex=4" else - [ -d "/storage2" ] && error "Disk image ${DATA2} does not exist! Use an empty file of at least 6 GB." && exit 53 + [ -d "$(dirname "${EXTRA_DISK}")" ] && error "Disk image ${EXTRA_DISK} does not exist! Please supply an empty file of at least 6 GB." && exit 53 fi -DATA3="/storage3/data.img" +EXTRA_DISK="/storage3/data.img" -if [ -f "${DATA3}" ]; then +if [ -f "${EXTRA_DISK}" ]; then DISK_OPTS="${DISK_OPTS} \ -device virtio-scsi-pci,id=hw-userdata3,bus=pcie.0,addr=0xe \ - -drive file=${DATA3},if=none,id=drive-userdata3,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ + -drive file=${EXTRA_DISK},if=none,id=drive-userdata3,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ -device scsi-hd,bus=hw-userdata3.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata3,id=userdata3,rotation_rate=${DISK_ROTATION},bootindex=5" else - [ -d "/storage3" ] && error "Disk image ${DATA3} does not exist! Use an empty file of at least 6 GB." && exit 54 + [ -d "$(dirname "${EXTRA_DISK}")" ] && error "Disk image ${EXTRA_DISK} does not exist! Please supply an empty file of at least 6 GB." && exit 54 fi