Use wipefs before creating partitions or formatting

This commit is contained in:
oddlama 2021-06-01 02:50:08 +02:00
parent b347ef4b02
commit 6f25eae015
No known key found for this signature in database
GPG Key ID: 14EFE510775FE39A
2 changed files with 15 additions and 2 deletions

4
configure vendored
View File

@ -328,7 +328,7 @@ function load_default_config() {
function disk_configuration() { function disk_configuration() {
#create_zfs_centric_layout swap=8GiB type=efi encrypt=true pool_type=standard /dev/sdX #create_zfs_centric_layout swap=8GiB type=efi encrypt=true pool_type=standard /dev/sdX
create_single_disk_layout swap=8GiB type=efi luks=true root_fs=ext4 /dev/sdX create_classic_single_disk_layout swap=8GiB type=efi luks=true root_fs=ext4 /dev/sdX
} }
SYSTEMD=true SYSTEMD=true
@ -830,7 +830,7 @@ function PARTITIONING_ROOT_FS_menu() {
fi fi
} }
function PARTITIONING_USE_LUKS_tag() { echo " ├ Use LUKS"; } function PARTITIONING_USE_LUKS_tag() { echo " ├ LUKS Encryption"; }
function PARTITIONING_USE_LUKS_label() { on_off_label "$PARTITIONING_USE_LUKS" " ├ "; } function PARTITIONING_USE_LUKS_label() { on_off_label "$PARTITIONING_USE_LUKS" " ├ "; }
function PARTITIONING_USE_LUKS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "btrfs_centric"; } function PARTITIONING_USE_LUKS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "btrfs_centric"; }
function PARTITIONING_USE_LUKS_help() { echo "Determines if LUKS will be used to encrypt your root partition. You can export the desired encryption key via export GENTOO_INSTALL_ENCRYPTION_KEY='...' before installing if you don't want to be asked."; } function PARTITIONING_USE_LUKS_help() { echo "Determines if LUKS will be used to encrypt your root partition. You can export the desired encryption key via export GENTOO_INSTALL_ENCRYPTION_KEY='...' before installing if you don't want to be asked."; }

View File

@ -180,6 +180,8 @@ function disk_create_gpt() {
local ptuuid="${DISK_ID_TO_UUID[$new_id]}" local ptuuid="${DISK_ID_TO_UUID[$new_id]}"
einfo "Creating new gpt partition table ($new_id) on $device_desc" einfo "Creating new gpt partition table ($new_id) on $device_desc"
wipefs --quiet --all --force "$device" \
|| die "Could not erase previous file system signatures from '$device'"
sgdisk -Z -U "$ptuuid" "$device" >/dev/null \ sgdisk -Z -U "$ptuuid" "$device" >/dev/null \
|| die "Could not create new gpt partition table ($new_id) on '$device'" || die "Could not create new gpt partition table ($new_id) on '$device'"
partprobe "$device" partprobe "$device"
@ -358,7 +360,11 @@ function disk_format() {
local device local device
device="$(resolve_device_by_id "$id")" \ device="$(resolve_device_by_id "$id")" \
|| die "Could not resolve device with id=$id" || die "Could not resolve device with id=$id"
einfo "Formatting $device ($id) with $type" einfo "Formatting $device ($id) with $type"
wipefs --quiet --all --force "$device" \
|| die "Could not erase previous file system signatures from '$device' ($id)"
case "$type" in case "$type" in
'bios'|'efi') 'bios'|'efi')
if [[ -v "arguments[label]" ]]; then if [[ -v "arguments[label]" ]]; then
@ -413,6 +419,7 @@ function format_zfs_standard() {
local devices=("$@") local devices=("$@")
einfo "Creating zfs pool on $devices_desc" einfo "Creating zfs pool on $devices_desc"
local extra_args=() local extra_args=()
if [[ "$encrypt" == true ]]; then if [[ "$encrypt" == true ]]; then
extra_args+=( extra_args+=(
@ -476,6 +483,9 @@ function disk_format_zfs() {
done done
devices_desc="${devices_desc:0:-2}" devices_desc="${devices_desc:0:-2}"
wipefs --quiet --all --force "${devices[@]}" \
|| die "Could not erase previous file system signatures from $devices_desc"
if [[ "$pool_type" == "custom" ]]; then if [[ "$pool_type" == "custom" ]]; then
format_zfs_custom "$encrypt" "$devices_desc" "${devices[@]}" format_zfs_custom "$encrypt" "$devices_desc" "${devices[@]}"
else else
@ -511,6 +521,9 @@ function disk_format_btrfs() {
done done
devices_desc="${devices_desc:0:-2}" devices_desc="${devices_desc:0:-2}"
wipefs --quiet --all --force "${devices[@]}" \
|| die "Could not erase previous file system signatures from $devices_desc"
# Collect extra arguments # Collect extra arguments
extra_args=() extra_args=()
if [[ "${#devices}" -gt 1 ]] && [[ -v "arguments[raid_type]" ]]; then if [[ "${#devices}" -gt 1 ]] && [[ -v "arguments[raid_type]" ]]; then