X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Fimage-provision.git;a=blobdiff_plain;f=dracut%2Fmodules%2F00installmedia%2Finstallmedia.sh;h=57026a34bb396bc6d2178c3f276b73279b261180;hp=3d24dafb66a0167479fbddc93c7c80d69e7220e5;hb=9ae903606e4e36c1dd652279c412b5ef0ab7d762;hpb=06e73ed8bfb037b6e49ceda1c8cb234b57566b47 diff --git a/dracut/modules/00installmedia/installmedia.sh b/dracut/modules/00installmedia/installmedia.sh index 3d24daf..57026a3 100755 --- a/dracut/modules/00installmedia/installmedia.sh +++ b/dracut/modules/00installmedia/installmedia.sh @@ -77,7 +77,7 @@ for hd_dev in ${hd_devices[@]}; do if [ -b /dev/$hd_dev ] && (( is_removable $hd_dev ) || ( is_partition $hd_dev ) || ( is_loop $hd_dev )); then logmsg "Removable, loop or partition $hd_dev. Skipping..." continue - elif ! [ -b /dev/$hd_dev ];then + elif ! [ -b /dev/$hd_dev ]; then continue fi logmsg "Erasing existing GPT and MBR data structures from ${hd_dev}" @@ -96,6 +96,21 @@ if [ $? -ne 0 ]; then fi sync +partprobe ${rootdev} +is_esp_partition_present "${rootdev}" +rootdev_has_uefi=$? + +# For UEFI systems (which imply using a GPT partition table), fix the GPT backup +# data structures by moving them to the end of the disk; rootfs partition will +# have index 3 (1=ESP, 2=boot, 3=rootfs), unlike BIOS/MBR layout where it has 1. +if [ "${rootdev_has_uefi}" -eq 0 ]; then + sgdisk -e "${rootdev}" + sleep 5 + rootpartno=3 +else + rootpartno=1 +fi + logmsg "${rootdev} dumped successfully!" echo "Finishing installation... Please wait." > $CONSOLE_DEV @@ -104,12 +119,22 @@ partprobe ${rootdev} parted ${rootdev} --script -- mkpart primary 50GiB -1 partprobe ${rootdev} -mount ${rootdev}1 /sysroot/ +# For GPT and 3 partitions, it might take some time to (re)discover them all +sleep 5 +mount "${rootdev}${rootpartno}" /sysroot/ if [ $? -ne 0 ];then logmsg "FAILED TO MOUNT SYSROOT. All hope is lost" exit 255 fi +if [ "${rootdev_has_uefi}" -eq 0 ]; then + mount "${rootdev}1" /sysroot/boot/efi + if [ $? -ne 0 ];then + logmsg "FAILED TO MOUNT EFI SYSTEM PARTITION. All hope is lost" + exit 255 + fi +fi + kernel_cmdline="intel_iommu=on iommu=pt crashkernel=256M" # Check if this has a iscsi target if so, add extra cmdline option for HDD boot. iscsiadm -m fw >/dev/null 2>&1 @@ -125,10 +150,14 @@ fi run_crit mount -o bind /dev /sysroot/dev run_crit mount -o bind /proc /sysroot/proc run_crit mount -o bind /sys /sysroot/sys -run_crit chroot /sysroot /bin/bash -c \"/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg\" +if [ "${rootdev_has_uefi}" -eq 0 ]; then + run_crit chroot /sysroot /bin/bash -c \"/usr/sbin/grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg\" +else + run_crit chroot /sysroot /bin/bash -c \"/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg\" +fi logmsg "Extending partition and filesystem size" -run_crit chroot /sysroot /bin/bash -c \"growpart ${rootdev} 1\" +run_crit chroot /sysroot /bin/bash -c \"growpart ${rootdev} ${rootpartno}\" run_crit chroot /sysroot /bin/bash -c \"xfs_growfs /\" logmsg "Copying cloud guest image" @@ -168,6 +197,9 @@ cp -rf /run/initramfs/ /sysroot/var/log/provisioning-logs/ sync +if [ "${rootdev_has_uefi}" -eq 0 ]; then + umount /sysroot/boot/efi +fi umount /sysroot/dev umount /sysroot/proc umount /sysroot/sys