|
|
|
|
@@ -12,21 +12,6 @@
|
|
|
|
|
|
|
|
|
|
guard_sourcing
|
|
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
|
# Validates var_mount_path to be processed.
|
|
|
|
|
# Arguments:
|
|
|
|
|
# 1 var_mount_path
|
|
|
|
|
# Returns:
|
|
|
|
|
# 0: Skip mounting
|
|
|
|
|
# 1: Process mount
|
|
|
|
|
#######################################
|
|
|
|
|
skip_path() {
|
|
|
|
|
declare -a ary_skip=( "/" "/boot" "/boot/efi" "/recovery" )
|
|
|
|
|
declare p=""
|
|
|
|
|
for p in "${ary_skip[@]}"; do [[ "$1" == "${p}" ]] && return 0; done
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
|
# Function to create the mount command, incl. mount path and options, and mount the respective device.
|
|
|
|
|
# Globals:
|
|
|
|
|
@@ -110,7 +95,16 @@ validate_btrfs_compression() {
|
|
|
|
|
#######################################
|
|
|
|
|
# Function for mounting all partitions for debootstrap, including the generation of btrfs subvolumes.
|
|
|
|
|
# Globals:
|
|
|
|
|
# HMP_MOUNTPATH_DEV
|
|
|
|
|
# ARY_PATHS_SORTED
|
|
|
|
|
# DIR_LOG
|
|
|
|
|
# ERR_BTRFS_INITPH
|
|
|
|
|
# ERR_BTRFS_OPTION
|
|
|
|
|
# ERR_BTRFS_SUBVOL
|
|
|
|
|
# ERR_MOUNTING_DEV
|
|
|
|
|
# HMP_FSTAB_MOUNT_OPTS
|
|
|
|
|
# HMP_PATH_DEV_PART
|
|
|
|
|
# HMP_PATH_FSUUID
|
|
|
|
|
# NL
|
|
|
|
|
# TARGET
|
|
|
|
|
# VAR_RECIPE_STRING
|
|
|
|
|
# VAR_SAFE_MNT_BASE
|
|
|
|
|
@@ -128,193 +122,167 @@ validate_btrfs_compression() {
|
|
|
|
|
mount_partition() {
|
|
|
|
|
### Declare Arrays, HashMaps, and Variables.
|
|
|
|
|
declare -Ag HMP_FSTAB_MOUNT_OPTS # Used in: 4040() - [Mount Path:Mount Options].
|
|
|
|
|
declare -r var_mount_path_root="/"
|
|
|
|
|
|
|
|
|
|
declare var_path="" var_dev="" var_part="" \
|
|
|
|
|
var_fs_btrfs_compress="" var_fs_btrfs_level="" var_fs_btrfs_subvolume="" var_fs_btrfs_snapshot="" \
|
|
|
|
|
var_encryption_enable="" var_encryption_label="" var_fs_options="" var_fs_version="" var_mount_path="" \
|
|
|
|
|
var_mount_options="" var_snapshot="" var_mount_optsnap="" var_fs_uuid=""
|
|
|
|
|
declare var_mount_path="" var_dev_part="" var_dev="" var_btrfs_options="" \
|
|
|
|
|
var_encryption_label="" var_fs_btrfs_compress="" var_fs_btrfs_level="" var_fs_btrfs_snapshot="" \
|
|
|
|
|
var_fs_btrfs_subvolume="" var_fs_version="" var_mount_options="" var_mount_optsnap="" var_mount_path="" \
|
|
|
|
|
var_snapshot="" var_fs_uuid=""
|
|
|
|
|
|
|
|
|
|
declare -a ary_devs=() ary_parts=()
|
|
|
|
|
declare -a ary_cmd=() ary_cmd_mount=()
|
|
|
|
|
|
|
|
|
|
### Mount "/"-filesystem
|
|
|
|
|
if [[ -n "${HMP_PATH_FSUUID["${var_mount_path_root}"]}" ]]; then
|
|
|
|
|
mount_with_dir "${var_mount_path_root}" "${HMP_PATH_FSUUID["${var_mount_path_root}"]}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
else
|
|
|
|
|
do_log "error" "file_only" "3280() Root-filesystem '${var_mount_path_root}' not found in Hashmap: 'HMP_PATH_FSUUID'."
|
|
|
|
|
return "${ERR_MOUNTING_ROOT}"
|
|
|
|
|
fi
|
|
|
|
|
for var_mount_path in "${ARY_PATHS_SORTED[@]}"; do
|
|
|
|
|
|
|
|
|
|
#if [[ -n "${HMP_MOUNTPATH_DEV[${var_mount_path_root}]}" ]]; then
|
|
|
|
|
# mount_with_dir "${var_mount_path_root}" "${HMP_MOUNTPATH_DEV[${var_mount_path_root}]}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
#else
|
|
|
|
|
# do_log "error" "file_only" "3280() Root-filesystem '${var_mount_path_root}' not found in Hashmap: 'HMP_MOUNTPATH_DEV'."
|
|
|
|
|
# return "${ERR_MOUNTING_ROOT}"
|
|
|
|
|
#fi
|
|
|
|
|
### Initialize Arrays and Variables
|
|
|
|
|
ary_cmd=(); ary_cmd_mount=(); var_btrfs_options=""
|
|
|
|
|
|
|
|
|
|
### Generates physical device location.
|
|
|
|
|
var_dev_part="${HMP_PATH_DEV_PART["${var_mount_path}"]}"
|
|
|
|
|
|
|
|
|
|
### Extract parameters from YAML.
|
|
|
|
|
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
|
|
|
|
|
var_fs_btrfs_level=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.btrfs.level" "${VAR_SETUP_PART}")
|
|
|
|
|
var_fs_btrfs_snapshot=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.btrfs.snapshot" "${VAR_SETUP_PART}")
|
|
|
|
|
var_fs_version=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.version" "${VAR_SETUP_PART}")
|
|
|
|
|
var_mount_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.mount.options" "${VAR_SETUP_PART}")
|
|
|
|
|
var_mount_optsnap=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.mount.optsnap" "${VAR_SETUP_PART}")
|
|
|
|
|
|
|
|
|
|
var_encryption_label=$(get_label "${var_mount_path}" "${var_fs_version}" "luks")
|
|
|
|
|
var_fs_uuid="${HMP_PATH_FSUUID["${var_mount_path}"]}"
|
|
|
|
|
|
|
|
|
|
### Mounting of Ephemeral 'SWAP' and '/tmp' as per https://wiki.archlinux.org/title/Dm-crypt/Swap_encryption#UUID_and_LABEL
|
|
|
|
|
if [[ "${var_mount_path,,}" == "swap" ]]; then
|
|
|
|
|
|
|
|
|
|
cryptsetup open --type plain --key-file /dev/random \
|
|
|
|
|
--offset 2048 --cipher aes-xts-plain64 --key-size 512 \
|
|
|
|
|
--sector-size 4096 "/dev/disk/by-uuid/${var_fs_uuid}" "${var_encryption_label}"
|
|
|
|
|
|
|
|
|
|
mkswap "/dev/mapper/${var_encryption_label}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [mkswap /dev/mapper/${var_encryption_label}]."
|
|
|
|
|
|
|
|
|
|
swapon "/dev/mapper/${var_encryption_label}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [swapon /dev/mapper/${var_encryption_label}]."
|
|
|
|
|
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
### Ephemeral 'SWAP' finally mounted. Skip all other steps.
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
elif [[ "${var_mount_path,,}" == "/tmp" ]]; then
|
|
|
|
|
|
|
|
|
|
cryptsetup open --type plain --key-file /dev/random \
|
|
|
|
|
--offset 2048 --cipher aes-xts-plain64 --key-size 512 \
|
|
|
|
|
--sector-size 4096 "/dev/disk/by-uuid/${var_fs_uuid}" "${var_encryption_label}"
|
|
|
|
|
|
|
|
|
|
mkdir -p "${TARGET}/tmp"
|
|
|
|
|
|
|
|
|
|
safe_exec mkfs.ext4 -E nodiscard,lazy_itable_init=1,lazy_journal_init=1 "/dev/mapper/${var_encryption_label}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
|
|
|
|
|
### Gathering information for '/etc/fstab'-generation in 4040().
|
|
|
|
|
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_mount_options}"
|
|
|
|
|
|
|
|
|
|
### Build the command in an array to keep word boundaries intact
|
|
|
|
|
ary_cmd=( mount )
|
|
|
|
|
ary_cmd+=( "/dev/mapper/${var_encryption_label}" "${TARGET}${var_mount_path}" )
|
|
|
|
|
|
|
|
|
|
safe_exec "${ary_cmd[@]}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
### Ephemeral '/tmp' finally mounted. Skip all other steps.
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
### Ensure order of "/boot" and "/boot/efi"
|
|
|
|
|
for var_path in "/boot" "/boot/efi"; do
|
|
|
|
|
if [[ -n "${HMP_PATH_FSUUID["${var_path}"]}" ]]; then
|
|
|
|
|
mount_with_dir "${var_path}" "${HMP_PATH_FSUUID["${var_path}"]}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
else
|
|
|
|
|
do_log "info" "file_only" "3280() Entry '${var_path}' not found in Hashmap: 'HMP_PATH_FSUUID'."
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
#for var_path in "/boot" "/boot/efi"; do
|
|
|
|
|
# if [[ -n "${HMP_MOUNTPATH_DEV[${var_path}]}" ]]; then
|
|
|
|
|
# mount_with_dir "${var_path}" "${HMP_MOUNTPATH_DEV[${var_path}]}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
# else
|
|
|
|
|
# do_log "info" "file_only" "3280() Entry '${var_path}' not found in Hashmap: 'HMP_MOUNTPATH_DEV'."
|
|
|
|
|
# fi
|
|
|
|
|
#done
|
|
|
|
|
if [[ "${var_fs_version,,}" == "btrfs" ]]; then
|
|
|
|
|
|
|
|
|
|
### Iterate over all devices in the recipe.
|
|
|
|
|
# shellcheck disable=SC2312
|
|
|
|
|
readarray -t ary_devs < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev | keys | .[]" "${VAR_SETUP_PART}")
|
|
|
|
|
for var_dev in "${ary_devs[@]}"; do
|
|
|
|
|
var_fs_btrfs_subvolume=$(get_label "${var_mount_path}" "${var_fs_version}" "sub")
|
|
|
|
|
|
|
|
|
|
### Iterate over all partitions for this device.
|
|
|
|
|
# shellcheck disable=SC2312
|
|
|
|
|
readarray -t ary_parts < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev} | keys | .[]" "${VAR_SETUP_PART}")
|
|
|
|
|
for var_part in "${ary_parts[@]}"; do
|
|
|
|
|
### Mount toplevel (subvolid=0) without extra options.
|
|
|
|
|
ary_cmd_mount=( mount -o "subvolid=0" "${var_fs_uuid}" "${VAR_SAFE_MNT_BASE}" )
|
|
|
|
|
safe_exec "${ary_cmd_mount[@]}" "${ERR_BTRFS_INITPH}" || return "${ERR_BTRFS_INITPH}"
|
|
|
|
|
|
|
|
|
|
### Extract parameters from YAML.
|
|
|
|
|
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
|
|
|
|
|
var_fs_btrfs_level=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.level" "${VAR_SETUP_PART}")
|
|
|
|
|
var_fs_btrfs_snapshot=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.snapshot" "${VAR_SETUP_PART}")
|
|
|
|
|
var_encryption_enable=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.enable" "${VAR_SETUP_PART}")
|
|
|
|
|
var_fs_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.options" "${VAR_SETUP_PART}")
|
|
|
|
|
var_fs_version=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.version" "${VAR_SETUP_PART}")
|
|
|
|
|
var_mount_path=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.path" "${VAR_SETUP_PART}")
|
|
|
|
|
var_mount_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.options" "${VAR_SETUP_PART}")
|
|
|
|
|
var_mount_optsnap=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.optsnap" "${VAR_SETUP_PART}")
|
|
|
|
|
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_fs_btrfs_subvolume}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [btrfs subvolume create ${VAR_SAFE_MNT_BASE}/${var_fs_btrfs_subvolume}]."
|
|
|
|
|
do_log "info" "file_only" "3280() btrfs subvolid=0 created: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
### Skip already mounted paths ("/", "/boot", "/boot/efi") and skip ("/recovery")
|
|
|
|
|
skip_path "${var_mount_path}" && continue
|
|
|
|
|
if [[ "${var_fs_btrfs_snapshot}" == "true" ]]; then
|
|
|
|
|
|
|
|
|
|
var_encryption_label=$(get_label "${var_mount_path}" "${var_fs_version}" "luks")
|
|
|
|
|
var_fs_uuid="${HMP_PATH_FSUUID["${var_path}"]}"
|
|
|
|
|
var_snapshot=$(get_label "${var_mount_path}" "${var_fs_version}" "snap")
|
|
|
|
|
|
|
|
|
|
if [[ "${var_mount_path,,}" == "swap" ]]; then
|
|
|
|
|
|
|
|
|
|
#var_fs_label=$(get_label "${var_mount_path}" "${var_fs_version}" "file")
|
|
|
|
|
|
|
|
|
|
cryptsetup open --type plain --key-file /dev/random \
|
|
|
|
|
--offset 2048 --cipher aes-xts-plain64 --key-size 512 \
|
|
|
|
|
--sector-size 4096 "/dev/disk/by-uuid/${var_fs_uuid}" "${var_encryption_label}"
|
|
|
|
|
#--sector-size 4096 "/dev/disk/by-label/${var_fs_label}" "${var_encryption_label}"
|
|
|
|
|
|
|
|
|
|
mkswap "/dev/mapper/${var_encryption_label}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [mkswap /dev/mapper/${var_encryption_label}]."
|
|
|
|
|
|
|
|
|
|
swapon "/dev/mapper/${var_encryption_label}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [swapon /dev/mapper/${var_encryption_label}]."
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
elif [[ "${var_mount_path,,}" == "/tmp" ]]; then
|
|
|
|
|
|
|
|
|
|
cryptsetup open --type plain --key-file /dev/random \
|
|
|
|
|
--offset 2048 --cipher aes-xts-plain64 --key-size 512 \
|
|
|
|
|
--sector-size 4096 "/dev/disk/by-uuid/${var_fs_uuid}" "${var_encryption_label}"
|
|
|
|
|
|
|
|
|
|
mkdir -p "${TARGET}/tmp"
|
|
|
|
|
|
|
|
|
|
echo "safe_exec mkfs.ext4 -E nodiscard,lazy_itable_init=1,lazy_journal_init=1 /dev/mapper/${var_encryption_label} ${ERR_MOUNTING_DEV}"
|
|
|
|
|
safe_exec mkfs.ext4 -E nodiscard,lazy_itable_init=1,lazy_journal_init=1 "/dev/mapper/${var_encryption_label}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
|
|
|
|
|
### Build the command in an array to keep word boundaries intact
|
|
|
|
|
declare -a ary_cmd2=(mount)
|
|
|
|
|
|
|
|
|
|
ary_cmd2+=("/dev/mapper/${var_encryption_label}" "${TARGET}${var_mount_path}")
|
|
|
|
|
|
|
|
|
|
safe_exec "${ary_cmd2[@]}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_snapshot}" || return "${ERR_BTRFS_SUBVOL}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [btrfs subvolume create ${VAR_SAFE_MNT_BASE}/${var_snapshot}]."
|
|
|
|
|
do_log "info" "file_only" "3280() btrfs subvolid=${var_snapshot} created: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#var_resolved_dev=$(resolve_device "${var_dev}" "${var_part}" "${var_encryption_enable}" "${var_encryption_label}")
|
|
|
|
|
umount "${VAR_SAFE_MNT_BASE}"
|
|
|
|
|
do_log "info" "file_only" "3280() btrfs subvolume umount: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
if [[ "${var_fs_version,,}" == "btrfs" ]]; then
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
var_fs_btrfs_subvolume=$(get_label "${var_mount_path}" "${var_fs_version}" "sub")
|
|
|
|
|
case "${var_fs_version,,}" in
|
|
|
|
|
|
|
|
|
|
### Mount toplevel (subvolid=0) without extra options.
|
|
|
|
|
declare -a ary_cmd_mount=(mount -o "subvolid=0" "${var_fs_uuid}" "${VAR_SAFE_MNT_BASE}")
|
|
|
|
|
safe_exec "${ary_cmd_mount[@]}" "${ERR_BTRFS_INITPH}" || return "${ERR_BTRFS_INITPH}"
|
|
|
|
|
btrfs)
|
|
|
|
|
|
|
|
|
|
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_fs_btrfs_subvolume}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [btrfs subvolume create ${VAR_SAFE_MNT_BASE}/${var_fs_btrfs_subvolume}]."
|
|
|
|
|
do_log "info" "file_only" "3280() btrfs subvolid=0 created: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
validate_btrfs_compression "${var_fs_btrfs_compress}" "${var_fs_btrfs_level}" || return "${ERR_BTRFS_OPTION}"
|
|
|
|
|
|
|
|
|
|
var_btrfs_options="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
|
|
|
|
|
|
|
|
|
|
[[ -n "${var_mount_options}" ]] && var_btrfs_options+="${var_mount_options},${var_btrfs_options},subvol=${var_fs_btrfs_subvolume}"
|
|
|
|
|
[[ -z "${var_mount_options}" ]] && var_btrfs_options+="${var_btrfs_options},subvol=${var_fs_btrfs_subvolume}"
|
|
|
|
|
|
|
|
|
|
### Gathering information for '/etc/fstab'-generation in 4040().
|
|
|
|
|
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_btrfs_options}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
|
|
|
|
|
|
|
|
|
|
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_btrfs_options}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_btrfs_options}')."
|
|
|
|
|
|
|
|
|
|
if [[ "${var_fs_btrfs_snapshot}" == "true" ]]; then
|
|
|
|
|
|
|
|
|
|
var_snapshot=$(get_label "${var_mount_path}" "${var_fs_version}" "snap")
|
|
|
|
|
### Preparing "/.snapshot"-directory
|
|
|
|
|
mkdir -p "${TARGET}${var_mount_path}/.snapshots"
|
|
|
|
|
do_log "info" "file_only" "3280() Created: '${TARGET}${var_mount_path}/.snapshots'."
|
|
|
|
|
|
|
|
|
|
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_snapshot}" || return "${ERR_BTRFS_SUBVOL}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [btrfs subvolume create ${VAR_SAFE_MNT_BASE}/${var_snapshot}]."
|
|
|
|
|
do_log "info" "file_only" "3280() btrfs subvolid=${var_snapshot} created: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
umount "${VAR_SAFE_MNT_BASE}"
|
|
|
|
|
do_log "info" "file_only" "3280() btrfs subvolume umount: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
case "${var_fs_version,,}:${var_encryption_enable,,}" in
|
|
|
|
|
|
|
|
|
|
btrfs:*)
|
|
|
|
|
|
|
|
|
|
validate_btrfs_compression "${var_fs_btrfs_compress}" "${var_fs_btrfs_level}" || return "${ERR_BTRFS_OPTION}"
|
|
|
|
|
|
|
|
|
|
declare var_btrfs_compression_options="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
|
|
|
|
|
|
|
|
|
|
[[ -n "${var_mount_options}" ]] && var_btrfs_compression_options+=",${var_mount_options},subvol=${var_fs_btrfs_subvolume}"
|
|
|
|
|
var_mount_optsnap="${var_mount_optsnap},subvol=${var_snapshot}"
|
|
|
|
|
|
|
|
|
|
### Gathering information for '/etc/fstab'-generation in 4040().
|
|
|
|
|
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_btrfs_compression_options[*]}"
|
|
|
|
|
do_log "debug" "file_only" "3280() Stored in HashMap [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
|
|
|
|
|
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]="${var_mount_optsnap}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}/.snapshots' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]}'."
|
|
|
|
|
|
|
|
|
|
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_btrfs_compression_options}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
mount_with_dir "${var_mount_path}/.snapshots" "${var_fs_uuid}" "${var_mount_optsnap}"
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}/.snapshots' (Options='${var_mount_optsnap}')."
|
|
|
|
|
|
|
|
|
|
if [[ "${var_fs_btrfs_snapshot}" == "true" ]]; then
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
### Preparing "/.snapshot"-directory
|
|
|
|
|
mkdir -p "${TARGET}${var_mount_path}/.snapshots"
|
|
|
|
|
do_log "info" "file_only" "3280() Created: '${TARGET}${var_mount_path}/.snapshots'."
|
|
|
|
|
ext4)
|
|
|
|
|
|
|
|
|
|
var_mount_optsnap="${var_mount_optsnap},subvol=${var_snapshot}"
|
|
|
|
|
### Gathering information for '/etc/fstab'-generation in 4040().
|
|
|
|
|
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_mount_options}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
|
|
|
|
|
|
|
|
|
|
### Gathering information for '/etc/fstab'-generation in 4040().
|
|
|
|
|
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]="${var_mount_optsnap[*]}"
|
|
|
|
|
do_log "debug" "file_only" "3280() Stored in HashMap [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}/.snapshots' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]}'."
|
|
|
|
|
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
mount_with_dir "${var_mount_path}/.snapshots" "${var_fs_uuid}" "${var_mount_optsnap}"
|
|
|
|
|
fat32)
|
|
|
|
|
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}/.snapshots' (Options='${var_mount_optsnap}')."
|
|
|
|
|
### Gathering information for '/etc/fstab'-generation in 4040().
|
|
|
|
|
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_mount_options}"
|
|
|
|
|
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
ext4:*)
|
|
|
|
|
|
|
|
|
|
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*) do_log "error" "file_only" "3280() Unsupported fs/encryption combination."
|
|
|
|
|
return "${ERR_MOUNTING_DEV}" ;;
|
|
|
|
|
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" || return "${ERR_MOUNTING_DEV}"
|
|
|
|
|
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
var_dev="${HMP_PATH_DEV_PART["${var_mount_path}"]}"
|
|
|
|
|
var_dev="${var_dev%.*}"
|
|
|
|
|
|
|
|
|
|
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview_full.log"
|
|
|
|
|
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview_full.log"
|
|
|
|
|
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview_full.log"
|
|
|
|
|
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview_3280.log"
|
|
|
|
|
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview_3280.log"
|
|
|
|
|
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview_3280.log"
|
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|