Move functions to internal_config.sh; fixed regex

This commit is contained in:
oddlama 2020-04-21 18:43:17 +02:00
parent 9b854df006
commit 506bb9acf8
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
2 changed files with 46 additions and 44 deletions

View File

@ -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}

View File

@ -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
}