Skip to content

Instantly share code, notes, and snippets.

@pearsonc
Forked from umpirsky/ubuntu-raid.sh
Last active April 18, 2024 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pearsonc/d3839ca1ad4e8d4520a3d907ed5f636e to your computer and use it in GitHub Desktop.
Save pearsonc/d3839ca1ad4e8d4520a3d907ed5f636e to your computer and use it in GitHub Desktop.
Install Ubuntu on RAID 0 and UEFI/GPT system
sudo -s
sgdisk -z /dev/sda -g # Delete all partitions and create a gpt table
sgdisk -z /dev/sdb -g # Delete all partitions and create a gpt table
sgdisk -n 1:0:+100M -t 1:ef00 -c 1:"EFI System" /dev/sda
sgdisk -n 2:0:+8G -t 2:fd00 -c 2:"Linux RAID Swap" /dev/sda
sgdisk -n 3:0:0 -t 3:fd00 -c 3:"Linux RAID" /dev/sda
sgdisk /dev/sda -R /dev/sdb -G
mkfs.fat -F 32 /dev/sda1
mkdir /tmp/sda1
mount /dev/sda1 /tmp/sda1
mkdir /tmp/sda1/EFI
umount /dev/sda1
apt-get clean && apt-get update && apt-get install vim grub-efi-amd64 mdadm -y
mdadm --create /dev/md0 --level=0 --raid-disks=2 /dev/sda2 /dev/sdb2
mdadm --create /dev/md1 --level=0 --raid-disks=2 /dev/sda3 /dev/sdb3
sgdisk -z /dev/md0
sgdisk -z /dev/md1
sgdisk -N 1 -t 1:8200 -c 1:"Linux swap" /dev/md0
sgdisk -N 1 -t 1:8300 -c 1:"Linux filesystem" /dev/md1
ubiquity -b
mount /dev/md1p1 /mnt
mount -o bind /dev /mnt/dev
mount -o bind /dev/pts /mnt/dev/pts
mount -o bind /sys /mnt/sys
mount -o bind /proc /mnt/proc
cat /etc/resolv.conf >> /mnt/etc/resolv.conf
chroot /mnt
sudo apt-get clean && sudo apt-get update && apt-get install vim htop -y
vi /etc/grub.d/10_linux
# change quick_boot and quiet_boot to 0
sudo mount -t efivarfs efivarfs /sys/firmware/efi/efivars
apt-get install -y grub-efi-amd64
apt-get install -y mdadm
vi /etc/mdadm/mdadm.conf
# remove metadata and name
update-grub
mount /dev/sda1 /boot/efi
grub-install --boot-directory=/boot --bootloader-id=Ubuntu --target=x86_64-efi --efi-directory=/boot/efi --recheck
update-grub
umount /dev/sda1
dd if=/dev/sda1 of=/dev/sdb1
efibootmgr -c -g -d /dev/sdb -p 1 -L "Ubuntu #2" -l '\EFI\Ubuntu\grubx64.efi'
exit # from chroot
exit # from sudo -s
reboot
# Restart computer and disable Secure boot to allow you to boot the install for the first time
# Once booted you will be required to install shim-signed, DO NOT DO THIS UNTIL REBOOTED.
sudo apt-get install shim-signed
reboot
# Before allowing the boot to start enter the Bios and re-enable secure boot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment