Compare commits
10
Commits
c089338005
...
acf94c1c70
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acf94c1c70 | ||
|
|
fc27be9805 | ||
|
|
08dea28243 | ||
|
|
2506714ae8 | ||
|
|
b51e5f1db5 | ||
|
|
b09786d730 | ||
|
|
89977b70a4 | ||
|
|
0a9ace0897 | ||
|
|
9c8c803090 | ||
|
|
9f9168ae6b |
@@ -25,6 +25,8 @@ width=`tput cols`
|
|||||||
height=`tput lines`
|
height=`tput lines`
|
||||||
window=$((height - 5))
|
window=$((height - 5))
|
||||||
|
|
||||||
|
if [ -d "/sys/firmware/efi" ]; then efi="1"; echo -e "\nUEFI detected..." else efi="0"; echo -e "\nBIOS detected..."; 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 -n1:1M:+512M -t1:EF00 /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 "$boots"`; 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 ""
|
||||||
@@ -128,18 +158,31 @@ for disk in `echo "$disks"`; do
|
|||||||
echo "Done."
|
echo "Done."
|
||||||
done
|
done
|
||||||
|
|
||||||
# create boot mirror list
|
# create boot mirror list and root list
|
||||||
bootmirror=""; rootraidz=""; for disk in `echo "$disks"`; do bootmirror="$bootmirror /dev/disk/by-id/${disk}-part3"; rootraidz="$rootraidz /dev/disk/by-id/${disk}-part4"; done
|
|
||||||
|
count="0"; bootmirror=""; for disk in `echo "$boots"`; do bootmirror="$bootmirror /dev/disk/by-id/${disk}-part3"; count=$((count + 1)); done; if [ "$count" -gt "1" ]; then bootmirror="mirror $bootmirror"; fi
|
||||||
|
rootraidz=""; for disk in `echo "$disks"`; do rootraidz="$rootraidz /dev/disk/by-id/${disk}-part4"; done
|
||||||
|
|
||||||
# refresh drives or there are missing partitions
|
# refresh drives or there are missing partitions
|
||||||
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 "$boots"`; do
|
||||||
pending="0"
|
pending="0"
|
||||||
while ! [ -e "/dev/disk/by-id/${disk}-part3" ]; do
|
while ! [ -e "/dev/disk/by-id/${disk}-part3" ]; 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 pool partition to update on device ${disk}..."; pending="1"; fi
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
if [ "$pending" = "1" ]; then echo "Done."; fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for disk in `echo "$boots"`; do
|
||||||
|
pending="0"
|
||||||
|
while ! [ -e "/dev/disk/by-id/${disk}-part1" ]; do
|
||||||
|
partprobe 2>/dev/null 1>/dev/null
|
||||||
|
if [ "$pending" = "0" ]; then echo "" && echo "Waiting for ${disk} boot partition to update on device ${disk}..."; pending="1"; fi
|
||||||
sleep 3
|
sleep 3
|
||||||
done
|
done
|
||||||
if [ "$pending" = "1" ]; then echo "Done."; fi
|
if [ "$pending" = "1" ]; then echo "Done."; fi
|
||||||
@@ -147,7 +190,7 @@ done
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Creating boot zpool..."
|
echo "Creating boot zpool..."
|
||||||
errors=`zpool create -f -o ashift=12 -d -o feature@async_destroy=enabled -o feature@bookmarks=enabled -o feature@embedded_data=enabled -o feature@empty_bpobj=enabled -o feature@enabled_txg=enabled -o feature@extensible_dataset=enabled -o feature@filesystem_limits=enabled -o feature@hole_birth=enabled -o feature@large_blocks=enabled -o feature@lz4_compress=enabled -o feature@spacemap_histogram=enabled -o feature@userobj_accounting=enabled -O acltype=posixacl -O canmount=off -O compression=lz4 -O devices=off -O normalization=formD -O relatime=on -O xattr=sa -O mountpoint=/ -R /mnt bpool mirror$bootmirror 2>&1 1>/dev/null`
|
errors=`zpool create -f -o ashift=12 -d -o feature@async_destroy=enabled -o feature@bookmarks=enabled -o feature@embedded_data=enabled -o feature@empty_bpobj=enabled -o feature@enabled_txg=enabled -o feature@extensible_dataset=enabled -o feature@filesystem_limits=enabled -o feature@hole_birth=enabled -o feature@large_blocks=enabled -o feature@lz4_compress=enabled -o feature@spacemap_histogram=enabled -o feature@userobj_accounting=enabled -O acltype=posixacl -O canmount=off -O compression=lz4 -O devices=off -O normalization=formD -O relatime=on -O xattr=sa -O mountpoint=/ -R /mnt bpool $bootmirror 2>&1 1>/dev/null`
|
||||||
if ! [ "$?" = "0" ]; then
|
if ! [ "$?" = "0" ]; then
|
||||||
echo "Failed to create boot pool - $errors"
|
echo "Failed to create boot pool - $errors"
|
||||||
exit 4
|
exit 4
|
||||||
@@ -322,12 +365,12 @@ echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /mnt/etc/sysctl.conf
|
|||||||
echo 'echo ""' >> /mnt/setup-chroot.sh
|
echo 'echo ""' >> /mnt/setup-chroot.sh
|
||||||
echo 'echo "Creating EFI partition..."' >> /mnt/setup-chroot.sh
|
echo 'echo "Creating EFI partition..."' >> /mnt/setup-chroot.sh
|
||||||
firstdisk=`echo "$boots" | head -n1`
|
firstdisk=`echo "$boots" | head -n1`
|
||||||
echo "error=\$(mkdosfs -F 32 -s 1 -n EFI /dev/disk/by-id/${firstdisk}-part2 2>&1 1>/dev/null && mkdir /boot/efi 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
echo "error=\$(mkdosfs -F 32 -s 1 -n EFI /dev/disk/by-id/${firstdisk}-part1 2>&1 1>/dev/null && mkdir /boot/efi 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
||||||
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
|
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
|
||||||
echo ' echo "Failed to create dos file system for EFI partition - $errors"' >> /mnt/setup-chroot.sh
|
echo ' echo "Failed to create dos file system for EFI partition - $errors"' >> /mnt/setup-chroot.sh
|
||||||
echo " exit 100">> /mnt/setup-chroot.sh
|
echo " exit 100">> /mnt/setup-chroot.sh
|
||||||
echo "fi">> /mnt/setup-chroot.sh
|
echo "fi">> /mnt/setup-chroot.sh
|
||||||
echo "echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-id/${firstdisk}-part2) /boot/efi vfat nofail,x-systemd.device-timeout=0 0 1 >> /etc/fstab" >> /mnt/setup-chroot.sh
|
echo "echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-id/${firstdisk}-part1) /boot/efi vfat nofail,x-systemd.device-timeout=0 0 1 >> /etc/fstab" >> /mnt/setup-chroot.sh
|
||||||
|
|
||||||
echo "errors=\$(mount /boot/efi 2>&1 1>/dev/null && apt install -y grub-efi-amd64-signed shim-signed 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
echo "errors=\$(mount /boot/efi 2>&1 1>/dev/null && apt install -y grub-efi-amd64-signed shim-signed 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
||||||
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
|
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
|
||||||
@@ -359,6 +402,7 @@ echo "echo \"Success.\"" >> /mnt/setup-chroot.sh
|
|||||||
|
|
||||||
echo 'echo ""' >> /mnt/setup-chroot.sh
|
echo 'echo ""' >> /mnt/setup-chroot.sh
|
||||||
echo 'echo "Updating initramfs..."' >> /mnt/setup-chroot.sh
|
echo 'echo "Updating initramfs..."' >> /mnt/setup-chroot.sh
|
||||||
|
echo "echo \"vmd\" >> /etc/initramfs-tools/modules" >> /mnt/setup-chroot.sh
|
||||||
echo 'errors=$(update-initramfs -u -k all 2>&1 1>/dev/null)' >> /mnt/setup-chroot.sh
|
echo 'errors=$(update-initramfs -u -k all 2>&1 1>/dev/null)' >> /mnt/setup-chroot.sh
|
||||||
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
|
echo 'if ! [ \"$?\" = \"0\" ]; then '>> /mnt/setup-chroot.sh
|
||||||
echo ' echo "Failed to update initramfs - $errors"' >> /mnt/setup-chroot.sh
|
echo ' echo "Failed to update initramfs - $errors"' >> /mnt/setup-chroot.sh
|
||||||
@@ -369,7 +413,7 @@ echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
|
|||||||
# you need sed to do this right!
|
# you need sed to do this right!
|
||||||
echo 'echo ""' >> /mnt/setup-chroot.sh
|
echo 'echo ""' >> /mnt/setup-chroot.sh
|
||||||
echo 'echo "Modifying grub for ZFS root..."' >> /mnt/setup-chroot.sh
|
echo 'echo "Modifying grub for ZFS root..."' >> /mnt/setup-chroot.sh
|
||||||
echo "errors=\$(sed -ir 's/quiet splash//g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/GRUB_CMDLINE_LINUX=\".*\"/GRUB_CMDLINE_LINUX=\"root=ZFS=rpool\/ROOT\/ubuntu\"/g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/^#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /etc/default/grub 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
echo "errors=\$(sed -ir 's/quiet splash//g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/GRUB_CMDLINE_LINUX=\".*\"/GRUB_CMDLINE_LINUX=\"root=ZFS=rpool\/ROOT\/ubuntu rootdelay=10 noresume\"/g' /etc/default/grub 2>&1 1>/dev/null && sed -ir 's/^#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /etc/default/grub 2>&1 1>/dev/null)" >> /mnt/setup-chroot.sh
|
||||||
echo "if ! [ \"\$?\" = \"0\" ]; then echo \"Failed to set grub ZFS root - \$errors\"; exit 104; fi" >> /mnt/setup-chroot.sh
|
echo "if ! [ \"\$?\" = \"0\" ]; then echo \"Failed to set grub ZFS root - \$errors\"; exit 104; fi" >> /mnt/setup-chroot.sh
|
||||||
echo 'echo "Done."' >> /mnt/setup-chroot.sh
|
echo 'echo "Done."' >> /mnt/setup-chroot.sh
|
||||||
|
|
||||||
@@ -389,16 +433,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}-part1 of=/dev/disk/by-id/${disk}-part1 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