diff --git a/bash/fs.sh b/bash/fs.sh index 005a56d..2635ce0 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -56,6 +56,22 @@ fs_make_fat() { fi } +fs_raid_create() { + if [ -n "${4}" ]; then + local name="${1}" + local uuid="${2}" + shift 2 + mdadm \ + --create "/dev/md/${name}" \ + --level 0 \ + --metadata 1 \ + --name "md:${name}" \ + --raid-devices ${#} \ + --uuid "${uuid}" \ + "${@}" + fi +} + fs_wipe() { local device="${1}" local buffer="${2}" @@ -103,19 +119,3 @@ luks_format() { cryptsetup "${@}" luksFormat "${device}" fi } - -raid_create() { - if [ -n "${4}" ]; then - local name="${1}" - local uuid="${2}" - shift 2 - mdadm \ - --create "/dev/md/${name}" \ - --level 0 \ - --metadata 1 \ - --name "md:${name}" \ - --raid-devices ${#} \ - --uuid "${uuid}" \ - "${@}" - fi -} diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh index 82694d6..0417230 100644 --- a/bash/rescue-hetzner.sh +++ b/bash/rescue-hetzner.sh @@ -65,14 +65,8 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members+=("${device}2") done - mdadm \ - --create "/dev/md/boot" \ - --level 0 \ - --metadata 1 \ - --name "md:boot" \ - --raid-devices ${#} \ - --uuid "00000000:00000000:00000000:00000002" \ - "${members[@]}" + fs_raid_create \ + "boot" "00000000:00000000:00000000:00000002" "${members[@]}" # fs_make_btrfs "/dev/md/boot" "boot" \ "00000000-0000-0000-0000-00000000000b" @@ -95,14 +89,8 @@ rescue_wipe_0_init_hetzner_8_8() { for device in "${@}"; do members+=("${device}1") done - mdadm \ - --create "/dev/md/crypt" \ - --level 0 \ - --metadata 1 \ - --name "md:crypt" \ - --raid-devices ${#} \ - --uuid "00000000:00000000:00000000:00000001" \ - "${members[@]}" + fs_raid_create \ + "crypt" "00000000:00000000:00000000:00000001" "${members[@]}" # encrypt luks_format "${passphrase}" "/dev/md/crypt" # open