Skip to content

Instantly share code, notes, and snippets.

@davidrothera
Last active February 13, 2018 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidrothera/3a7aa94f7479c6bd2f236aff6c17653a to your computer and use it in GitHub Desktop.
Save davidrothera/3a7aa94f7479c6bd2f236aff6c17653a to your computer and use it in GitHub Desktop.
Installing Arch linux step-by-step

Install base system

The following steps will get you the basics of Arch running. It will install a fully encrypted root partition using LUKS on LVM and then boot into a GUI environment.

Format drive

fdisk /dev/sda

Create a GPT partition table and create 1 512M EFI partition and fill the rest with Linux Filesystem

Encrypt main drive

cryptsetup luksFormat --type luks2 /dev/sda2
cryptsetup open /dev/sda2 cryptolvm

Create LVM volume group

pvcreate /dev/mapper/cryptolvm
vgcreate MyVol /dev/mapper/cryptolvm
lvcreate -L 4GB MyVol -n swap
lvcreate -l 100%FREE MyVol -n root

Format partitions

mkfs.vfat -F 32 /dev/sda1
mkfs.xfs /dev/mapper/MyVol-root
mkswap /dev/mapper/MyVol-swap

Mount partitions

mount /dev/mapper/MyVol-root /mnt
swapon /dev/mapper/MyVol-swap
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

Bootstrap Arch

pacstrap /mnt base base-devel vim git

Generate fstab

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

Jump into chroot

arch-chroot /mnt

Setup time/locale/hostname

  • Setup time ln -sf /usr/share/zoneinfo/Europe/Dublin /etc/localtime
  • Setup locale
    • Uncomment GB and US locales from /etc/locale.gen
    • Generate locale files - locale-gen
    • echo LANG=en_GB.UTF-8 > /etc/locale.conf
  • Setup hostname
    • echo drothera-vm > /etc/hostname
    • Add hostname to /etc/hosts

Set root password

passwd

Add a new user

pacman -S sudo
groupadd sudo
useradd -m -G sudo david
passwd david
# Uncomment line for sudo group inside /etc/sudoers

Install GUI

pacman -S gnome xfce4 networkmanager
systemctl enable gdm
systemctl enable NetworkManager

Install VM tools

pacman -S open-vm-tools xf86-video-vmware xf86-input-vmmouse
systemctl enable vmware-vmblock-fuse
systemctl enable vmtoolsd

Install systemd bootloader

bootctl install

Configure mkinitcpio to support encryption and LVM

  • Edit /etc/mkinitcpio.conf
...
HOOKS=(base systemd autodetect keyboard sd-vconsole modconf block sd-encrypt sd-lvm2 filesystems fsck)
...
  • Generate new files mkinitcpio -p linux

Configure systemd-boot

  • Copy examples
cp /usr/share/systemd/bootctl/loader.conf /boot/loader/
cp /usr/share/systemd/bootctl/arch.conf /boot/loader/entries/
  • Dump UUID of LVM partition into entry to use later
blkid | grep sda2 >> /boot/loader/entries/arch.conf
  • Set entry to boot from encrypted volume (in /boot/loader/entries/arch.conf)
...
options rd.luks.uuid=UUID root=/dev/mapper/MyVol-root add_efi_memmap
...

Delete output from blkid once you have used the UUID

Exit and reboot

exit
reboot

Extra steps (optional)

Install yaourt (for installing from AUR)

  • Clone yaourt and package-query
git clone https://aur.archlinux.org/package-query.git
git clone https://aur.archlinux.org/yaourt.git
  • Build and install package-query
cd package-query
makepkg -si
  • Build and install yaourt
cd ..
cd yaourt
makepkg -si

Install powerline fonts

yaourt powerline-fonts-git

Install and setup dotfiles

git clone https://github.com/svetlyak40wt/dotfiler.git .dotfiles
.dotfiles/bin/dot add https://github.com/davidrothera/dotfiles-zsh
.dotfiles/bin/dot add https://github.com/davidrothera/dotfiles-vim
.dotfiles/bin/dot update

Install neovim and vim-plug

  • Install neovim
sudo pacman -S neovim
  • Install vim-plug
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  • Install plugins
# open nvim
:PlugInstall

Install zsh and zprezto

  • Install zsh
sudo pacman -S zsh
  • Install zprezto
zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
exit
  • Set zsh as shell
chsh -s /bin/zsh
# Logout and log back in to take affect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment