Skip to content

Instantly share code, notes, and snippets.

@subrezon
Last active May 1, 2024 00:07
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save subrezon/9c04d10635ebbfb737816c5196c8ca24 to your computer and use it in GitHub Desktop.
Save subrezon/9c04d10635ebbfb737816c5196c8ca24 to your computer and use it in GitHub Desktop.

These instructions are based on this blogpost by Anton Semjonov and this video by Animortis Productions. Please follow the link if you want more details, they go into much more detail about each step, whereas this document is more focused on being a concise cheat sheet. Let's go.

Install base system

Boot the Ubuntu installation medium. When asked, choose the "Try Ubuntu" option and open a terminal.

Switch to root, otherwise you'll have to type sudo all the time:

sudo su -

Enable the universe repository and install required tools:

add-apt-repository universe
apt update
apt install debootstrap arch-install-scripts

Create partitions. You'll need an EFI partition and a Linux filesystem partition, swap is optional:

gdisk /dev/vda

o
n 1 (default) +512m     ef00   # EFI system partition
n 2 (default) +16g      8200   # Linux swap (optional, same size as RAM)
n 3 (default) (default) 8300   # Linux filesystem (if no swap - change partition number to 2)
w

Create the filesystems:

mkfs.vfat /dev/vda1
mkswap /dev/vda2
mkfs.btrfs /dev/vda3

Create the BTRFS subvolumes:

mount /dev/vda3 /mnt
btrfs su cr /mnt/@
btrfs su cr /mnt/@home
btrfs su cr /mnt/@root
btrfs su cr /mnt/@srv
btrfs su cr /mnt/@cache
btrfs su cr /mnt/@tmp
btrfs su cr /mnt/@log
umount /mnt

Mount the partitions/subvolumes to /mnt:

mount -o  defaults,noatime,autodefrag,compress-force=zstd:1,space_cache=v2,discard=async,subvol=@ /dev/vda3 /mnt

mkdir /mnt/{home,root,srv,var}
mkdir /mnt/var/{cache,tmp,log}

mount -o defaults,noatime,autodefrag,compress-force=zstd:1,space_cache=v2,discard=async,subvol=@home /dev/vda3 /mnt/home
mount -o defaults,noatime,autodefrag,compress-force=zstd:1,space_cache=v2,discard=async,subvol=@root /dev/vda3 /mnt/root
mount -o defaults,noatime,autodefrag,compress-force=zstd:1,space_cache=v2,discard=async,subvol=@srv /dev/vda3 /mnt/srv
mount -o defaults,noatime,autodefrag,compress-force=zstd:1,space_cache=v2,discard=async,subvol=@cache /dev/vda3 /mnt/var/cache
mount -o defaults,noatime,autodefrag,compress-force=zstd:1,space_cache=v2,discard=async,subvol=@tmp /dev/vda3 /mnt/var/tmp
mount -o defaults,noatime,autodefrag,compress-force=zstd:1,space_cache=v2,discard=async,subvol=@log /dev/vda3 /mnt/var/log

mkdir -p /mnt/boot/efi
mount -o defaults,nosuid,nodev,relatime,errors=remount-ro /dev/vda1 /mnt/boot/efi

swapon /dev/vda2

Install base system using debootstrap. Since I'm installing 22.04, use the jammy identifier. You can also specify your mirror, choose one that is faster/closer to you:

debootstrap jammy /mnt http://de.archive.ubuntu.com/ubuntu

The mirror will also be written to sources.list, so choose an actually good one. If you don't specify one, the default is the main repository located in US.

Prepare chroot environment

There are some packages I do not want to get installed. Create a file /mnt/etc/apt/preferences.d/ignored-packages:

Package: snapd cloud-init landscape-common popularity-contest ubuntu-advantage-tools
Pin: release *
Pin-Priority: -1

Edit /mnt/etc/apt/sources.list, add -security and -updates suites, as well as restricted and universe repositories:

deb http://de.archive.ubuntu.com/ubuntu jammy           main restricted universe
deb http://de.archive.ubuntu.com/ubuntu jammy-security  main restricted universe
deb http://de.archive.ubuntu.com/ubuntu jammy-updates   main restricted universe

Chroot into the installation environment:

arch-chroot /mnt

Configure the system

Update and add more necessary packages:

apt update
apt upgrade
apt install --no-install-recommends \
  linux-{,image-,headers-}generic-hwe-22.04 \
  linux-firmware initramfs-tools efibootmgr

This is also where you pick your kernel. I'm using 22.04 HWE kernel. Now install a text editor:

apt install vim

Configure your timezone, locales and keyboard layout. I use Europe/Berlin timezone, en_IE.UTF-8 and en_US.UTF-8 locales, and a standard US keyboard:

dpkg-reconfigure tzdata
dpkg-reconfigure locales
dpkg-reconfigure keyboard-configuration

Set your hostname:

echo "your-hostname" > /etc/hostname
echo "127.0.0.1 your-hostname" >> /etc/hosts

Set up users

Set your root password:

passwd

Create your sudo user and set a password for it:

useradd -mG sudo your-user
passwd your-user

Set up networking

For most single ethernet cable setups, you can just:

systemctl enable systemd-networkd

And then create a configuration in /etc/systemd/network/ethernet.network:

[Match]
Name=enp1s0

[Network]
DHCP=yes

Replace enp1s0 with your interface name, find it out using ip a.

Install other packages

You can install other useful packages that you need, here's what I install:

apt install at btrfs-progs curl dmidecode ethtool firewalld fwupd gawk git gnupg htop man \
  needrestart openssh-server patch screen software-properties-common tmux zsh zstd

After that, you can install you desktop environment:

apt install sway swayidle swaylock xdg-desktop-portal-wlr

Install a bootloader

Finally, install a bootloader of your choice. I will install GRUB:

apt install grub-efi-amd64
grub-install /dev/vda
update-grub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment