[HowTo] Install Manjaro using UEFI, systemd-boot and btrfs

Manjaro UEFI using systemd-boot and btrfs

This document is the result of reading a guide linked by @TomZ in this topic How to install Arch on btrfs with systemd boot.

The following is my notes while reading and the changes I made to the subsequent installation to fit into a Manjaro system installation.

NOTE: Before you dive into btrfs - be sure to read the entire article - including the documentation linked at the end of this document.

Overview


  • UEFI using systemd-boot
  • btrfs with subvolumes
  • Sources is listed at the end of this document

You can boot from any Manjaro ISO - open a terminal - and follow this guide.

For a similar guide but using LUKS read here

Assuming you know how to identify your disk devices and can replace the example device name /dev/sdy with the device for your system.

All commands written is assuming your are logged in as root. On Manjaro ISOs the root login is root : manjaro

General


Connect to your network and ensure your time is corret

# systemctl enable --now systemd-timesyncd

Update the mirrorlist and download databases

# pacman-mirrors -f
# pacman -Syy

Partitioning and File System Creation

Partition

Clear the disk of any existing file systems

# dd if=/dev/urandom of=/dev/sdy bs=1M count=100

Use cdisk to create the boot partition and the main partition

# cfdisk /dev/sdy
  1. boot
    • 512M
    • EFI system partition type
  2. root
    • remaining space
    • default type Linux file system

Format

Format to FAT32 for the boot and btrfs for root

# mkfs.vfat -F32 /dev/sdy1
# mkfs.btrfs /dev/sdy2

The author of the original guide has some reasonable suggestions which also matches the defaults used by Manjaro Architect.

  • / subvolume
  • /home subvolume in case a root snapshot needs to be restored
  • /var changes often so also a separate subvolume.
  • noatime and nodiratime are used to prevent a write every time a file or directory is accessed (not great for a COW filesystem like btrfs).
  • zstd is used for compression because it's fast and provides compression similar to xz.
  • Don't use discard . Issue manual trim commands with fstrim or enable the fstrim.timer.

Subvolumes

# mount /dev/sdy2 /mnt
# btrfs subvolume create /mnt/@
# btrfs subvolume create /mnt/@home
# btrfs subvolume create /mnt/@var
# umount /mnt
# mount -o subvol=@,ssd,compress=zstd,noatime,nodiratime /dev/sdy2 /mnt
# mkdir /mnt/{boot,home,var}
# mount -o subvol=@home,ssd,compress=zstd,noatime,nodiratime /dev/sdy2 /mnt/home
# mount -o subvol=@var,ssd,compress=zstd,noatime,nodiratime /dev/sdy2 /mnt/var
# mount /dev/sdy1 /mnt/boot

Installation


Install base Manjaro

# basestrap /mnt base btrfs-progs sudo manjaro-zsh-config intel-ucode networkmanager linux54 nano vim systemd-boot-manager mkinitcpio

Generate fstab and verify

# fstabgen -U /mnt >> /mnt/etc/fstab
# cat /mnt/etc/fstab

Configure system

Chroot

# manjaro-chroot /mnt /bin/zsh

Hostname

# echo manjaro > /etc/hostname

Edit /etc/hosts

# nano /etc/hosts
127.0.0.1   localhost
::1     localhost
127.0.1.1   manjaro.localdomain   manjaro

Shell

# chsh -s /bin/zsh

Timezone

Example for Denmark

# ln -sf /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime
# hwclock --systohc

Network Manager

Enable network connection

# systemctl enable NetworkManager

Enable ntp client

# systemctl enable systemd-timesyncd

Locale

Example for Danish locale

  • uncomment en_DK.UTF-8 and en_US.UTF-8
# nano /etc/locale.gen
# locale-gen

/etc/locale.conf

Locale.conf example for Denmark

# echo LANG=en_DK.UTF-8 > /etc/locale.conf

Root password

# passwd

/etc/mkinitcpio.conf

Add btrfs

HOOKS="base udev autodetect modconf block btrfs filesystems keyboard fsck"
# mkinitcpio -p linux54

