2022-09-12 11:00:57 +02:00
|
|
|
#!/bin/bash
|
2022-10-06 09:46:45 +02:00
|
|
|
if [ "$VIRTUALISATION" = "true" ]
|
2022-07-30 14:02:57 +02:00
|
|
|
then
|
2022-11-29 15:00:52 +01:00
|
|
|
datadir=__DATADIR__
|
2022-10-06 09:46:45 +02:00
|
|
|
format=$1
|
|
|
|
i=0
|
|
|
|
while $(fdisk -l /dev/nbd$i 1&>2 /dev/null)
|
|
|
|
do
|
|
|
|
i=$(( i + 1 ))
|
|
|
|
done
|
2022-11-30 11:59:12 +01:00
|
|
|
echo $i > $datadir/nbd_index
|
2022-10-06 09:46:45 +02:00
|
|
|
modprobe nbd max_part=$(( i + 1 ))
|
2022-11-29 15:00:52 +01:00
|
|
|
qemu-nbd --connect /dev/nbd$i $datadir/garage_data.qcow2
|
2022-10-06 09:46:45 +02:00
|
|
|
if [[ "$format" = "true" ]]
|
|
|
|
then
|
2022-11-30 17:51:55 +01:00
|
|
|
echo "formatting /dev/nbd$i"
|
|
|
|
mkfs.ext4 /dev/nbd$i
|
2022-10-06 09:46:45 +02:00
|
|
|
fi
|
2022-11-29 15:00:52 +01:00
|
|
|
mkdir -p $datadir/data
|
2022-10-06 09:46:45 +02:00
|
|
|
mount /dev/nbd$i $datadir/data/
|
2022-07-30 14:02:57 +02:00
|
|
|
fi
|