feat: add new dummy partitioning scheme "existing_partitions", which skips all partitioning and formatting operations.

This commit is contained in:
oddlama 2022-05-13 20:41:24 +02:00
parent 8e01c52ed6
commit 93f70f969c
No known key found for this signature in database
GPG Key ID: 14EFE510775FE39A
3 changed files with 122 additions and 5 deletions

78
configure vendored
View File

@ -1,6 +1,10 @@
#!/bin/bash #!/bin/bash
set -uo pipefail set -uo pipefail
#todo "selector for disks by-id, or custom"
#todo "test ZFS compression really on"
#todo "disks by id also in resolve step"
#todo "the device you want to partitoin ---> to use?"
################################################ ################################################
# Initialize script environment # Initialize script environment
@ -164,8 +168,11 @@ function define_zfs_compression() {
} }
function define_disk_layout() { function define_disk_layout() {
local swapdev
case "$PARTITIONING_SCHEME" in case "$PARTITIONING_SCHEME" in
"classic_single_disk") define_disk_configuration_function "create_classic_single_disk_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICE@Q}" ;; "classic_single_disk") define_disk_configuration_function "create_classic_single_disk_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICE@Q}" ;;
"existing_partitions") swapdev=${PARTITIONING_SWAP_DEVICE:-false}
define_disk_configuration_function "create_existing_partitions_layout boot=${PARTITIONING_BOOT_DEVICE@Q} swap=${swapdev@Q} type=${PARTITIONING_BOOT_TYPE@Q}" "${PARTITIONING_DEVICE@Q}" ;;
"zfs_centric") define_disk_configuration_function "create_zfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} encrypt=${PARTITIONING_ZFS_USE_ENCRYPTION@Q} compress=$(define_zfs_compression) pool_type=${PARTITIONING_ZFS_POOL_TYPE@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;; "zfs_centric") define_disk_configuration_function "create_zfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} encrypt=${PARTITIONING_ZFS_USE_ENCRYPTION@Q} compress=$(define_zfs_compression) pool_type=${PARTITIONING_ZFS_POOL_TYPE@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"btrfs_centric") define_disk_configuration_function "create_btrfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} raid_type=${PARTITIONING_BTRFS_RAID_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;; "btrfs_centric") define_disk_configuration_function "create_btrfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} raid_type=${PARTITIONING_BTRFS_RAID_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"raid0_luks") define_disk_configuration_function "create_raid0_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;; "raid0_luks") define_disk_configuration_function "create_raid0_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
@ -192,7 +199,8 @@ ALL_STAGE3_VARIANTS=(
) )
ALL_PARTITIONING_SCHEMES=( ALL_PARTITIONING_SCHEMES=(
"classic_single_disk" "Classic single disk layout (boot, swap, root)" "classic_single_disk" "Classic single disk layout (boot/efi, swap?, root)"
"existing_partitions" "Skip partitioning, use existing pre-formatted partitions"
"zfs_centric" "ZFS centric (optional ZFS compression and encryption)" "zfs_centric" "ZFS centric (optional ZFS compression and encryption)"
"btrfs_centric" "Btrfs centric (optional raid0/1 via btrfs)" "btrfs_centric" "Btrfs centric (optional raid0/1 via btrfs)"
"raid0_luks" "Raid0 (N>=2 disks) and luks for root" "raid0_luks" "Raid0 (N>=2 disks) and luks for root"
@ -248,6 +256,25 @@ function create_classic_single_disk_layout() {
PARTITIONING_ROOT_FS="${arguments[root_fs]:-ext4}" PARTITIONING_ROOT_FS="${arguments[root_fs]:-ext4}"
} }
function create_existing_partitions_layout() {
PARTITIONING_SCHEME="existing_partitions"
local known_arguments=('+swap' '+boot' '?type')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
PARTITIONING_DEVICE="${extra_arguments[0]}"
if [[ "${arguments[swap]}" == "false" ]]; then
PARTITIONING_USE_SWAP=false
PARTITIONING_SWAP_DEVICE=""
else
PARTITIONING_USE_SWAP=true
PARTITIONING_SWAP_DEVICE="${arguments[swap]}"
fi
PARTITIONING_BOOT_TYPE="${arguments[type]}"
PARTITIONING_BOOT_DEVICE="${arguments[boot]}"
}
function create_raid0_luks_layout() { function create_raid0_luks_layout() {
PARTITIONING_SCHEME="raid0_luks" PARTITIONING_SCHEME="raid0_luks"
@ -748,8 +775,10 @@ init_menu_size
MENU_ITEMS=( MENU_ITEMS=(
"PARTITIONING_SCHEME" "PARTITIONING_SCHEME"
"PARTITIONING_BOOT_TYPE" "PARTITIONING_BOOT_TYPE"
"PARTITIONING_BOOT_DEVICE"
"PARTITIONING_USE_SWAP" "PARTITIONING_USE_SWAP"
"PARTITIONING_SWAP" "PARTITIONING_SWAP"
"PARTITIONING_SWAP_DEVICE"
"PARTITIONING_ROOT_FS" "PARTITIONING_ROOT_FS"
"PARTITIONING_USE_LUKS" "PARTITIONING_USE_LUKS"
"PARTITIONING_ZFS_POOL_TYPE" "PARTITIONING_ZFS_POOL_TYPE"
@ -803,6 +832,7 @@ function PARTITIONING_SCHEME_menu() {
# Set disk scheme # Set disk scheme
case "$dialog_out" in case "$dialog_out" in
"classic_single_disk") create_classic_single_disk_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=false root_fs=ext4 /dev/sdX ;; "classic_single_disk") create_classic_single_disk_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=false root_fs=ext4 /dev/sdX ;;
"existing_partitions") create_existing_partitions_layout boot=/dev/sdA swap=false type="$DEFAULT_BOOT_TYPE" /dev/sdX ;;
"zfs_centric") create_zfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" encrypt=true compress=zstd pool_type=standard /dev/sdX ;; "zfs_centric") create_zfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" encrypt=true compress=zstd pool_type=standard /dev/sdX ;;
"btrfs_centric") create_btrfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" raid_type=raid0 luks=false /dev/sdX ;; "btrfs_centric") create_btrfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" raid_type=raid0 luks=false /dev/sdX ;;
"raid0_luks") create_raid0_luks_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" root_fs=ext4 /dev/sdX /dev/sdY ;; "raid0_luks") create_raid0_luks_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" root_fs=ext4 /dev/sdX /dev/sdY ;;
@ -816,7 +846,7 @@ function PARTITIONING_SCHEME_menu() {
} }
function PARTITIONING_BOOT_TYPE_tag() { echo " ├ Boot type"; } function PARTITIONING_BOOT_TYPE_tag() { echo " ├ Boot type"; }
function PARTITIONING_BOOT_TYPE_label() { echo " ├ ($PARTITIONING_BOOT_TYPE)$([[ $PARTITIONING_BOOT_TYPE == efi ]] &&echo -n " \Z1$EFI_UNSUPPORTED_MESSAGE_SHORT\Zn" || echo -n "")"; } function PARTITIONING_BOOT_TYPE_label() { echo " ├ ($PARTITIONING_BOOT_TYPE)$([[ $PARTITIONING_BOOT_TYPE == efi && $HAS_EFI_SUPPORT == false ]] && echo -n " \Z1$EFI_UNSUPPORTED_MESSAGE_SHORT\Zn" || echo -n "")"; }
function PARTITIONING_BOOT_TYPE_show() { [[ $PARTITIONING_SCHEME != "custom" ]]; } function PARTITIONING_BOOT_TYPE_show() { [[ $PARTITIONING_SCHEME != "custom" ]]; }
function PARTITIONING_BOOT_TYPE_help() { echo "Select whether to use EFI or BIOS boot."; } function PARTITIONING_BOOT_TYPE_help() { echo "Select whether to use EFI or BIOS boot."; }
function PARTITIONING_BOOT_TYPE_menu() { function PARTITIONING_BOOT_TYPE_menu() {
@ -835,6 +865,25 @@ function PARTITIONING_BOOT_TYPE_menu() {
fi fi
} }
function PARTITIONING_BOOT_DEVICE_tag() { echo " ├ Boot Device"; }
function PARTITIONING_BOOT_DEVICE_label() {
if [[ -e "$PARTITIONING_BOOT_DEVICE" ]]; then
echo " ├ ($PARTITIONING_BOOT_DEVICE)"
else
echo " ├ (\Z1$PARTITIONING_BOOT_DEVICE\Zn)"
fi
}
function PARTITIONING_BOOT_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
function PARTITIONING_BOOT_DEVICE_help() { echo "The device to use for the boot partition. For EFI systems this is the efi partition. Must be formatted already."; }
function PARTITIONING_BOOT_DEVICE_menu() {
dialog \
--title "Select boot device" \
--inputbox "Enter the path of the boot device which you want to partition. (e.g. /dev/sda)." \
"${INPUTBOX_SIZE[@]}" "$PARTITIONING_BOOT_DEVICE"
PARTITIONING_BOOT_DEVICE="$dialog_out"
UNSAVED_CHANGES=true
}
function PARTITIONING_USE_SWAP_tag() { echo " ├ Use swap"; } function PARTITIONING_USE_SWAP_tag() { echo " ├ Use swap"; }
function PARTITIONING_USE_SWAP_label() { on_off_label "$PARTITIONING_USE_SWAP" " ├ "; } function PARTITIONING_USE_SWAP_label() { on_off_label "$PARTITIONING_USE_SWAP" " ├ "; }
function PARTITIONING_USE_SWAP_show() { [[ $PARTITIONING_SCHEME != "custom" ]]; } function PARTITIONING_USE_SWAP_show() { [[ $PARTITIONING_SCHEME != "custom" ]]; }
@ -846,7 +895,7 @@ function PARTITIONING_USE_SWAP_menu() {
function PARTITIONING_SWAP_tag() { echo " │ └ Swap amount"; } function PARTITIONING_SWAP_tag() { echo " │ └ Swap amount"; }
function PARTITIONING_SWAP_label() { echo " │ └ ($PARTITIONING_SWAP)"; } function PARTITIONING_SWAP_label() { echo " │ └ ($PARTITIONING_SWAP)"; }
function PARTITIONING_SWAP_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP"; } function PARTITIONING_SWAP_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP" && ! one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
function PARTITIONING_SWAP_help() { echo "Select the amount of swap to use."; } function PARTITIONING_SWAP_help() { echo "Select the amount of swap to use."; }
function PARTITIONING_SWAP_menu() { function PARTITIONING_SWAP_menu() {
dialog \ dialog \
@ -857,6 +906,27 @@ function PARTITIONING_SWAP_menu() {
UNSAVED_CHANGES=true UNSAVED_CHANGES=true
} }
function PARTITIONING_SWAP_DEVICE_tag() { echo " │ └ Swap Device"; }
function PARTITIONING_SWAP_DEVICE_label() {
local dev=${PARTITIONING_SWAP_DEVICE:-/dev/sdB}
if [[ -e "$dev" ]]; then
echo " │ └ ($dev)"
else
echo " │ └ (\Z1$dev\Zn)"
fi
}
function PARTITIONING_SWAP_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP" && one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
function PARTITIONING_SWAP_DEVICE_help() { echo "The device to use as swap."; }
function PARTITIONING_SWAP_DEVICE_menu() {
dialog \
--title "Select swap device" \
--inputbox "Enter the path of the swap device. (e.g. /dev/sda)" \
"${INPUTBOX_SIZE[@]}" "${PARTITIONING_SWAP_DEVICE:-/dev/sdB}"
PARTITIONING_SWAP_DEVICE="$dialog_out"
UNSAVED_CHANGES=true
}
function PARTITIONING_ROOT_FS_tag() { echo " ├ Root filesystem"; } function PARTITIONING_ROOT_FS_tag() { echo " ├ Root filesystem"; }
function PARTITIONING_ROOT_FS_label() { echo " ├ ($PARTITIONING_ROOT_FS)"; } function PARTITIONING_ROOT_FS_label() { echo " ├ ($PARTITIONING_ROOT_FS)"; }
function PARTITIONING_ROOT_FS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "raid0_luks"; } function PARTITIONING_ROOT_FS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "raid0_luks"; }
@ -975,7 +1045,7 @@ function PARTITIONING_DEVICE_label() {
echo " └ (\Z1$PARTITIONING_DEVICE\Zn)" echo " └ (\Z1$PARTITIONING_DEVICE\Zn)"
fi fi
} }
function PARTITIONING_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk"; } function PARTITIONING_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "existing_partitions"; }
function PARTITIONING_DEVICE_help() { echo "The block device to which the layout will be applied."; } function PARTITIONING_DEVICE_help() { echo "The block device to which the layout will be applied."; }
function PARTITIONING_DEVICE_menu() { function PARTITIONING_DEVICE_menu() {
dialog \ dialog \

View File

@ -104,6 +104,20 @@ function verify_option() {
die_trace 2 "Invalid option $opt='$arg', must be one of ($*)" die_trace 2 "Invalid option $opt='$arg', must be one of ($*)"
} }
# Named arguments:
# new_id: Id for the existing device
# device: The block device
function register_existing() {
local known_arguments=('+new_id' '+device')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
create_new_id new_id
local new_id="${arguments[new_id]}"
local device="${arguments[device]}"
create_resolve_entry_device "$new_id" "$device"
}
# Named arguments: # Named arguments:
# new_id: Id for the new gpt table # new_id: Id for the new gpt table
# device|id: The operand block device or previously allocated id # device|id: The operand block device or previously allocated id
@ -334,6 +348,39 @@ function create_single_disk_layout() {
die "'create_single_disk_layout' is deprecated, please use 'create_classic_single_disk_layout' instead. It is fully option-compatible to the old version." die "'create_single_disk_layout' is deprecated, please use 'create_classic_single_disk_layout' instead. It is fully option-compatible to the old version."
} }
# Skip partitioning, and use existing partitions.
# Parameters:
# swap=<device|false> Use the given device as swap, or no swap at all if set to false
# boot=<device> Use the given device as the bios/efi partition.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
function create_existing_partitions_layout() {
local known_arguments=('+swap' '+boot' '?type')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
[[ ${#extra_arguments[@]} -eq 1 ]] \
|| die_trace 1 "Expected exactly one positional argument (the device)"
local device="${extra_arguments[0]}"
local swap_device="${arguments[swap]}"
local boot_device="${arguments[boot]}"
local type="${arguments[type]:-efi}"
register_existing new_id="part_$type" device="$boot_device"
[[ $swap_device != "false" ]] \
&& register_existing new_id="part_swap" device="$swap_device"
register_existing new_id="part_root" device="$device"
if [[ $type == "efi" ]]; then
DISK_ID_EFI="part_$type"
else
DISK_ID_BIOS="part_$type"
fi
[[ $swap_device != "false" ]] \
&& DISK_ID_SWAP=part_swap
DISK_ID_ROOT="part_root"
DISK_ID_ROOT_TYPE="" # unknown, could be anything. Left empty to skip generating an fstab entry.
}
# Multiple disks, up to 3 partitions on first disk (efi, optional swap, root with zfs). # Multiple disks, up to 3 partitions on first disk (efi, optional swap, root with zfs).
# Additional devices will be added to the zfs pool. # Additional devices will be added to the zfs pool.
# Parameters: # Parameters:

View File

@ -278,7 +278,7 @@ function generate_fstab() {
einfo "Generating fstab" einfo "Generating fstab"
install -m0644 -o root -g root "$GENTOO_INSTALL_REPO_DIR/contrib/fstab" /etc/fstab \ install -m0644 -o root -g root "$GENTOO_INSTALL_REPO_DIR/contrib/fstab" /etc/fstab \
|| die "Could not overwrite /etc/fstab" || die "Could not overwrite /etc/fstab"
if [[ $USED_ZFS != "true" ]]; then if [[ $USED_ZFS != "true" && -n $DISK_ID_ROOT_TYPE ]]; then
add_fstab_entry "UUID=$(get_blkid_uuid_for_id "$DISK_ID_ROOT")" "/" "$DISK_ID_ROOT_TYPE" "$DISK_ID_ROOT_MOUNT_OPTS" "0 1" add_fstab_entry "UUID=$(get_blkid_uuid_for_id "$DISK_ID_ROOT")" "/" "$DISK_ID_ROOT_TYPE" "$DISK_ID_ROOT_MOUNT_OPTS" "0 1"
fi fi
if [[ $IS_EFI == "true" ]]; then if [[ $IS_EFI == "true" ]]; then