Skip to content

Instantly share code, notes, and snippets.

@lucasnlm
Last active December 23, 2019 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasnlm/a0a46c8b9b440e7aff764d82dbbbdf45 to your computer and use it in GitHub Desktop.
Save lucasnlm/a0a46c8b9b440e7aff764d82dbbbdf45 to your computer and use it in GitHub Desktop.

Arch Linux recipe

Keyboard

If the keyboard is not American layout, load the target keyboard layout by running the following command:

loadkeys br-abnt2

Internet Connection

Make sure you are connected to internet and your PC has a configured IP.

ip addr show

# or

wifi-menu

Check connection using ping google.com.

SSH Connection

It's also possible to connect to the Arch intall using SSH running:

systemctl start sshd
passwd

Then, open a new SSH connection.

Mirror list

Run following to get fastest mirrors:

pacman -Sy reflector
reflector --verbose --latest 15 --sort rate --save /etc/pacman.d/mirrorlist
# or
reflector -c Brazil --save /etc/pacman.d/mirrorlist
pacman -Syyy

Partitioning without Cryptography

fdisk -l
cfdisk /dev/nvme0n1

If your hardware supports UEFI, select gpt. Otherwise select dos.

Create the following partitions:

Partition Location Size Type
Boot /dev/nvme0n1p1 512M EFI System
/ /dev/nvme0n1p2 25G Linux Filesystem
/home /dev/nvme0n1p3 * Linux Filesystem

Check if the partitions were created:

fdisk -l /dev/nvme0n1

They can also be sda instead of nvme0n1 depending on your hardware.

Formatting and making the filesystems

Run the following commands to format the partitions:

mkfs.vfat -F32 -n EFI /dev/nvme0n1p1
mkfs.ext4 /dev/nvme0n1p2
mkfs.ext4 /dev/nvme0n1p3

And then mount them:

mount /dev/nvme0n1p2 /mnt
mkdir -p /mnt/boot/EFI
mount /dev/nvme0n1p1 /mnt/boot
mkdir /mnt/home
mount /dev/nvme0n1p3 /mnt/home
ls /mnt

Check if they are correctly mounted using:

findmnt

Partitioning with Cryptography

Before setup the partitions, load the following modules:

modprobe -a dm-mod dm-crypt

Then format the your storage.

fdisk -l
cfdisk /dev/nvme0n1

If your hardware supports UEFI, select gpt. Otherwise select dos.

Create the following partitions:

Partition Location Size Type
EFI /dev/nvme0n1p1 300M EFI System
/boot /dev/nvme0n1p2 400M Linux Filesystem
/ /dev/nvme0n1p3 * Linux LVM

Check if the partitions were created:

fdisk -l /dev/nvme0n1

They can also be sda instead of nvme0n1 depending on your hardware.

Formatting and making the filesystems

Run the following commands to format the partitions:

mkfs.vfat -F32 -n EFI /dev/nvme0n1p1
mkfs.ext4 /dev/nvme0n1p2

# crypto
cryptsetup luksFormat /dev/nvme0n1p3
cryptsetup open --type luks /dev/nvme0n1p3 lvm

# set up lvm:
pvcreate --dataalignment 1m /dev/mapper/lvm
vgcreate storage /dev/mapper/lvm
lvcreate -L 25GB storage -n lv_root
lvcreate -l 100%FREE storage -n lv_home
modprobe dm_mod
vgscan
vgchange -ay

# format
mkfs.ext4 /dev/storage/lv_root
mkfs.ext4 /dev/storage/lv_home

mount /dev/storage/lv_root /mnt
mkdir /mnt/boot
mkdir /mnt/home
mount /dev/nvme0n1p2 /mnt/boot
mount /dev/storage/lv_home /mnt/home
mkdir /mnt/boot/EFI
mount /dev/nvme0n1p1 /mnt/boot/EFI

Run vls command to make sure is everything good.

Base install

Run the following commands to install the base:

pacstrap /mnt base base-devel

Create fstab

Run the following command to generate the fstab file.

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

Make sure your fstab file has all previously created partitions.

Go to the new system

arch-chroot /mnt

Configure Linux Cryptography

Run:

pacman -S grub efibootmgr dosfstools openssh mtools linux-headers 

Edit /etc/mkinitcpio.conf and add encrypt lvm2 in between block and filesystems in HOOKS. Then:

mkinitcpio -p linux

Edit /etc/default/grub, add cryptdevice=/dev/nvme0n1p3:storage to GRUB_CMDLINE_LINUX_DEFAULT.

Sync time

Run the following command:

ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/timezone
hwclock --systohc --utc

Locale

Uncomment en_US.UTF-8 in /etc/locale.gen, then run:

locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
echo KEYMAP=us-acentos > /etc/vconsole.conf

Creating the user

Define your root user password:

passwd

And run the following command to create your user:

useradd -m -G wheel -s /bin/bash lucasnlm
ls /home/

Use the following command to set the user password if needed:

passwd lucasnlm

Install some useful programs, including sudo and add that user to sudoers:

pacman -S dosfstools os-prober mtools network-manager-applet \
          networkmanager wpa_supplicant wireless_tools dialog sudo

nano /etc/sudoers

Add lucasnlm ALL=(ALL) ALL in the and of sudoers file.

Configure localhost

Run the following commands to define your hostname:

echo lucasnlm > /etc/hostname
cat /etc/hostname

Edit and add following to /etc/hosts:

nano /etc/hosts

# Add

127.0.0.1  localhost.localdomain  localhost
::1  localhost.localdomain  localhost
127.0.1.1  lucasnlm.localdomain  lucasnlm

Install linux-zen

Run the following commands:

pacman -S linux-zen linux-zen-headers
mkinitcpio -p linux-zen
uname -r

Install Grub

Run the following commands to setup Grub using UEFI:

pacman -S grub efibootmgr
grub-install --target=x86_64-efi --bootloader-id=Arch --recheck
grub-mkconfig -o /boot/grub/grub.cfg
mkdir /boot/grub/locale
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Make sure EFI folder is inside /boot and not /boot/EFI/EFI. If that happen, move the inner EFI to /boot.

Create Swap File

To create a swap file, run the following codes:

fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment