V8.00.000.2025.06.17
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -25,22 +25,21 @@ guard_sourcing
|
||||
# 0: on success
|
||||
#######################################
|
||||
partition_formatting() {
|
||||
### Declare Arrays and Variables.
|
||||
declare -Ag HMP_PATH_FSUUID
|
||||
declare var_dev var_part \
|
||||
var_encryption_enable var_encryption_label var_fs_btrfs_checksum var_fs_btrfs_compress var_fs_btrfs_mdup \
|
||||
var_fs_format var_fs_label var_fs_options var_fs_version var_mount_path var_node var_fs_uuid
|
||||
declare -a ary_devs ary_parts ary_opts ary_fmt_opts
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -Ag HMP_PATH_FSUUID # Used in: 3290() - [Mount Path:Filesystem UUID].
|
||||
# Used in: 4060() - [Mount Path:Filesystem UUID].
|
||||
declare var_dev="" var_part="" \
|
||||
var_encryption_enable="" var_encryption_label="" var_fs_btrfs_checksum="" var_fs_btrfs_compress="" var_fs_btrfs_mdup="" \
|
||||
var_fs_format="" var_fs_label="" var_fs_options="" var_fs_version="" var_mount_path="" var_node="" var_fs_uuid=""
|
||||
|
||||
### 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
|
||||
declare -a ary_devs=() ary_parts=() ary_opts=() ary_fmt_opts=()
|
||||
|
||||
### 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
|
||||
for var_format_path in "${ARY_FORMT_MOUNT_PATHS[@]}"; do
|
||||
|
||||
### Generates physical device location.
|
||||
var_dev_part="${HMP_PATH_DEV_PART[${var_format_path}]}"
|
||||
|
||||
### Extract parameters from YAML.
|
||||
|
||||
### Extract parameters from YAML.
|
||||
var_encryption_enable=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.enable" "${VAR_SETUP_PART}")
|
||||
@@ -76,32 +75,45 @@ partition_formatting() {
|
||||
btrfs)
|
||||
ary_opts=( -L "${var_fs_label}" -f --csum "${var_fs_btrfs_checksum}" )
|
||||
[[ "${var_fs_btrfs_mdup,,}" == "true" ]] && ary_opts+=( -m dup )
|
||||
|
||||
mkfs.btrfs "${ary_opts[@]}" "${var_node}"
|
||||
|
||||
do_log "debug" "file_only" "3240() [mkfs.btrfs ${ary_opts[*]} ${var_node}]."
|
||||
do_log "info" "file_only" "3240() Partition: '${var_node}' formatted: 'btrfs' options: '${ary_opts[*]}'."
|
||||
|
||||
echo "Partition: '${var_node}':" >> "${DIR_LOG}/btrfs.log"
|
||||
btrfs filesystem show "${var_node}" >> "${DIR_LOG}/btrfs.log"
|
||||
|
||||
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
|
||||
HMP_PATH_FSUUID["UUID_${var_mount_path}"]="${var_fs_uuid}"
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
HMP_PATH_FSUUID["${var_mount_path}"]="${var_fs_uuid}"
|
||||
;;
|
||||
|
||||
ext4)
|
||||
read -r -a ary_fmt_opts <<< "${var_fs_options}"
|
||||
|
||||
mkfs.ext4 -L "${var_fs_label}" "${ary_fmt_opts[@]}" "${var_node}"
|
||||
|
||||
do_log "debug" "file_only" "3240() [mkfs.ext4 -L ${var_fs_label} ${ary_fmt_opts[*]} ${var_node}]."
|
||||
do_log "info" "file_only" "3240() Partition: '${var_node}' formatted: 'ext4' options: '${ary_fmt_opts[*]}'."
|
||||
|
||||
echo "Partition: '${var_node}':" >> "${DIR_LOG}/ext4.log"
|
||||
tune2fs -l "${var_node}" >> "${DIR_LOG}/ext4.log"
|
||||
|
||||
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
|
||||
HMP_PATH_FSUUID["UUID_${var_mount_path}"]="${var_fs_uuid}"
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
HMP_PATH_FSUUID["${var_mount_path}"]="${var_fs_uuid}"
|
||||
;;
|
||||
|
||||
fat32)
|
||||
mkfs.fat -F 32 -n "${var_fs_label}" "${var_node}"
|
||||
|
||||
do_log "debug" "file_only" "3240() [mkfs.fat -F 32 -n ${var_fs_label} ${var_node}]."
|
||||
do_log "info" "file_only" "3240() Partition: '${var_node}' formatted: 'FAT32'."
|
||||
|
||||
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
|
||||
HMP_PATH_FSUUID["UUID_${var_mount_path}"]="${var_fs_uuid}"
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
HMP_PATH_FSUUID["${var_mount_path}"]="${var_fs_uuid}"
|
||||
;;
|
||||
|
||||
*)
|
||||
@@ -112,7 +124,14 @@ partition_formatting() {
|
||||
|
||||
done
|
||||
|
||||
done
|
||||
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview.log"
|
||||
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview.log"
|
||||
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview.log"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user