new booting tweaks
This commit is contained in:
@@ -25,6 +25,8 @@ width=`tput cols`
|
|||||||
height=`tput lines`
|
height=`tput lines`
|
||||||
window=$((height - 5))
|
window=$((height - 5))
|
||||||
|
|
||||||
|
if [ -e "/sys/firmware/efi/efivars" ]; then efi="1" else efi="0"; fi
|
||||||
|
|
||||||
# gather input at the start
|
# gather input at the start
|
||||||
devices=""; for device in $(ls /dev/disk/by-id | grep -v part); do devices="$devices $device off"; done
|
devices=""; for device in $(ls /dev/disk/by-id | grep -v part); do devices="$devices $device off"; done
|
||||||
disks=`dialog --separate-output --no-cancel --no-items --title "Root devices" --checklist "Select root OS disks:" $height $width ${window}$devices 2>&1 1>/dev/tty`
|
disks=`dialog --separate-output --no-cancel --no-items --title "Root devices" --checklist "Select root OS disks:" $height $width ${window}$devices 2>&1 1>/dev/tty`
|
||||||
@@ -106,16 +108,44 @@ for disk in `echo "$alldisks"`; do
|
|||||||
echo "Done."
|
echo "Done."
|
||||||
done
|
done
|
||||||
|
|
||||||
for disk in `echo "$boots"`; do
|
if [ "$efi" = "1" ]; then
|
||||||
echo ""
|
|
||||||
echo "Creating boot partitions for device $disk..."
|
for disk in `echo "$boots"`; do
|
||||||
errors=`sgdisk -n2:1M:+512M -t2:EF00 /dev/disk/by-id/$disk 2>&1 1>/dev/null && sgdisk -n3:0:+512M -t3:BF01 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
|
echo ""
|
||||||
if ! [ "$?" = "0" ]; then
|
echo "Creating boot partitions for device $disk..."
|
||||||
echo "Failed to create boot partition for device $disk - $errors"
|
errors=`sgdisk -n2:1M:+512M -t2:EF00 /dev/disk/by-id/$disk 2>&1 1>/dev/null && sgdisk -n3:0:+512M -t3:BF01 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
|
||||||
exit 3
|
if ! [ "$?" = "0" ]; then
|
||||||
fi
|
echo "Failed to create boot partition for device $disk - $errors"
|
||||||
echo "Done."
|
exit 3
|
||||||
done
|
fi
|
||||||
|
echo "Done."
|
||||||
|
done
|
||||||
|
|
||||||
|
for disk in `echo "$disks"`; do
|
||||||
|
echo ""
|
||||||
|
echo "Creating boot partitions for device $disk..."
|
||||||
|
errors=`sgdisk -n3:0:+512M -t3:BF01 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
|
||||||
|
if ! [ "$?" = "0" ]; then
|
||||||
|
echo "Failed to create boot partition for device $disk - $errors"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
echo "Done."
|
||||||
|
done
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
for disk in `echo "$boots"`; do
|
||||||
|
echo ""
|
||||||
|
echo "Creating boot partitions for device $disk..."
|
||||||
|
errors=`sgdisk -a1 -n1:24K:+1000K -t1:EF02 /dev/disk/by-id/$disk 2>&1 1>/dev/null`
|
||||||
|
if ! [ "$?" = "0" ]; then
|
||||||
|
echo "Failed to create boot partition for device $disk - $errors"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
echo "Done."
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
for disk in `echo "$disks"`; do
|
for disk in `echo "$disks"`; do
|
||||||
echo ""
|
echo ""
|
||||||
@@ -135,9 +165,10 @@ bootmirror=""; rootraidz=""; for disk in `echo "$disks"`; do bootmirror="$bootmi
|
|||||||
partprobe 2>/dev/null 1>/dev/null
|
partprobe 2>/dev/null 1>/dev/null
|
||||||
|
|
||||||
# wait for the partitions to show up
|
# wait for the partitions to show up
|
||||||
for disk in `echo "$boots"`; do
|
|
||||||
|
for disk in `echo "$disk"`; do
|
||||||
pending="0"
|
pending="0"
|
||||||
while ! [ -e "/dev/disk/by-id/${disk}-part3" ]; do
|
while ! [ -e "/dev/disk/by-id/${disk}-part1" ]; do
|
||||||
partprobe 2>/dev/null 1>/dev/null
|
partprobe 2>/dev/null 1>/dev/null
|
||||||
if [ "$pending" = "0" ]; then echo "" && echo "Waiting for ${disk} boot partition to update..."; pending="1"; fi
|
if [ "$pending" = "0" ]; then echo "" && echo "Waiting for ${disk} boot partition to update..."; pending="1"; fi
|
||||||
sleep 3
|
sleep 3
|
||||||
@@ -389,16 +420,19 @@ echo "if ! [ \"\$?\" = \"0\" ]; then echo \"Failed to install grub UEFI on plex1
|
|||||||
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
|
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
|
||||||
|
|
||||||
if ! [ "$boots" = "" ]; then
|
if ! [ "$boots" = "" ]; then
|
||||||
echo 'echo ""' >> /mnt/setup-chroot.sh
|
if [ "$efi" = "1" ]; then
|
||||||
echo 'echo "Cloning EFI boot partition to all boot devices..."' >> /mnt/setup-chroot.sh
|
|
||||||
i="2"
|
|
||||||
for disk in `echo "$boots" | tail -n+2`; do
|
|
||||||
echo "errors=\$(dd if=/dev/disk/by-id/${firstdisk}-part2 of=/dev/disk/by-id/${disk}-part2 2>&1 1>/dev/null && efibootmgr -c -g -d /dev/disk/by-id/${disk} -p 3 -L "ubuntu-$i" -l '\EFI\ubuntu\grubx64.efi' 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
|
||||||
echo "if ! [ \"\$?\" = \"0\" ]; then echo \"EFI copy failed - \$errors\"; exit 20; fi" >> /mnt/setup-chroot.sh
|
|
||||||
i=$((i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo 'echo "Done."' >> /mnt/setup-chroot.sh
|
echo 'echo ""' >> /mnt/setup-chroot.sh
|
||||||
|
echo 'echo "Cloning EFI boot partition to all boot devices..."' >> /mnt/setup-chroot.sh
|
||||||
|
i="2"
|
||||||
|
for disk in `echo "$boots" | tail -n+2`; do
|
||||||
|
echo "errors=\$(dd if=/dev/disk/by-id/${firstdisk}-part2 of=/dev/disk/by-id/${disk}-part2 2>&1 1>/dev/null && efibootmgr -c -g -d /dev/disk/by-id/${disk} -p 3 -L "ubuntu-$i" -l '\EFI\ubuntu\grubx64.efi' 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
||||||
|
echo "if ! [ \"\$?\" = \"0\" ]; then echo \"EFI copy failed - \$errors\"; exit 20; fi" >> /mnt/setup-chroot.sh
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo 'echo "Done."' >> /mnt/setup-chroot.sh
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# error check this as one big block
|
# error check this as one big block
|
||||||
|
|||||||
Reference in New Issue
Block a user