Last active
May 18, 2023 15:03
-
-
Save pvmart/d1ac1dcc651f024164afc5766a48de08 to your computer and use it in GitHub Desktop.
Install arch linux on btrfs raid1
This file contains 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
#!/bin/bash | |
set -e | |
set -o pipefail | |
dd if=/dev/zero of=/dev/sda bs=1024 count=10 | |
dd if=/dev/zero of=/dev/sdb bs=1024 count=10 | |
RAM=$(free -m | awk '/Mem:/{print $2}') | |
cat > disk.sf <<EOF | |
label: gpt | |
, 512M, 21686148-6449-6E6F-744E-656564454649 | |
; ${RAM}M, S | |
; | |
EOF | |
sfdisk /dev/sda < disk.sf | |
sfdisk /dev/sdb < disk.sf | |
# pacman -Sy btrfs-progs git | |
mkfs.btrfs -f -d raid1 -m raid1 /dev/sda3 /dev/sdb3 | |
mount /dev/sda3 /mnt | |
cd /mnt | |
btrfs subvolume snapshot . __active | |
btrfs subvolume set-default $(btrfs subvolume list /mnt | awk '{print $2}') . | |
mkdir __snapshot | |
cd __active | |
btrfs subvolume create root | |
btrfs subvolume create home | |
btrfs subvolume create var | |
mkdir /target | |
mount -o subvol=__active/root /dev/sda3 /target | |
mkdir /target/home /target/var | |
mount -o subvol=__active/home /dev/sda3 /target/home | |
mount -o subvol=__active/var /dev/sda3 /target/var | |
pacstrap /target base base-devel btrfs-progs kexec-tools grub git vim openssh \ | |
wget | |
mkdir /target/var/lib/btrfs | |
mount -o rw,relatime,space_cache,subvolid=0 /dev/sda3 /target/var/lib/btrfs | |
genfstab -U -p /target >> /target/etc/fstab | |
cat > /target/run_01.sh <<EOF | |
#!/bin/bash | |
set -e | |
set -o pipefail | |
git clone https://github.com/xtfxme/mkinitcpio-btrfs | |
cd mkinitcpio-btrfs | |
echo Y | makepkg -i | |
EOF | |
cat > /target/install.sh <<EOF | |
#!/bin/bash | |
set -e | |
set -o pipefail | |
sed -i 's/^# %wheel/%wheel/' /etc/sudoers | |
useradd -m -G wheel doc | |
echo doc:123123 | chpasswd | |
su - doc -c /run_01.sh | |
sed -i 's/fsck)/fsck btrfs)/' /etc/mkinitcpio.conf | |
mkinitcpio -p linux | |
grub-install /dev/sda | |
grub-install /dev/sdb | |
grub-mkconfig > /boot/grub/grub.cfg | |
systemctl enable dhcpcd | |
systemctl enable sshd | |
EOF | |
chmod +x /target/run_??.sh | |
chmod +x /target/install.sh | |
arch-chroot /target /install.sh | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment