Created
June 11, 2017 03:06
-
-
Save artizirk/0f3c17c004316234df8c837e520afea5 to your computer and use it in GitHub Desktop.
Arch Linux full raid1 crypted btrfs install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bash | |
set -o xtrace | |
HOSTNAME="crypto" | |
SERVER="http://172.20.20.154" | |
echo "Stupid Arch cluster installer" | |
umount -R /mnt | |
mdadm --stop /dev/md0 | |
mdadm --remove /dev/md0 | |
mdadm --zero-superblock /dev/sda1 | |
mdadm --zero-superblock /dev/sdb1 | |
cryptsetup close cryptroot1 | |
cryptsetup close cryptroot2 | |
set -e | |
echo "Partition disk" | |
lsblk | |
parted /dev/sda -s \ | |
mklabel gpt \ | |
mkpart ESP fat32 1M 128M \ | |
set 1 boot on \ | |
mkpart primary ext4 128M 100% \ | |
parted /dev/sdb -s \ | |
mklabel gpt \ | |
mkpart ESP fat32 1M 128M \ | |
set 1 boot on \ | |
mkpart primary ext4 128M 100% \ | |
lsblk | |
echo "Format disk" | |
yes | mdadm --create /dev/md0 --metadata=1.0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1 | |
mkfs.vfat -n ESP /dev/md0 | |
echo -n salakala | cryptsetup -y -v luksFormat /dev/sda2 -d - | |
echo -n salakala | cryptsetup open /dev/sda2 cryptroot1 -d - | |
echo -n salakala | cryptsetup -y -v luksFormat /dev/sdb2 -d - | |
echo -n salakala | cryptsetup open /dev/sdb2 cryptroot2 -d - | |
mkfs.btrfs -f -d raid1 -m raid1 -L ROOT /dev/mapper/cryptroot1 /dev/mapper/cryptroot2 | |
echo "Mount" | |
mount /dev/mapper/cryptroot1 /mnt | |
btrfs subvolume create /mnt/@ | |
mkdir /mnt/@/home | |
mkdir /mnt/@/boot | |
btrfs subvolume create /mnt/@home | |
umount /mnt | |
mount -o subvol=@,compress=lzo /dev/mapper/cryptroot1 /mnt | |
mount -o subvol=@home,compress=lzo /dev/mapper/cryptroot1 /mnt/home | |
mount /dev/md0 /mnt/boot | |
echo "Add local mirror" | |
curl $SERVER/mirrorlist > /etc/pacman.d/mirrorlist | |
echo "Start install" | |
pacstrap /mnt base base-devel bash-completion openssh gptfdisk htop btrfs-progs | |
echo "Genfstab" | |
genfstab -U /mnt >> /mnt/etc/fstab | |
echo "chroot" | |
arch-chroot /mnt /bin/bash << EOF | |
set -o xtrace | |
set -e | |
systemctl enable dhcpcd.service | |
systemctl enable systemd-timesyncd.service | |
systemctl enable sshd.service | |
set +e | |
rm /etc/localtime | |
set -e | |
ln -s /usr/share/zoneinfo/Europe/Tallinn /etc/localtime | |
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen | |
locale-gen | |
echo "LANG=en_US.UTF-8" >> /etc/locale.conf | |
mkdir -p /boot/EFI/Boot | |
cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi /boot/EFI/Boot/bootx64.efi | |
mkdir -p /boot/loader/entries | |
echo timeout 3 > /boot/loader/loader.conf | |
cat > /boot/loader/entries/archlinux.conf << CONFEOF | |
title Arch Linux (linux) | |
linux /vmlinuz-linux | |
initrd /initramfs-linux.img | |
options cryptdevice=/dev/sdb2:cryptroot2 | |
options cryptdevice=/dev/sda2:cryptroot1 | |
options root=/dev/mapper/cryptroot1 rw | |
options rootflags=subvol=@,noatime,compress=lzo | |
CONFEOF | |
useradd -m -G wheel -s /bin/bash arti | |
echo -e "salakala\nsalakala" | passwd arti | |
mkdir /home/arti/.ssh | |
curl https://arti.ee/keys >> /home/arti/.ssh/authorized_keys | |
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
sed -i -e 's/udev /udev encrypt /g' /etc/mkinitcpio.conf | |
mkinitcpio -p linux | |
EOF | |
echo $HOSTNAME > /mnt/etc/hostname | |
echo "INSTALL READY!" | |
echo "Press enter to reboot." | |
read | |
#reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment