Browse Source

Check for ext4 before mounting a device (#144)

docker-compose-config
Mayank Chhabra 4 years ago
committed by GitHub
parent
commit
75f6b46ede
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      scripts/umbrel-os/external-storage/mount

62
scripts/umbrel-os/external-storage/mount

@ -85,6 +85,25 @@ unmount_partition () {
umount "${MOUNT_POINT}"
}
# Formats and sets up a new device
setup_new_device () {
block_device="${1}"
partition_path="${2}"
echo "Formatting device..."
format_block_device $block_device
echo "Mounting partition..."
mount_partition "${partition_path}"
echo "Copying Umbrel install to external storage..."
mkdir -p "${EXTERNAL_UMBREL_ROOT}"
cp --recursive \
--archive \
--no-target-directory \
"${UMBREL_ROOT}" "${EXTERNAL_UMBREL_ROOT}"
}
main () {
echo "Running external storage mount script..."
check_root
@ -111,39 +130,34 @@ main () {
block_device_model=$(get_block_device_model $block_device)
echo "Found device \"${block_device_model}\""
echo "Checking if device contains an Umbrel install..."
mount_partition "${partition_path}"
echo "Checking if the device is ext4..."
if is_partition_ext4 "${partition_path}" && [[ -f "${EXTERNAL_UMBREL_ROOT}"/.umbrel ]]; then
echo "Yes, it does"
else
echo "No, it doesn't"
echo "Unmounting partition..."
unmount_partition
echo "Formatting device..."
format_block_device $block_device
echo "Mounting partition..."
if is_partition_ext4 "${partition_path}" ; then
echo "Yes, it is ext4"
mount_partition "${partition_path}"
echo "Copying Umbrel install to external storage..."
mkdir -p "${EXTERNAL_UMBREL_ROOT}"
cp --recursive \
--archive \
--no-target-directory \
"${UMBREL_ROOT}" "${EXTERNAL_UMBREL_ROOT}"
echo "Checking if device contains an Umbrel install..."
echo "Creating /sd-root to bind-mount SD card root..."
mkdir -p "/sd-root"
if [[ -f "${EXTERNAL_UMBREL_ROOT}"/.umbrel ]]; then
echo "Yes, it contains an Umbrel install"
else
echo "No, it doesn't contain an Umbrel install"
echo "Unmounting partition..."
unmount_partition
setup_new_device $block_device $partition_path
fi
else
echo "No, it's not ext4"
setup_new_device $block_device $partition_path
fi
echo "Bind mounting external storage over local Umbrel installation..."
mount --bind "${EXTERNAL_UMBREL_ROOT}" "${UMBREL_ROOT}"
echo "Bind mounting SD card root at /sd-card"
echo "Bind mounting SD card root at /sd-card..."
[[ ! -d "/sd-root" ]] && mkdir -p "/sd-root"
mount --bind "/" "/sd-root"
echo "Checking Umbrel root is now on external storage..."

Loading…
Cancel
Save