V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 40s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 40s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -43,21 +43,43 @@ partitioning() {
|
|||||||
|
|
||||||
### All current data for the respective device will be deleted.
|
### All current data for the respective device will be deleted.
|
||||||
if ! blkdiscard "/dev/${var_dev}"; then
|
if ! blkdiscard "/dev/${var_dev}"; then
|
||||||
do_log "fatal" "file_only" "Partition table deletion '/dev/${var_dev}' failed."
|
|
||||||
return "${ERR_TABLE_DELETE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
do_log "info" "file_only" "Partition table of '/dev/${var_dev}' discarded."
|
do_log "warn" "file_only" "Partition table: '/dev/${var_dev}' deletion failed with: 'blkdiscard' trying 'sgdisk' fallback."
|
||||||
|
|
||||||
|
if command -v sgdisk >/dev/null && sgdisk --zap-all "/dev/${var_dev}"; then
|
||||||
|
|
||||||
|
do_log "info" "file_only" "Partition table: '/dev/${var_dev}' wiped with 'sgdisk --zap-all'."
|
||||||
|
|
||||||
|
elif dd if=/dev/zero of="/dev/${var_dev}" bs=1M count=8 status=none; then
|
||||||
|
|
||||||
|
do_log "info" "file_only" "Partition table: '/dev/${var_dev}' overwritten with zeros."
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
do_log "fatal" "file_only" "Partition table: '/dev/${var_dev}' deletion failed with: [blkdiscard, sgdisk and dd]."
|
||||||
|
return "${ERR_TABLE_DELETE}"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
do_log "info" "file_only" "Partition table: '/dev/${var_dev}' discarded (blkdiscard)."
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
case "${VAR_RECIPE_TABLE,,}" in
|
case "${VAR_RECIPE_TABLE,,}" in
|
||||||
|
|
||||||
gpt|mbr)
|
gpt|mbr)
|
||||||
if ! parted -s "/dev/${var_dev}" mklabel "${VAR_RECIPE_TABLE,,}"; then
|
if ! parted -s "/dev/${var_dev}" mklabel "${VAR_RECIPE_TABLE,,}"; then
|
||||||
do_log "fatal" "false" "Partition table creation '/dev/${var_dev}' failed."
|
|
||||||
|
do_log "fatal" "file_only" "Partition table: '/dev/${var_dev}' creation failed."
|
||||||
return "${ERR_TABLE_CREATE}"
|
return "${ERR_TABLE_CREATE}"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
do_log "info" "file_only" "Partition table '${VAR_RECIPE_TABLE}' of '/dev/${var_dev}' generated."
|
|
||||||
|
do_log "info" "file_only" "Partition table: '/dev/${var_dev}' generated: '${VAR_RECIPE_TABLE}'."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
do_log "fatal" "file_only" "No valid partition table chosen. String was '${VAR_RECIPE_TABLE}'."
|
do_log "fatal" "file_only" "No valid partition table chosen. String was '${VAR_RECIPE_TABLE}'."
|
||||||
return "${ERR_PARTITIONTBL}"
|
return "${ERR_PARTITIONTBL}"
|
||||||
@@ -86,11 +108,11 @@ partitioning() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if ! parted -s "/dev/${var_dev}" mkpart "${var_pri}" "${var_fs}" "${var_begin}" "${var_end_arg}"; then
|
if ! parted -s "/dev/${var_dev}" mkpart "${var_pri}" "${var_fs}" "${var_begin}" "${var_end_arg}"; then
|
||||||
do_log "fatal" "file_only" "Partition creation '/dev/${var_dev}${var_part}' failed."
|
do_log "fatal" "file_only" "Partition: '/dev/${var_dev}${var_part}' creation failed."
|
||||||
return "${ERR_PART_CREATE}"
|
return "${ERR_PART_CREATE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
do_log "info" "file_only" "Partition generated: '${var_part}' | on device '/dev/${var_dev}' | begin: '${var_begin}' | end: '${var_end_arg}'."
|
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' generated | begin: '${var_begin}' | end: '${var_end_arg}'."
|
||||||
|
|
||||||
### Set the bootable flag if necessary.
|
### Set the bootable flag if necessary.
|
||||||
if [[ "${var_boot,,}" == "true" ]]; then
|
if [[ "${var_boot,,}" == "true" ]]; then
|
||||||
@@ -98,7 +120,6 @@ partitioning() {
|
|||||||
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' marked as bootable."
|
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' marked as bootable."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
### Store PARTUUID of the partition.
|
### Store PARTUUID of the partition.
|
||||||
udevadm settle
|
udevadm settle
|
||||||
for i in {1..10}; do
|
for i in {1..10}; do
|
||||||
@@ -107,7 +128,7 @@ partitioning() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "${var_uuid}" ]]; then
|
if [[ -z "${var_uuid}" ]]; then
|
||||||
do_log "fatal" "file_only" "WARNING: could not read PARTUUID for '/dev/${var_dev}${var_part}'."
|
do_log "fatal" "file_only" "Partition: '/dev/${var_dev}${var_part}' could not read PARTUUID."
|
||||||
return "${ERR_PART_READ}"
|
return "${ERR_PART_READ}"
|
||||||
else
|
else
|
||||||
HMP_PATH_PARTUUID["PARTUUID_${var_mount_path}"]="${var_uuid}"
|
HMP_PATH_PARTUUID["PARTUUID_${var_mount_path}"]="${var_uuid}"
|
||||||
@@ -116,6 +137,7 @@ partitioning() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||||
|
|||||||
Reference in New Issue
Block a user