Fix nvme auto_partition()
This commit is contained in:
parent
63fac78577
commit
6acc34d429
@ -15,7 +15,7 @@
|
||||
# immutable variables {
|
||||
|
||||
readonly DIST="Archlabs" # Linux distributor
|
||||
readonly VER="1.6.36" # Installer version
|
||||
readonly VER="1.6.37" # Installer version
|
||||
readonly LIVE="liveuser" # Live session user
|
||||
readonly TRN="/usr/share/archlabs-installer" # Translation path
|
||||
readonly MNT="/mnt/install" # Install mountpoint
|
||||
@ -881,9 +881,10 @@ auto_partition() {
|
||||
# confirm or bail
|
||||
yesno "$_PrepParts" "$_PartBody1 $device $_PartBody2" || return 0
|
||||
infobox "$_PrepParts" "\nAuto partitioning device: $device\n"
|
||||
swapoff -a # make sure swap is disabled
|
||||
|
||||
# partition number of each partition on the device in reverse order
|
||||
swapoff -a # make sure swap is disabled in case the device was used for swap
|
||||
|
||||
# walk the partitions on the device in reverse order and delete them
|
||||
local dev_info="$(parted -s $device print)"
|
||||
for i in $(awk '/^ [1-9][0-9]?/ {print $1}' <<< "$dev_info" | sort -r); do
|
||||
parted -s $device rm $i 2>$ERR
|
||||
@ -892,11 +893,8 @@ auto_partition() {
|
||||
|
||||
# make sure we have the correct device table for the system type, gpt or msdos
|
||||
local table="$(awk '/Table:/ {print $3}' <<< "$dev_info")"
|
||||
if [[ $SYS == BIOS ]]; then
|
||||
local newtable="msdos"
|
||||
else
|
||||
local newtable="gpt"
|
||||
fi
|
||||
local newtable="gpt"
|
||||
[[ $SYS == BIOS ]] && newtable="msdos"
|
||||
|
||||
# if the current device table isn't correct run mklabel
|
||||
if [[ $table != "$newtable" ]]; then
|
||||
@ -904,40 +902,43 @@ auto_partition() {
|
||||
check_for_errors "parted -s $device mklabel $newtable" || return 1
|
||||
fi
|
||||
|
||||
# when device contains the string 'nvme' then add 'p' before the part number
|
||||
local nvme=""
|
||||
[[ $device =~ nvme ]] && nvme="p"
|
||||
|
||||
local part_num=1
|
||||
BOOT_PART="${device}$part_num"
|
||||
BOOT_PART="$device${nvme}$part_num" # set the boot partition label to the first partition
|
||||
|
||||
if [[ $SYS == "BIOS" ]]; then
|
||||
parted -s $device mkpart primary ext4 1MiB 513MiB 2>$ERR
|
||||
check_for_errors "parted -s $device mkpart primary ext4 1MiB 513MiB" || { BOOT_PART=""; return 1; }
|
||||
check_for_errors "parted -s $device mkpart primary ext4 1MiB 513MiB" || return 1
|
||||
mkfs.ext4 -q $BOOT_PART >/dev/null 2>$ERR
|
||||
check_for_errors "mkfs.ext4 -q $BOOT_PART" || { BOOT_PART=""; return 1; }
|
||||
check_for_errors "mkfs.ext4 -q $BOOT_PART" || return 1
|
||||
else
|
||||
parted -s $device mkpart ESP fat32 1MiB 513MiB 2>$ERR
|
||||
check_for_errors "parted -s $device mkpart ESP fat32 1MiB 513MiB" || { BOOT_PART=""; return 1; }
|
||||
check_for_errors "parted -s $device mkpart ESP fat32 1MiB 513MiB" || return 1
|
||||
mkfs.vfat -F32 $BOOT_PART >/dev/null 2>$ERR
|
||||
check_for_errors "mkfs.vfat -F32 $BOOT_PART" || { BOOT_PART=""; return 1; }
|
||||
parted -s $device set 1 esp on 2>$ERR
|
||||
check_for_errors "parted -s $device set 1 esp on" || { BOOT_PART=""; return 1; }
|
||||
check_for_errors "mkfs.vfat -F32 $BOOT_PART" || return 1
|
||||
parted -s $device set $part_num esp on 2>$ERR
|
||||
check_for_errors "parted -s $device set $part_num esp on" || return 1
|
||||
fi
|
||||
|
||||
parted -s $device set 1 boot on 2>$ERR
|
||||
check_for_errors "parted -s $device set 1 boot on" || return 1
|
||||
parted -s $device set $part_num boot on 2>$ERR
|
||||
check_for_errors "parted -s $device set $part_num boot on" || return 1
|
||||
|
||||
BOOT_DEVICE="$device" # only grub on BIOS systems uses this
|
||||
ROOT_PART="${device}$((part_num + 1))"
|
||||
(( part_num++ )) # increment the partition number
|
||||
BOOT_DEVICE="$device" # only grub on BIOS systems uses this
|
||||
ROOT_PART="${device}${nvme}$part_num" # set root partition label to the second partition
|
||||
|
||||
parted -s $device mkpart primary ext4 514MiB 100% 2>$ERR
|
||||
check_for_errors "parted -s $device mkpart primary ext4 514MiB 100%" || return 1
|
||||
mkfs.ext4 -q $ROOT_PART >/dev/null 2>$ERR
|
||||
check_for_errors "mkfs.ext4 -q $ROOT_PART" || { ROOT_PART=""; return 1; }
|
||||
check_for_errors "mkfs.ext4 -q $ROOT_PART" || return 1
|
||||
|
||||
tput civis
|
||||
sleep 0.5
|
||||
tput civis; sleep 0.5
|
||||
echo -e "\nAuto partitioning complete.\n" > /tmp/.devlist
|
||||
lsblk $device -o NAME,MODEL,TYPE,FSTYPE,SIZE >> /tmp/.devlist
|
||||
dialog --cr-wrap --backtitle "$BT" --title " $_PrepParts " --textbox /tmp/.devlist 0 0
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user