Skip to content

Instantly share code, notes, and snippets.

@codeitlikemiley
Last active December 13, 2019 15:44
Show Gist options
  • Save codeitlikemiley/c9fee568f222a469cbced5b8631e4452 to your computer and use it in GitHub Desktop.
Save codeitlikemiley/c9fee568f222a469cbced5b8631e4452 to your computer and use it in GitHub Desktop.
Bulletproof Archlinux Install

This Guide is from ARCH WIKI Bullet_Proof_Arch_Install

DRIVE=/dev/DRIVEID

sgdisk --zap-all $DRIVE

sgdisk --clear \
       --new=1:0:+550MiB --typecode=1:ef00 --change-name=1:EFI \
       --new=2:0:+8GiB   --typecode=2:8200 --change-name=2:cryptswap \
       --new=3:0:0       --typecode=2:8200 --change-name=3:cryptsystem \
         $DRIVE

mkfs.fat -F32 -n EFI /dev/disk/by-partlabel/EFI

cryptsetup luksFormat --align-payload=8192 -s 256 -c aes-xts-plain64 /dev/disk/by-partlabel/cryptsystem

cryptsetup open /dev/disk/by-partlabel/cryptsystem system

cryptsetup open --type plain --key-file /dev/urandom /dev/disk/by-partlabel/cryptswap swap

mkswap -L swap /dev/mapper/swap

swapon -L swap

mkfs.btrfs --force --label system /dev/mapper/system

o=defaults,x-mount.mkdir

o_btrfs=$o,compress=lzo,ssd,noatime

mount -t btrfs LABEL=system /mnt

btrfs subvolume create /mnt/root

btrfs subvolume create /mnt/home

btrfs subvolume create /mnt/snapshots

umount -R /mnt

mount -t btrfs -o subvol=root,$o_btrfs LABEL=system /mnt

mount -t btrfs -o subvol=home,$o_btrfs LABEL=system /mnt/home

mount -t btrfs -o subvol=snapshots,$o_btrfs LABEL=system /mnt/.snapshots

pacstrap /mnt base

genfstab -L -p /mnt >> /mnt/etc/fstab

sed -i "s+LABEL=swap+/dev/mapper/swap" /etc/fstab_labels

systemd-nspawn -bD /mnt

echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen

locale-gen

localectl set-locale LANG=en_US.UTF-8

timedatectl set-ntp 1

timedatectl set-timezone America/Los_Angeles

hostnamectl set-hostname myhostname

echo "127.0.1.1	myhostname.localdomain	myhostname" >> /etc/hosts

pacman -Syu base-devel btrfs-progs iw gptfdisk zsh vim terminus-font

Special Arch Install With BTRFS on UEFI

Requirements

  • UEFI bios
  • Bootable Usb C Arch ISO

Check if you have UEFI bios

ls /sys/firmware/efi/efivars

Connect to Internet

  • if you cant connect try to remove wifi password for the moment
wifi-menu

check if you have Internet

ping archlinux.org

Update time

timedatectl set-ntp true

set mirror list

vim /etc/pacman.d/mirrorlist -add this to /etc/pacman.d/mirrorlist generate your mirrorlist @ https://www.archlinux.org/mirrorlist/

Server = http://mirror.rise.ph/archlinux/$repo/os/$arch\

SSH to Your Laptop (THIS IS OPTIONAL but it speeds up copy pasting)

  • create a password for root
passwd
  • start sshd daemon
systemctl start sshd.service
  • we need find out what is the IP address of this laptop so we can ssh to it
ip address show
  • connect from other laptop now using ssh
ssh root@ip-address
  • Note if you failed on installation or wanna repeat the process You need to delete on your other laptop the last entry in ~/.ssh/known_host

format disk

to check disk: fdisk -l /dev/nvme0n1

to format : cfdisk /dev/nvme0n1

This is the partition distribution

/dev/nvme0n1p1 ->type = EFI System ~ at least 100mb
/dev/nvme0n1p2 ->type = Linux Filesystem ~ root at least 100GB up to 200GB
/dev/nvme0n1p3 ->type = Linux Filesystem ~ home (the rest of the partition storage)
 /dev/nvme0n1p4 ->type = Linux Swap ~ swap at least 16 GB

format disk

mkfs.vfat -F 32 -n EFI /dev/nvme0n1p1
mkfs.btrfs -L ROOT /dev/nvme0n1p2
mkfs.xfs -L HOME /dev/nvme0n1p3
mkswap -L SWAP /dev/nvme0n1p4

set BTRFS on btrfs partition

mount /dev/nvme0n1p2 /mnt
btrfs sub cr /mnt/@
btrfs sub cr /mnt/@log
btrfs sub cr /mnt/@pkg
btrfs sub cr /mnt/@snapshots

Mount BTRFS

  • very important! If You need to boot to fix some issue you need to mount the ff except swap & boot then proceed chroot
umount /mnt
mount -o relatime,space_cache=v2,compress=lzo,subvol=@ /dev/nvme0n1p2 /mnt
mkdir -p /mnt/{boot/efi,home,var/log,var/cache/pacman/pkg,btrfs}
mount -o relatime,space_cache=v2,compress=lzo,subvol=@log /dev/nvme0n1p2 /mnt/var/log
mount -o relatime,space_cache=v2,compress=lzo,subvol=@pkg /dev/nvme0n1p2 /mnt/var/cache/pacman/pkg/
mount -o relatime,space_cache=v2,compress=lzo,subvolid=5 /dev/nvme0n1p2 /mnt/btrfs
mount /dev/nvme0n1p1 /mnt/boot/efi/
mount /dev/nvme0n1p3 /mnt/home/
swapon /dev/nvme0n1p4

Check partition

df -Th

check memory and swap

free -h

Install Arch Dependencies

  • pacstrap /mnt
base 
base-devel  
vim 
linux 
linux-firmware 
btrfs-progs 
xfsprogs 
dosfstools 
intel-ucode
grub
grub efibootmgr
wpa_supplicant
dialog
iw
man-db
man-pages
textinfo

Generate FSTAB

genfstab -U /mnt >> /mnt/etc/fstab

check the file remove the line for ROOT partition

vim /mnt/etc/fstab

CHROOT to your machine

arch-chroot /mnt

Set time zone

ln -sf /usr/share/zoneinfo/Asia/Manila /etc/localtime

set hwclock

hwclock --systohc

localization

vim /etc/locale.gen

  • Uncomment en_US.UTF-8 UTF-8 and other needed locales in /etc/locale.gen

run locale-gen

EDIT locale.conf

vim /etc/locale.conf

LANG=en_US.UTF-8

set hostname to dev

vim /etc/hostname

dev

edit /etc/hosts

vim /etc/hosts

127.0.0.1	localhost
::1		localhost
127.0.1.1	dev.localdomain	dev

Init Ramfs (NOT NEEDED)

  • Creating a new initramfs is usually not required, because mkinitcpio was run on installation of the kernel package with pacstrap.

  • For LVM, system encryption or RAID, modify mkinitcpio.conf(5) and recreate the initramfs image:

create the grub folder since it is missing

cd /boot
mkdir grub

generate grub config

grub-mkconfig -o /boot/grub/grub.cfg

Install Grub Boot loader for UEFI

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub

change root pass

passwd

to avoid error on journald.conf which is harmless

vim /etc/systemd/journald.conf

  • set this to
Storage=volatile

exit on CHROOT

exit
umount -R /mnt
reboot
curl -LO larbs.xyz/larbs.sh
bash larbs.sh

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment