From 506bb9acf8bffc95014bf363c8f1d91e4d635f2e Mon Sep 17 00:00:00 2001 From: oddlama Date: Tue, 21 Apr 2020 18:43:17 +0200 Subject: [PATCH] Move functions to internal_config.sh; fixed regex --- scripts/config.sh | 46 ++------------------------------------ scripts/internal_config.sh | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index 646093e..98c8f40 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -5,50 +5,8 @@ source "$GENTOO_INSTALL_REPO_DIR/scripts/internal_config.sh" || exit 1 ################################################ # Disk configuration -# Example 1: Single disk, 3 partitions (efi, swap, root) -create_default_disk_layout() { - local device="$1" - - create_gpt new_id=gpt device="$device" - create_partition new_id=part_efi id=gpt size=128MiB type=efi - create_partition new_id=part_swap id=gpt size=8GiB type=raid - create_partition new_id=part_root id=gpt size=remaining type=raid - - format id=part_efi type=efi label=efi - format id=part_swap type=swap label=swap - format id=part_root type=ext4 label=root - - DISK_ID_EFI=part_efi - DISK_ID_SWAP=part_raid - DISK_ID_ROOT=part_luks -} - -# Example 2: Multiple disks, with raid 0 and luks -# - efi: partition on all disks, but only first disk used -# - swap: raid 0 → fs -# - root: raid 0 → luks → fs -create_raid0_luks_layout() { - local devices=("$@") - for i in "${!devices[@]}"; do - create_gpt new_id="gpt_dev${i}" device="${devices[$i]}" - create_partition new_id="part_efi_dev${i}" id="gpt_dev${i}" size=128MiB type=efi - create_partition new_id="part_swap_dev${i}" id="gpt_dev${i}" size=8GiB type=raid - create_partition new_id="part_root_dev${i}" id="gpt_dev${i}" size=remaining type=raid - done - - create_raid new_id=part_raid_swap level=0 ids="$(expand_ids '^part_swap_dev\d$')" - create_raid new_id=part_raid_root level=0 ids="$(expand_ids '^part_root_dev\d$')" - create_luks new_id=part_luks_root id=part_raid_root - - format id=part_efi_dev0 type=efi label=efi - format id=part_raid_swap type=swap label=swap - format id=part_luks_root type=ext4 label=root - - DISK_ID_EFI=part_efi_dev0 - DISK_ID_SWAP=part_raid_swap - DISK_ID_ROOT=part_luks_root -} - +# See the respective functions in internal_config.sh if you +# want to use a different disk configuration. create_default_disk_layout /dev/sdX #create_raid0_luks_layout /dev/sd{X,Y} diff --git a/scripts/internal_config.sh b/scripts/internal_config.sh index d7d0ae1..e2892e4 100644 --- a/scripts/internal_config.sh +++ b/scripts/internal_config.sh @@ -183,3 +183,47 @@ expand_ids() { && echo -n "$id;" done } + +# Example 1: Single disk, 3 partitions (efi, swap, root) +create_default_disk_layout() { + local device="$1" + + create_gpt new_id=gpt device="$device" + create_partition new_id=part_efi id=gpt size=128MiB type=efi + create_partition new_id=part_swap id=gpt size=8GiB type=raid + create_partition new_id=part_root id=gpt size=remaining type=raid + + format id=part_efi type=efi label=efi + format id=part_swap type=swap label=swap + format id=part_root type=ext4 label=root + + DISK_ID_EFI=part_efi + DISK_ID_SWAP=part_raid + DISK_ID_ROOT=part_luks +} + +# Example 2: Multiple disks, with raid 0 and luks +# - efi: partition on all disks, but only first disk used +# - swap: raid 0 → fs +# - root: raid 0 → luks → fs +create_raid0_luks_layout() { + local devices=("$@") + for i in "${!devices[@]}"; do + create_gpt new_id="gpt_dev${i}" device="${devices[$i]}" + create_partition new_id="part_efi_dev${i}" id="gpt_dev${i}" size=128MiB type=efi + create_partition new_id="part_swap_dev${i}" id="gpt_dev${i}" size=8GiB type=raid + create_partition new_id="part_root_dev${i}" id="gpt_dev${i}" size=remaining type=raid + done + + 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_luks new_id=part_luks_root id=part_raid_root + + format id=part_efi_dev0 type=efi label=efi + format id=part_raid_swap type=swap label=swap + format id=part_luks_root type=ext4 label=root + + DISK_ID_EFI=part_efi_dev0 + DISK_ID_SWAP=part_raid_swap + DISK_ID_ROOT=part_luks_root +}