Skip to content

Instantly share code, notes, and snippets.

@leowinterde
Forked from umpirsky/ubuntu-raid.sh
Last active April 18, 2024 09:26
Show Gist options
  • Save leowinterde/8618534acc55df4b090dd7064db48a2c to your computer and use it in GitHub Desktop.
Save leowinterde/8618534acc55df4b090dd7064db48a2c to your computer and use it in GitHub Desktop.
Install Ubuntu on RAID 1 and UEFI/GPT system without SWAP - 2017
# http://askubuntu.com/questions/505446/how-to-install-ubuntu-14-04-with-raid-1-using-desktop-installer
# http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi%5D
sudo -s
apt-get -y install mdadm grub-efi-amd64
sgdisk -z /dev/sda
sgdisk -z /dev/sdb
sgdisk -n 1:0:+100M -t 1:ef00 -c 1:"EFI System" /dev/sda
sgdisk -n 2:0:0 -t 2:fd00 -c 2:"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
mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sd[ab]2
sgdisk -z /dev/md0
sgdisk -N 1 -t 1:8300 -c 1:"Linux filesystem" /dev/md0
ubiquity -b
# Just install to /dev/md0
# Once ubiquity has finished press "Continue Testing" and continue with the steps.
mount /dev/md0p1 /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
nano /etc/grub.d/10_linux
# change quick_boot and quiet_boot to 0
apt-get install -y grub-efi-amd64 mdadm
nano /etc/mdadm/mdadm.conf
# remove metadata and name
update-grub
mkdir -p /boot/efi
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment