From cc95e9be6219fe760c50df3078178d985155cb8f Mon Sep 17 00:00:00 2001 From: Volodymyr Fedorov Date: Tue, 2 Oct 2018 14:24:10 +0200 Subject: [PATCH] TT#44972 Enable to install to NVMe drives By default we do assumption that we are installing to standard block devices, this is not working for NVMe hardware name spaces. Here we try to detect underlying device for named partition. Change-Id: I7d2ea339a3aee2a8458a72cfc392441721d350c7 --- templates/scripts/includes/deployment.sh | 25 +++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/templates/scripts/includes/deployment.sh b/templates/scripts/includes/deployment.sh index 62eeb0c..73613da 100755 --- a/templates/scripts/includes/deployment.sh +++ b/templates/scripts/includes/deployment.sh @@ -1040,11 +1040,14 @@ parted_execution() { parted -a optimal -s "${blockdevice}" mkpart primary 2M 512M parted -a optimal -s "${blockdevice}" "name 2 'EFI System'" parted -a optimal -s "${blockdevice}" set 2 boot on - EFI_PARTITION="${blockdevice}"2 + echo "Get path of EFI partition" + blockdev --flushbufs "${blockdevice}" + EFI_PARTITION=$(blkid -t PARTLABEL="EFI System" -o device "${blockdevice}"*) } set_up_partition_table_noswraid() { local blockdevice + local pvdevice blockdevice="/dev/${DISK}" clear_partition_table "$blockdevice" @@ -1054,14 +1057,18 @@ set_up_partition_table_noswraid() { parted -a optimal -s "${blockdevice}" "name 3 'Linux LVM'" parted -a optimal -s "${blockdevice}" set 3 lvm on + blockdev --flushbufs "${blockdevice}" + pvdevice=$(blkid -t PARTLABEL="Linux LVM" -o device "${blockdevice}"*) echo "Creating PV + VG" - pvcreate -ff -y "${blockdevice}"3 - vgcreate "${VG_NAME}" "${blockdevice}"3 + pvcreate -ff -y "${pvdevice}" + vgcreate "${VG_NAME}" "${pvdevice}" vgchange -a y "${VG_NAME}" } set_up_partition_table_swraid() { # make sure we don't overlook unassembled SW-RAIDs + local raidev1 + local raidev2 mdadm --assemble --scan || true # fails if there's nothing to assemble if [[ -b "${SWRAID_DEVICE}" ]] ; then @@ -1095,8 +1102,10 @@ set_up_partition_table_swraid() { sgdisk "/dev/${SWRAID_DISK1}" -R "/dev/${SWRAID_DISK2}" # randomize the disk's GUID and all partitions' unique GUIDs after cloning sgdisk -G "/dev/${SWRAID_DISK2}" + raidev1=$(blkid -t PARTLABEL="Linux RAID" -o device "/dev/${SWRAID_DISK1}"*) + raidev2=$(blkid -t PARTLABEL="Linux RAID" -o device "/dev/${SWRAID_DISK2}"*) - echo y | mdadm --create --verbose "${SWRAID_DEVICE}" --level=1 --raid-devices=2 "/dev/${SWRAID_DISK1}"3 "/dev/${SWRAID_DISK2}"3 + echo y | mdadm --create --verbose "${SWRAID_DEVICE}" --level=1 --raid-devices=2 "${raidev1}" "${raidev2}" echo "Creating PV + VG on ${SWRAID_DEVICE}" pvcreate -ff -y "${SWRAID_DEVICE}" @@ -2064,7 +2073,7 @@ fi if [[ "${SWRAID}" = "true" ]] ; then if efi_support ; then - chroot "${TARGET}" mount /boot/efi + grml-chroot "${TARGET}" mount /boot/efi if efibootmgr | grep -q 'NGCP Fallback' ; then echo "Deleting existing NGCP Fallback entry from EFI boot manager" @@ -2107,8 +2116,10 @@ dmsetup remove_all || true if [[ "${SWRAID}" = "true" ]] ; then if efi_support ; then - echo "Cloning EFI partition from /dev/${SWRAID_DISK1}2 to /dev/${SWRAID_DISK2}2" - dd if="/dev/${SWRAID_DISK1}2" of="/dev/${SWRAID_DISK2}2" bs=10M + efidev1=$(blkid -t PARTLABEL="EFI System" -o device "/dev/${SWRAID_DISK1}"*) + efidev2=$(blkid -t PARTLABEL="EFI System" -o device "/dev/${SWRAID_DISK2}"*) + echo "Cloning EFI partition from ${efidev1} to ${efidev2}" + dd if="${efidev1}" of="${efidev2}" bs=10M fi fi