mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-24 06:48:00 +01:00
use btrfs on vm (#1668)
This commit is contained in:
parent
292949ff7f
commit
8fd5409856
2 changed files with 43 additions and 18 deletions
|
@ -15,7 +15,12 @@ if [ ${#error} -gt 0 ]; then
|
|||
fi
|
||||
|
||||
# temp mount
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddPartitionCandidate})
|
||||
if [ "$hddFormat" == "btrfs" ]; then
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddCandidate})
|
||||
else
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddPartitionCandidate})
|
||||
fi
|
||||
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL blitz.datadrive.sh tempmount --> ${error}"
|
||||
echo "Please report issue to the raspiblitz github."
|
||||
|
@ -39,7 +44,13 @@ echo
|
|||
echo "# --> Adding the data drive to OS ..."
|
||||
echo "# hddCandidate='${hddCandidate}'"
|
||||
echo "# hddPartitionCandidate='${hddPartitionCandidate}'"
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddPartitionCandidate})
|
||||
echo "# hddFormat='${hddFormat}'"
|
||||
if [ "$hddFormat" == "btrfs" ]; then
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddCandidate})
|
||||
else
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddPartitionCandidate})
|
||||
fi
|
||||
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL blitz.datadrive.sh fstab --> ${error}"
|
||||
echo "Please report issue to the raspiblitz github."
|
||||
|
|
|
@ -82,7 +82,6 @@ if [ "$1" = "status" ]; then
|
|||
hdd=""
|
||||
sizeDataPartition=0
|
||||
OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1 | sed "s/\/dev\///g")
|
||||
#echo "# OSPartition(${OSPartition})"
|
||||
|
||||
lsblk -o NAME,SIZE -b | grep -P "[s|v]d[a-z][0-9]?" > .lsblk.tmp
|
||||
while read line; do
|
||||
|
@ -105,8 +104,8 @@ if [ "$1" = "status" ]; then
|
|||
testpartitioncount=$((testpartitioncount-1))
|
||||
|
||||
if [ $testpartitioncount -gt 0 ]; then
|
||||
# if a partition was found - make sure to skip OS partition & if <=32gb
|
||||
if [ "$testpartition" != "$OSPartition" ] && [ ${testsize} -gt 32900000000 ]; then
|
||||
# if a partition was found - make sure to skip OS partition
|
||||
if [ "$testpartition" != "$OSPartition" ]; then
|
||||
|
||||
# make sure to use the biggest
|
||||
if [ ${testsize} -gt ${sizeDataPartition} ]; then
|
||||
|
@ -596,7 +595,15 @@ if [ "$1" = "fstab" ]; then
|
|||
fi
|
||||
|
||||
# check if exist and which format
|
||||
# if hdd is a partition (ext4)
|
||||
if [[ $hdd =~ [0-9] ]]; then
|
||||
# ext4
|
||||
hddFormat=$(lsblk -o FSTYPE,NAME | grep ${hdd} | cut -d ' ' -f 1)
|
||||
else
|
||||
# btrfs
|
||||
hddFormat=$(lsblk -o FSTYPE,NAME | grep ${hdd}1 | cut -d ' ' -f 1)
|
||||
fi
|
||||
|
||||
if [ ${#hddFormat} -eq 0 ]; then
|
||||
echo "# FAIL given device/partition not found"
|
||||
echo "error='device not found'"
|
||||
|
@ -851,10 +858,10 @@ if [ "$1" = "raid" ] && [ "$2" = "on" ]; then
|
|||
sudo parted -s /dev/${usbdev} rm ${v_partition}
|
||||
done
|
||||
|
||||
# check if usb device is at least 30GB groß
|
||||
# check if usb device is at least 30GB big
|
||||
usbdevsize=$(lsblk -o NAME,SIZE -b | grep "^${usbdev}" | awk '$1=$1' | cut -d " " -f 2)
|
||||
if [ ${usbdevsize} -lt 30000000000 ]; then
|
||||
>&2 echo "# FAIL ${usbdev} is smaller then the minumum 30GB"
|
||||
>&2 echo "# FAIL ${usbdev} is smaller than the minimum 30GB"
|
||||
echo "error='dev too small'"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -1016,15 +1023,24 @@ if [ "$1" = "tempmount" ]; then
|
|||
fi
|
||||
|
||||
# get device to temp mount
|
||||
hddDataPartition=$2
|
||||
if [ ${#hddDataPartition} -eq 0 ]; then
|
||||
hdd=$2
|
||||
if [ ${#hdd} -eq 0 ]; then
|
||||
>&2 echo "# FAIL which device should be temp mounted (e.g. sda)"
|
||||
>&2 echo "# run 'status' to see device candidates"
|
||||
echo "error='missing second parameter'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
hddFormat=$(lsblk -o FSTYPE,NAME | grep ${hddDataPartition} | cut -d ' ' -f 1)
|
||||
# if hdd is a partition
|
||||
if [[ $hdd =~ [0-9] ]]; then
|
||||
hddDataPartition=$hdd
|
||||
hddDataPartitionExt4=$hddDataPartition
|
||||
hddFormat=$(lsblk -o FSTYPE,NAME | grep ${hddDataPartitionExt4} | cut -d ' ' -f 1)
|
||||
else
|
||||
hddBTRFS=$hdd
|
||||
hddFormat=$(lsblk -o FSTYPE,NAME | grep ${hddBTRFS}1 | cut -d ' ' -f 1)
|
||||
fi
|
||||
|
||||
if [ ${#hddFormat} -eq 0 ]; then
|
||||
>&2 echo "# FAIL given device not found"
|
||||
echo "error='device not found'"
|
||||
|
@ -1032,7 +1048,6 @@ if [ "$1" = "tempmount" ]; then
|
|||
fi
|
||||
|
||||
if [ "${hddFormat}" = "ext4" ]; then
|
||||
hddDataPartitionExt4=$hddDataPartition
|
||||
|
||||
# do EXT4 temp mount
|
||||
sudo mkdir -p /mnt/hdd 1>/dev/null
|
||||
|
@ -1049,7 +1064,6 @@ if [ "$1" = "tempmount" ]; then
|
|||
fi
|
||||
|
||||
elif [ "${hddFormat}" = "btrfs" ]; then
|
||||
hdd=$hddDataPartition
|
||||
|
||||
# get user and grouid if usr/group bitcoin
|
||||
bitcoinUID=$(id -u bitcoin)
|
||||
|
@ -1059,9 +1073,9 @@ if [ "$1" = "tempmount" ]; then
|
|||
sudo mkdir -p /mnt/hdd 1>/dev/null
|
||||
sudo mkdir -p /mnt/storage 1>/dev/null
|
||||
sudo mkdir -p /mnt/temp 1>/dev/null
|
||||
sudo mount -t btrfs -o degraded -o subvol=WORKINGDIR /dev/${hdd}1 /mnt/hdd
|
||||
sudo mount -t btrfs -o subvol=WORKINGDIR /dev/${hdd}2 /mnt/storage
|
||||
sudo mount -o uid=${bitcoinUID},gid=${bitcoinGID} /dev/${hdd}3 /mnt/temp
|
||||
sudo mount -t btrfs -o degraded -o subvol=WORKINGDIR /dev/${hddBTRFS}1 /mnt/hdd
|
||||
sudo mount -t btrfs -o subvol=WORKINGDIR /dev/${hddBTRFS}2 /mnt/storage
|
||||
sudo mount -o uid=${bitcoinUID},gid=${bitcoinGID} /dev/${hddBTRFS}3 /mnt/temp
|
||||
|
||||
# check result
|
||||
isMountedA=$(df | grep -c "/mnt/hdd")
|
||||
|
|
Loading…
Add table
Reference in a new issue