From cfcefae1ecafed08c256454d89ea356a1904ce8a Mon Sep 17 00:00:00 2001 From: oddlama Date: Tue, 21 Apr 2020 23:29:06 +0200 Subject: [PATCH] Fixed mdadm invocation, added raid names --- scripts/config.sh | 5 ++++- scripts/functions.sh | 12 +++++++++--- scripts/internal_config.sh | 7 ++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index 7e5318a..5135457 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -24,7 +24,10 @@ create_default_disk_layout swap=8GiB /dev/sdX ################################################ # System configuration -# Enter the desired system hostname here +# Enter the desired system hostname here, +# be aware that when creating raid arrays, this value will be +# recorded in metadata block. If you change it later, you should +# also update the metadata. HOSTNAME="gentoo" # The timezone for the new system diff --git a/scripts/functions.sh b/scripts/functions.sh index 97b9351..77388c1 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -211,16 +211,17 @@ disk_create_partition() { disk_create_raid() { local new_id="${arguments[new_id]}" local level="${arguments[level]}" + local name="${arguments[name]}" local ids="${arguments[ids]}" if [[ $disk_action_summarize_only == true ]]; then local id # Splitting is intentional here # shellcheck disable=SC2086 for id in ${ids//';'/ }; do - add_summary_entry "$id" "_$new_id" "raid$level" "" "" + add_summary_entry "$id" "_$new_id" "raid$level" "" "$(summary_color_args name)" done - add_summary_entry __root__ "$new_id" "raid$level" "" "" + add_summary_entry __root__ "$new_id" "raid$level" "" "$(summary_color_args name)" return 0 fi @@ -240,7 +241,12 @@ disk_create_raid() { disk_id_to_resolvable[$new_id]="uuid:$uuid" einfo "Creating raid$level ($new_id) on $devices_desc" - mdadm --create \ + mdadm \ + --create "/dev/md/$name" \ + --verbose \ + --homehost="$HOSTNAME" \ + --metadata=1.2 \ + --raid-devices="${#devices[@]}" \ --uuid="$uuid" \ --level="$level" \ "${devices[@]}" \ diff --git a/scripts/internal_config.sh b/scripts/internal_config.sh index 0ba82b3..f66a7c5 100644 --- a/scripts/internal_config.sh +++ b/scripts/internal_config.sh @@ -136,11 +136,12 @@ create_partition() { # Named arguments: # new_id: Id for the new raid # level: Raid level +# name: Raid name (/dev/md/) # ids: Comma separated list of all member ids create_raid() { USED_RAID=true - local known_arguments=('+new_id' '+level' '+ids') + local known_arguments=('+new_id' '+level' '+name' '+ids') local extra_arguments=() declare -A arguments; parse_arguments "$@" @@ -264,8 +265,8 @@ create_raid0_luks_layout() { done [[ $size_swap != "false" ]] && \ - create_raid new_id=part_raid_swap level=0 ids="$(expand_ids '^part_swap_dev[[:digit:]]$')" - create_raid new_id=part_raid_root level=0 ids="$(expand_ids '^part_root_dev[[:digit:]]$')" + create_raid new_id=part_raid_swap name="swap" level=0 ids="$(expand_ids '^part_swap_dev[[:digit:]]$')" + create_raid new_id=part_raid_root name="root" level=0 ids="$(expand_ids '^part_root_dev[[:digit:]]$')" create_luks new_id=part_luks_root id=part_raid_root format id="part_${type}_dev0" type="$type" label="$type"