[HowTo] Manjaro Live installation with BTRFS, Subvolume, Snapper rollout

This tutorial has the purpose to install Manjaro with BTRFS file system, automatic subvolumes and Snapper rollout.

As you know Manjaro use Calamares for install and every program must have config somewhere :slight_smile:

So, start booting with usb live, I’ve used Gnome Edition and stop to start installation, first we must open terminal:

sudo -i
nano /usr/share/calamares/modules/mount.conf

and past at the end of the file under the section “btrfsSubvolumes”, cancelling all the other entry after:

btrfsSubvolumes:
	- mountPoint: /
	  subvolume: /@
	- mountPoint: /home
	  subvolume: /@home
	- mountPoint: /root
	  subvolume: /@root
	- mountPoint: /srv
	  subvolume: /@srv      
	- mountPoint: /var/cache
	  subvolume: /@cache
	- mountPoint: /var/log
	  subvolume: /@log
	- mountPoint: /var/tmp
	  subvolume: /@tmp      
	- mountPoint: /var/lib/AccountsService
	  subvolume: /@var@lib@AccountsService
	- mountPoint: /var/lib/gdm3
	  subvolume: /@var@lib@gdm3
	- mountPoint: /.snapshots
	  subvolume: /@snapshots      

When you edit /etc/calamares/modules/mount.conf, you must be very careful to respect space and tabulation or you will receive error during installation

For better use here you may find the file with correct space and tabulation:

https://u.pcloud.link/publink/show?code=XZ5S0aVZsykifrjkVJFKlWSCeMPsBBPmALf7)

You may change add or delete subvolumes that you need

After that you may start standard installation with BTRFS file system as usual

This is my /etc/fstab:

# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=463B-45DB                            /boot/efi      vfat    umask=0077 0 2
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /              btrfs   subvol=/@,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /home          btrfs   subvol=/@home,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /root          btrfs   subvol=/@root,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /srv           btrfs   subvol=/@srv,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /var/cache     btrfs   subvol=/@cache,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /var/log       btrfs   subvol=/@log,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /var/tmp       btrfs   subvol=/@tmp,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /var/lib/AccountsService btrfs   subvol=/@var@lib@AccountsService,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /var/lib/gdm3  btrfs   subvol=/@var@lib@gdm3,defaults,discard=async,ssd 0 0
UUID=4b4d8b13-5ec8-44c3-a397-e7655d65285e /.snapshots    btrfs   subvol=/@snapshots,defaults,discard=async,ssd 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0


and this is my subvolume list:


    ~  sudo btrfs subvolume list /                                                                                                                      ✔ 
[sudo] password di robertocannito: 
ID 257 gen 766 top level 5 path @home
ID 258 gen 429 top level 5 path @root
ID 259 gen 79 top level 5 path @srv
ID 260 gen 765 top level 5 path @cache
ID 261 gen 766 top level 5 path @log
ID 262 gen 764 top level 5 path @tmp
ID 263 gen 737 top level 5 path @var@lib@AccountsService
ID 264 gen 10 top level 5 path @var@lib@gdm3
ID 265 gen 756 top level 5 path @snapshots
ID 275 gen 766 top level 5 path @
ID 302 gen 463 top level 265 path @snapshots/1/snapshot
ID 303 gen 464 top level 265 path @snapshots/2/snapshot

Soon after first boot, remove timeshift and timeshift-autosnap and reboot

Now let’s start installing:

$ sudo pacman -S snapper 
$ sudo pacman -S btrfs-assistant 
$ sudo pacman -S grub-btrfs 
$ sudo pacman -S snap-pac 
$ sudo pacman -S --needed base-devel git
$ pamac build snapper-support

We need to unmount and delete .snapshots, because must re created again later

$ sudo umount /.snapshots
$ sudo rm -rf /.snapshots

Let’s create a new root config …

$ sudo snapper -c root create-config /
$ sudo btrfs subvolume delete /.snapshots
$ sudo mkdir /.snapshots

$ sudo chown root:root /.snapshots
$ sudo chmod 750 /.snapshots

sudo mount -a

$ sudo systemctl enable --now snapper-timeline.timer
$ sudo systemctl enable --now snapper-cleanup.timer

reinstall again grub-btrfs

$ sudo pacman -S grub-btrfs

Set the location of the directory containing the grub.cfg file in /etc/default/grub-btrfs/config.

sudo nano /etc/default/grub-btrfs/config

Example: My grub.cfg is located in /efi/grub …

GRUB_BTRFS_GRUB_DIRNAME="/boot/grub"

sudo systemctl enable --now grub-btrfsd.service
sudo chmod 750 /.snapshots

sudo nano /etc/snapper/configs/root 

Place your username between the quotation marks

ALLOW_USERS="your_username_here"

Zesko suggestion:
You need to manually configure Subvol-Mapping in the config file /etc/btrfs-assistant.conf:
For example:
<Snapper config name> = "<snapshot-subvolume>, <subvolume>, <UUID>"

[Subvol-Mapping]
root = "@snapshots,@,4b4d8b13-5ec8-44c3-a397-e7655d65285e"
home = "@home-snapshot,@home,4b4d8b13-5ec8-44c3-a397-e7655d65285e"
...

It tells btrfs-assistant to find snapshots in your custom layout.

That is all, I’ve tested on my two notebooks and different virtual machine and I hope this will help you in this matter

