Skip to content

Instantly share code, notes, and snippets.

@lzhoucs
Last active June 6, 2022 04:20
Show Gist options
  • Save lzhoucs/17f2a37432ea80bdbbab7b8a13157d1d to your computer and use it in GitHub Desktop.
Save lzhoucs/17f2a37432ea80bdbbab7b8a13157d1d to your computer and use it in GitHub Desktop.
arch linux install note

Prepare USB drive for UEFI boot

Download arch linux ISO, extract it(note: do NOT mount it with daemon tools or any other windows image mount tools which causes file name case sensitivitiy issues) to a USB partition in FAT32 format.

Open USB Drive/loader/entries/archiso-x86_x64.conf

Update: It is not recommended to use "extract ISO" any more as it doesn't work as I tried in the latest arch ISO image. On windows, just go with Rufus with DD mode, see: https://wiki.archlinux.org/index.php/USB_flash_installation_medium#In_Windows

As it turns out, "extract ISO" works fine, just not with all drives on all computers. With my HP laptop, it doesn't seem to be detecting the SD card no matter how I prepare the drive. My conclusion is this laptop is not allowing booting from SD Card, see: https://h30434.www3.hp.com/t5/Notebooks-Archive-Read-Only/How-to-boot-from-the-SD-card-reader-Spectre-x360/td-p/5033544/page/2

Install

  • Boot from USB in UEFI modc
  • Verify boot mode is UEFI
ls /sys/firmware/efi/efivars
  • Set up wifi with wifi-menu Note: Might need to wait for a few seconds before ping google.com can be successful.

Alternatively, use iwctl. See: https://wiki.archlinux.org/index.php/Iwd

  • Update the system clock
timedatectl set-ntp true
  • Sync up packages
pacman -Sy
  • Partition
`parted -l` to list disks
`parted -a optimal /dev/nvme0n1`
`mklabel gpt`
`mkpart primary fat32 1MB 100MB`
`set 1 esp on`
`mkpart primary ext4 100MB 100%`
`print`
  • Partition - gdisk version
gdisk /dev/nvme0n1
create two partitions in prompts: ef00 and 8304
  • Partiton - cfdisk version
cfdisk /dev/nvme0n1 -z
  • Make and Format file system
`mkfs.fat -F32 /dev/nvme0n1p1`
`mkfs.ext4 /dev/nvme0n1p2`
mkswap /dev/swap_partition
  • Select a good mirror
pacman -S reflector
reflector -c "US" -f 12 -l 10 -n 12 --save /etc/pacman.d/mirrorlist
  • Set up ZFS - ZFS only
# Get ZFS module on archiso system
curl -s https://eoli3n.github.io/archzfs/init | bash

# create zpool and dataset
zpool create \
  -o ashift=12
  -O canmount=off \
  -O mountpoint=none \
  -O dnodesize=auto \
  -O atime=off \
  -O xattr=sa \
  -O compression=lz4        \
  -R /mnt rpool /dev/nvme0n1p2 or /dev/disk/by-id/id-to-partition-partx
  
zfs create -o canmount=noauto -o mountpoint=/ rpool/rootfs
zfs create rpool/rootfs/home
zfs mount rpool/rootfs
# not sure if this is necessary
zpool set bootfs=rpool/rootfs rpool

# copy zfs cache
mkdir -p  /mnt/etc/zfs
zpool set cachefile=/etc/zfs/zpool.cache rpool
cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache

# mount the externnal /boot partition as necessary
mkdir /mnt/boot
mount /dev/sdc2 /mnt/boot
  • Install essential packages
# skip for zfs. already mounted it
mount /dev/nvme0n1p2 /mnt
# zfs doesn't need external swap, see: https://wiki.archlinux.org/title/Install_Arch_Linux_on_ZFS#Partition_the_destination_drive
swapon /dev/swap_partition
# consider linux-lts* --ignore linux
pacstrap /mnt base base-devel linux linux-firmware linux-headers
  • Generate an fstab file
genfstab -U /mnt >> /mnt/etc/fstab

manually delete/comment out rpool.rootfs entry in above file because it is managed by zfs
  • Change root into the new system
arch-chroot /mnt
  • Set timezone
timedatectl set-timezone America/Chicago

Note, above approach might be out dated, official guide uses:

ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc
  • Localization

    Uncomment en_US.UTF-8 UTF-8 in /etc/locale.gen, and generate them with:

locale-gen

Then create /etc/locale.conf

echo LANG=en_US.UTF-8 > /etc/locale.conf
  • Network Config
echo myhostname > /etc/hostname

Then add the following content to /etc/hosts

127.0.0.1	localhost
::1		localhost
127.0.1.1	myhostname.localdomain myhostname

* Install additional network packages

pacman -S dhcpcd
systemctl enable dhcpcd

pacman -S iwd
systemctl enable iwctl/iwd

Note, above step is not necessary when a desktop env will be installed next

  • Install desktop env
# not necessary, gnome by default comes with nicer wayland window system instead of x11
# pacman -S xorg xorg-server

pacman -S gnome
systemctl enable gdm.service
systemctl enable NetworkManager.service
# not necessary
# systemctl start gdm.service
  • Set root password
passwd
  • Set up ZFS - ZFS only
echo -e '
[archzfs]
Server = https://archzfs.com/$repo/x86_64' >> /etc/pacman.conf

curl -O https://archzfs.com/archzfs.gpg
pacman-key -a archzfs.gpg

pacman -Sy zfs-dkms

edit /etc/mkinitcpio.conf
add zfs, remove fsck

mkinitcpio -p linux

systemctl enable zfs.target zfs-import-cache zfs-mount zfs-import.target
  • Install grub bootloader
mkdir /boot/efi
mount /dev/nvme0n1p1 /boot/efi

pacman -S grub efibootmgr

# zfs only
nano /etc/default/grub # GRUB_CMDLINE_LINUX_DEFAULT="zfs=rpool/rootfs

grub-install --bootloader-id=GRUB --efi-directory=/boot/efi
ZPOOL_VDEV_NAME_PATH=1 grub-mkconfig -o /boot/grub/grub.cfg
  • Reboot
# Back in the installer shell
exit

# zfs only

umount -R /mnt zfs umount -a zpool export -a


shutdown now
  • Entering the new OS for the first time
wifi-menu
dhclient

Useful commands

  • df -h
  • lsblk -f
  • fdisk -l and parted -l

References:

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