mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-10-09 20:32:52 +02:00
allow datadrive script to format non system drives
This commit is contained in:
@@ -303,14 +303,16 @@ if [ "$1" = "format" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
>&2 echo "# Checking on SWAP"
|
# get basic info on data drives
|
||||||
if [ ${isSwapExternal} -eq 1 ]; then
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||||
>&2 echo "# Switching off external SWAP"
|
|
||||||
|
if [ ${isSwapExternal} -eq 1 ] && [ "${hdd}" == "${datadisk}" ]; then
|
||||||
|
>&2 echo "# Switching off external SWAP of system drive"
|
||||||
sudo dphys-swapfile swapoff 1>/dev/null
|
sudo dphys-swapfile swapoff 1>/dev/null
|
||||||
sudo dphys-swapfile uninstall 1>/dev/null
|
sudo dphys-swapfile uninstall 1>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
>&2 echo "# Unmounting all data drives"
|
>&2 echo "# Unmounting all partitions of this device"
|
||||||
# remove device from all system mounts (also fstab)
|
# remove device from all system mounts (also fstab)
|
||||||
lsblk -o NAME,UUID | grep "${hdd}" | awk '$1=$1' | cut -d " " -f 2 | grep "-" | while read -r uuid ; do
|
lsblk -o NAME,UUID | grep "${hdd}" | awk '$1=$1' | cut -d " " -f 2 | grep "-" | while read -r uuid ; do
|
||||||
>&2 echo "# Cleaning /etc/fstab from ${uuid}"
|
>&2 echo "# Cleaning /etc/fstab from ${uuid}"
|
||||||
@@ -319,7 +321,8 @@ if [ "$1" = "format" ]; then
|
|||||||
done
|
done
|
||||||
sudo mount -a
|
sudo mount -a
|
||||||
|
|
||||||
# unmount drives
|
if [ "${hdd}" == "${datadisk}" ]; then
|
||||||
|
>&2 echo "# Make sure system drives are unmounted .."
|
||||||
sudo umount /mnt/hdd 2>/dev/null
|
sudo umount /mnt/hdd 2>/dev/null
|
||||||
sudo umount /mnt/temp 2>/dev/null
|
sudo umount /mnt/temp 2>/dev/null
|
||||||
sudo umount /mnt/storage 2>/dev/null
|
sudo umount /mnt/storage 2>/dev/null
|
||||||
@@ -338,6 +341,7 @@ if [ "$1" = "format" ]; then
|
|||||||
echo "error='failed to unmount /mnt/storage'"
|
echo "error='failed to unmount /mnt/storage'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# wipe all partitions and write fresh GPT
|
# wipe all partitions and write fresh GPT
|
||||||
>&2 echo "# Wiping all partitions"
|
>&2 echo "# Wiping all partitions"
|
||||||
@@ -360,6 +364,9 @@ fi
|
|||||||
# formatting old: EXT4
|
# formatting old: EXT4
|
||||||
if [ "$1" = "format" ] && [ "$2" = "ext4" ]; then
|
if [ "$1" = "format" ] && [ "$2" = "ext4" ]; then
|
||||||
|
|
||||||
|
# prepare temo mount point
|
||||||
|
sudo mkdir -p /tmp/ext4 1>/dev/null
|
||||||
|
|
||||||
# write new EXT4 partition
|
# write new EXT4 partition
|
||||||
>&2 echo "# Creating the one big partition"
|
>&2 echo "# Creating the one big partition"
|
||||||
sudo parted /dev/${hdd} mkpart primary ext4 0% 100% 1>/dev/null 2>/dev/null
|
sudo parted /dev/${hdd} mkpart primary ext4 0% 100% 1>/dev/null 2>/dev/null
|
||||||
@@ -382,10 +389,10 @@ if [ "$1" = "format" ] && [ "$2" = "ext4" ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
# make sure /mnt/hdd is unmounted before formatting
|
# make sure /mnt/hdd is unmounted before formatting
|
||||||
sudo umount -f /mnt/hdd 2>/dev/null
|
sudo umount -f /tmp/ext4 2>/dev/null
|
||||||
unmounted=$(df | grep -c "/mnt/hdd")
|
unmounted=$(df | grep -c "/tmp/ext4")
|
||||||
if [ ${unmounted} -gt 0 ]; then
|
if [ ${unmounted} -gt 0 ]; then
|
||||||
echo "error='failed to unmount /mnt/hdd'"
|
echo "error='failed to unmount /tmp/ext4'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -408,7 +415,7 @@ if [ "$1" = "format" ] && [ "$2" = "ext4" ]; then
|
|||||||
|
|
||||||
# setting fsk check intervall to 1
|
# setting fsk check intervall to 1
|
||||||
# see https://github.com/rootzoll/raspiblitz/issues/360#issuecomment-467567572
|
# see https://github.com/rootzoll/raspiblitz/issues/360#issuecomment-467567572
|
||||||
sudo tune2fs -c 1 /dev/sda1
|
sudo tune2fs -c 1 /dev/${hdd}1
|
||||||
|
|
||||||
>&2 echo "# OK EXT 4 format done"
|
>&2 echo "# OK EXT 4 format done"
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user