mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-06 19:20:12 +00:00
mount-partitions: do not hardcode partition types
Query instead the device for its filesystem type before mounting. Change-type: patch Signed-off-by: Alex Gonzalez <alexg@balena.io>
This commit is contained in:
parent
325075b528
commit
cc2ca84448
@ -52,17 +52,17 @@ if [ "${TEST}" != 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Mounts a device to a path if it's not already mounted.
|
# Mounts a device to a path if it's not already mounted.
|
||||||
# Usage: do_mount DEVICE MOUNT_PATH [FS_TYPE]
|
# Usage: do_mount DEVICE MOUNT_PATH
|
||||||
do_mount() {
|
do_mount() {
|
||||||
device=$1
|
device=$1
|
||||||
mount_path=$2
|
mount_path=$2
|
||||||
fs_type=${3:-ext4}
|
|
||||||
|
|
||||||
# Create the directory if it doesn't exist
|
# Create the directory if it doesn't exist
|
||||||
mkdir -p "${mount_path}"
|
mkdir -p "${mount_path}"
|
||||||
|
|
||||||
# Mount the device if it doesn't exist
|
# Mount the device if it doesn't exist
|
||||||
if [ "$(mountpoint -n "${mount_path}" | awk '{ print $1 }')" != "${device}" ]; then
|
if [ "$(mountpoint -n "${mount_path}" | awk '{ print $1 }')" != "${device}" ]; then
|
||||||
|
fs_type=$(lsblk -nlo fstype "${device}")
|
||||||
mount -t "${fs_type}" "${device}" "${mount_path}"
|
mount -t "${fs_type}" "${device}" "${mount_path}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -81,20 +81,13 @@ setup_then_mount() {
|
|||||||
partition_label=$1
|
partition_label=$1
|
||||||
target_path=$2
|
target_path=$2
|
||||||
|
|
||||||
# Mount as vfat if boot, otherwise ext4
|
|
||||||
if [ "${partition_label}" = "boot" ]; then
|
|
||||||
fs_type="vfat"
|
|
||||||
else
|
|
||||||
fs_type="ext4"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try FS label first and partition label as a fallback
|
# Try FS label first and partition label as a fallback
|
||||||
for arg in label partlabel; do
|
for arg in label partlabel; do
|
||||||
kname=$(lsblk "/dev/${current_boot_block_device}" -nlo "kname,${arg}" | grep -E "(resin|balena)-${partition_label}" | awk '{print $1}')
|
kname=$(lsblk "/dev/${current_boot_block_device}" -nlo "kname,${arg}" | grep -E "(resin|balena)-${partition_label}" | awk '{print $1}')
|
||||||
device="/dev/${kname}"
|
device="/dev/${kname}"
|
||||||
if [ -b "${device}" ]; then
|
if [ -b "${device}" ]; then
|
||||||
echo "INFO: Found device $device on current boot device $current_boot_block_device, using as mount for '(resin|balena)-${partition_label}'."
|
echo "INFO: Found device $device on current boot device $current_boot_block_device, using as mount for '(resin|balena)-${partition_label}'."
|
||||||
do_mount "${device}" "${target_path}" "${fs_type}"
|
do_mount "${device}" "${target_path}"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user