Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Floppe/a2f6aa463c4a9eace1aa93bf4fa8a4b3 to your computer and use it in GitHub Desktop.
Save Floppe/a2f6aa463c4a9eace1aa93bf4fa8a4b3 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 file system

We need fstab also. Identify all partitions by UUID.

blkid

Then create your fstab file.

nano /etc/fstab

Here is an example how it could be, but with different UUIDs.

# <file system>                           <mount point>   <type>  <options>  <dump>  <pass>
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /               btrfs   defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@ 0 1
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /home           btrfs   defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@home 0 2
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /root           btrfs   defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@root 0 2
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /srv            btrfs   defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@srv 0 2
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /var/cache      btrfs   defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@cache 0 2
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /var/tmp        btrfs   defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@tmp 0 2
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /var/log        btrfs   defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@log 0 2

UUID=5A33-360B                            /boot/efi       vfat    defaults,nosuid,nodev,relatime,errors=remount-ro 0 1
UUID=50aeaaa6-f1c1-40b2-8713-e261fcf26c12 none            swap    sw 0 0

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
@SupRavII
Copy link

write /etc/fstab

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>

# Root subvolume
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 / btrfs defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@ 0 1

# Home subvolume
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /home btrfs defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@home 0 2

# Root subvolume
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /root btrfs defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@root 0 2

# Service subvolume
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /srv btrfs defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@srv 0 2

# Cache subvolume
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /var/cache btrfs defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@cache 0 2

# Temporary subvolume
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /var/tmp btrfs defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@tmp 0 2

# Log subvolume
UUID=96194de7-954e-4fd3-b7f0-f6aef75bf678 /var/log btrfs defaults,noatime,compress-force=zstd:1,discard=async,space_cache=v2,autodefrag,subvol=@log 0 2

# EFI Boot partition
UUID=5A33-360B /boot/efi vfat defaults,nosuid,nodev,relatime,errors=remount-ro 0 1

# Swap partition
UUID=50aeaaa6-f1c1-40b2-8713-e261fcf26c12 none swap sw 0 0

@SupRavII
Copy link

identify UUID by parts

type blkid

/dev/sda2: UUID="50aeaaa6-f1c1-40b2-8713-e261fcf26c12" TYPE="swap" PARTLABEL="Linux swap" PARTUUID="f73f1b81-e014-46c7-853a-d0062de94d30"
/dev/sda3: UUID="96194de7-954e-4fd3-b7f0-f6aef75bf678" UUID_SUB="0b100d61-cce6-461c-ab42-97fcc303506c" BLOCK_SIZE="4096" TYPE="btrfs" PARTLABEL="Linux filesystem" PARTUUID="764de5aa-1bc5-45d5-a5de-5d651f311ad4"
/dev/sda1: UUID="5A33-360B" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="17e952e9-e2a4-4b88-b4ef-637c6d66ce6f"

@SupRavII
Copy link

After reboot

df -h

Filesystem      Size  Used Avail Use% Mounted on
tmpfs           390M  1,1M  389M   1% /run
/dev/sda3        32G  1,4G   29G   5% /
tmpfs           1,9G     0  1,9G   0% /dev/shm
tmpfs           5,0M     0  5,0M   0% /run/lock
efivarfs        256K   26K  226K  11% /sys/firmware/efi/efivars
/dev/sda3        32G  1,4G   29G   5% /home
/dev/sda1       511M  5,0M  506M   1% /boot/efi
/dev/sda3        32G  1,4G   29G   5% /root
/dev/sda3        32G  1,4G   29G   5% /srv
/dev/sda3        32G  1,4G   29G   5% /var/tmp
/dev/sda3        32G  1,4G   29G   5% /var/log
/dev/sda3        32G  1,4G   29G   5% /var/cache
tmpfs           390M     0  390M   0% /run/user/1000

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