1 Like

FYI:

If you use custom flat layout of Snapper, open btrfs-assistant → Click “Snapper” tab → Click “Browse/Restore” tab does not support it automatically.
Because it does not know what custom layout you defined and does not know where are real snapshots.

You need to manually configure Subvol-Mapping in the config file /etc/btrfs-assistant.conf:
For example:
<Snapper config name> = "<snapshot-subvolume>, <subvolume>, <UUID>"

[Subvol-Mapping]
root = "@snapshots,@,4b4d8b13-5ec8-44c3-a397-e7655d65285e"
home = "@home-snapshot,@home,4b4d8b13-5ec8-44c3-a397-e7655d65285e"
...

It tells btrfs-assistant to find snapshots in your custom layout.


It should be $ pamac build snapper-support


Change

to

$ sudo chown root:root /.snapshots
$ sudo chmod 750 /.snapshots

it is like default snapshot permission for Snapper.

Thank you Zesko, I’ve done suggested amendaments
:wink:

Following this tutorial all works good also boot snapper from grub menu.
The only question, after booting snaphot from grub, I need to launch btrfs-assistant and from there choose again the snapper and restore it and all works.

I would like to kno if there’s a solution, after booting is possible execute btrfs-assistant or snapper-tools and automatically restore it?
Sincerly I’ ve installed snapper-tools but It doesn’t show me nothing

I hope there’s a solution.

Rgs

grub-btrfs is a package completely separate from Snapper, Timeshift, etc.

It detects snapshots, and tries to boot them. Unfortunately the restore does not work when booting into these snapshots. Hopefully they will one day, because it’s not really a difficult change considering.

But when you boot the snapshot, notice what your root FS is. e.g.:

findmnt /
TARGET SOURCE                                                                         FSTYPE OPTIONS
/      /dev/disk/by-uuid/751920f1-5f97-449d-8dd2-10187991b13b[/@snapshots/27/snapshot] btrfs  rw,relatime,discard=async,space_cache=v2,subvolid=304,subvol=/@snapshots/27/snapshot

Notice how the part after the UUID is not just @ anymore.

Timeshift actually let’s you restore, and it appears to work. Which is probably even worse.

I’ve never used Snapper Tools, but I think you just have to do a manual restore. Pretty much the same steps you would use with a live boot.

1 Like

No, the Snapper tool and Btrfs-assistant do not restore automatically after booting.

If you need automatic restoration during boot, you would need to customize your initramfs tools to support this functionality. However, this requires some technical knowledge to implement.


There is limine-snapper-sync, which allows for a “one-click restore” after booting and adds a “backup” boot entry after the restore. However, it requires setup Limine and having a large ESP partition. If you have a Grub partition smaller than 300 MB, you should stick with Grub.

I answer myself to my question.
The problem was a subvolume structure.
Consider that my procedure up above written works very well, but I want improve and learn new steps working with Manjaro and Arch linux system.

pamac build snapper-tools

I’ve cancelled all my old snapshots and then:

sudo umount /.snapshots   
sudo rmdir /.snapshots
sudo btrfs subvolume create /.snapshots

removed from /etc/fstab snapshots voice:

#UUID=62d842ab-b152-425b-a839-966415d89365 /.snapshots    btrfs   subvol=/@snapshots,defaults,discard=async,ssd,noatime,compress=zstd 0 0

deleted old subvolume @shapshots

sudo mount -a or reboot
sudo chown root:root /.snapshots

sudo chmod 750 /.snapshots

Now if I must restore a snapshot from grub menu, after booting automatically calls snapper-tools and invite me to reboot system.

I’ve made different test and all works good

Rgs

…that you created and can edit anytime… :wink:

If you need help to improve it, feel free to create a Support topic and reference it.

Subvolume list looks fine, but doesn’t tell a lot. What is your root FS exactly? After booting this restore, what is the output of findmnt / and your contents of grub.cfg?

sudo grep -A9 MANJARO -m2 /boot/grub/grub.cfg (Should be enough?)

Just the (by default): menuentry 'Manjaro Linux.. section you’re booting.

Kind of curious myself.

This is why the Snapper tool and similar tools don’t automatically support custom Snapper layouts, as I already mentioned above 11 months ago.
Some tools may require manual configuration to locate your custom snapshot paths. Some other tools do not have this feature.

That being said, I recommend that beginners stick with the default Snapper layout, as many tools work well with it without needing custom configuration.

Hi, here I’ve

 findmnt /                                                                                                                    ✔ 
TARGET SOURCE        FSTYPE OPTIONS
/      /dev/sda2[/@] btrfs  rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@

sudo grep -A9 MANJARO -m2 /boot/grub/grub.cfg                                                                                ✔ 
[sudo] password di robertocannito: 
	menuentry 'Manjaro Linux (Kernel: 6.10.6-10-MANJARO x64)' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.10.6-10-MANJARO x64-advanced-62d842ab-b152-425b-a839-966415d89365' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0,gpt2'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  62d842ab-b152-425b-a839-966415d89365
		else
--
	menuentry 'Manjaro Linux (Kernel: 6.10.6-10-MANJARO x64 - fallback initramfs)' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.10.6-10-MANJARO x64-fallback-62d842ab-b152-425b-a839-966415d89365' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0,gpt2'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  62d842ab-b152-425b-a839-966415d89365
		else