systemd-boot

Setup the boot loader

# bootctl --path=/boot install

Create Manjaro entries

# sdboot-manage gen

Verify the config

Navigate to /boot/loader/entries and check the configurations sdboot-manager has created (there will be two)

  • Default
  • Fallback

Base config done

# exit
# umount -R /mnt
# reboot

Customizing


You should have a fully functioning Manjaro system. What comes next is your personal preferences. The example is a very basic vanilla Gnome desktop.

Gnome desktop

# pacman -Syu xorg-server xorg-server-common xorg-xinit xorg-drivers accountsservice gnome-keyring gnome-session gnome-shell gnome-desktop gnome-terminal gdm

Add a user and set password

# useradd -mUG lp,network,power,sys,wheel -s /bin/zsh newuser
# passwd newuser

Admin user

Add user to wheel group

# EDITOR=nano visudo

Uncomment and save

%wheel ALL=(ALL) ALL

Enable display manager

# systemctl enable gdm

Reboot

# reboot

Trouble shooting


If something went wrong and you need to get back in from the live image:

# mount -o subvol=@,ssd /dev/sdy2 /mnt
# mount -o subvol=@home,ssd /dev/sdy2 /mnt/home
# mount -o subvol=@var,ssd /dev/sdy2 /mnt/var
# mount /dev/sdy1 /mnt/boot
# manjaro-chroot /mnt /bin/zsh

btrfs resources

Credits


Sources listed in primary source

7 Likes

@anon23612428 @eugen-b

I have noticed your experience with btrfs - if you have any improvements with relation to btrfs - I will appreciate your input or direct improvements.

I am neither one of the two :slight_smile: but how about a BTRFS sub- section in the customizing section covering some BTRFS best practice?

Optional but recomended

Mount drive root for easy access to subvolumes. Add the following to /etc/fstab:

UUID=Your-drives-UUID /mnt btrfs defaults,ssd,noatime 0 2

Create Snapshot directory

mkdir /mnt/snapshots

Create initial snapshots of your root (@) and home (@home) folders

sudo btrfs subvolume snapshot -r /mnt/@ /mnt/snapshots/clean@
sudo btrfs subvolume snapshot -r /mnt/@home /mnt/snapshots/clean@home

1 Like

Good idea - my first experiences with btrfs was a couple of years ago and not a positive one - so these writings are my getting-my-feet-weet experience using the btrfs filesystem.

I have nil experience so I can't judge what is good and what is bad.

I have added @anon23612428's tips and tricks to the original topic

it depends on what you use to create snapshots
timeshift has its own way
snapper also has its different way

1 Like

I think I need to have a closer look at timeshift at some point
So far I didn't bother because creating snapshots manually is a oneliner and restores are just 4 commands or so, I am not sure what useful things it can add.

But maybe there is stuff I will really value...

i tried snapper
manual way
and
timeshift
so far only timeshift is hassle free.
i use timeshift-autosnap and grub-btrfs.
and its enough for me.

Looks like systemd-boot is not supported?

  • GRUB2 - Bootloader must be GRUB2. GRUB legacy and other bootloaders are not supported.

I think - what is not supported is the timeshift ability to restore the bootloader.

Of course I cannot know - but I don't think the bootloader part has any influence on the ability to restore the root partition itself.

My draw to timeshift is that if my system won't boot after a change, I can boot from Manjaro Live USB and use the timeshift gui to quickly get back on track. A real plus for begintermediates like myself for not having to chroot etc etc. (I like to say I know enough to know how/why I broke something, but not enough to fix it). The history is nice to see as well.

1 Like

That is correct, if your /boot is not part of the snapshot it won't make it into your snapshot and subsequent backups. If Timeshift covers that part, that is a definite plus.
I just do a manual copy of /boot to a directory inside the snapshot before I actually create a new snapshot. Not elegant but works for me.

That's correct, and that's a problem, because if you restore your root after a failed upgrade /boot will still be new while the components in / are old, hence a missmatch which may prevent you from booting.

Forum kindly sponsored by