First experiment with installing on BTRFS

Hi,

I have just finished my first installation on btrfs. I should admit at the outset that I haven’t been doing much of homework on this so please bear with me. I used Gparted in the live usb and created two partitons one ESP and one / formatted as btrfs:

Model: WDC WD10 JPVX-08JC3T6 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size   File system  Name  Flags
 1      1049kB  785GB   785GB  ext4
 2      785GB   893GB   107GB  ext4
 3      893GB   1000GB  107GB  ext4


Model: SKHynix_HFS001TD9TNG-L3A0B (nvme)
Disk /dev/nvme0n1: 1024GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  106MB   105MB   fat32              boot, esp
 2      106MB   43.1GB  42.9GB  btrfs

I have seen that some users have subvolumes for home and or Timeshift snapshots. Is this something I should have created at the time of installation or is it possible to do it now? Or should I have created a separated partition only for home and then what format should I have chosen btrfs or ext4?

I’ll be grateful for any comments and suggestions. If you need some more info please tell me.

–edit–
correcting the spelling :blush:

–edit2–

 # <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=D79B-9C85                            /boot/efi      vfat    umask=0077 0 2
UUID=90793bd8-8680-45f2-88d6-05b1b9968539 /              btrfs   subvol=@,defaults,noatime,space_cache,autodefrag 0 1
UUID=90793bd8-8680-45f2-88d6-05b1b9968539 /home          btrfs   subvol=@home,defaults,noatime,space_cache,autodefrag 0 2

Learning by doing as I go :blush:
Looks like home is put already automatically on a subvolume of it’s own.

I’m curious about this as well, cause I only a BTRFS partition for my install without creating subvolumes.

1 Like

You’ve got the important bits: subvols @ and @home which timeshift depends on.

2 Likes

Breaking a volume into subvolumes is one of the most useful features of a filesystem like btrfs. You should definitely do it. The more the better in my opinion.

You can create subvolumes whenever you want. You will have to move the data and setup mounts for them in /etc/fstab.

IMO, this totally defeats the purpose of using a filesystem like btrfs in the first place. One of the big advantages of using a fs like btrfs is that you can separate volumes with there own policies and snapshots without having to separate the space on the physical disk or worry about which is filling up first.

The counterpoint to this is that if your /home is on a separate partition it makes it easier to install a different distro without erasing your /home partition. I am not really a fan of that practice to begin with though.

6 Likes

I think I am beginning to get the idea. I hope! So I could in princip create a subvolume for /usr, for /var, for /timeshift etc. and then create @usr, @var, and @timeshift entries in fstab?

How should I move the data in a directory? Via mounting them first at /mnt, copy to the subvolume and delete the source?

Yes, if that is how you wanted it laid out, you could do that.

Yes. Just be careful to not delete the data while it is still in use.

1 Like

I am truly green about this so I really don’t know what an optimal set up should look like. It is a learning project at this point but since I will be migrating to this new laptop it would be nice to get it right (somewhat) from the start.

You only need @ and @home to use the useful tools that make btrfs a good choice on a home pc: timeshift, timeshift-snapshot, grub-btrfs, and btrfs subvol commands.
But remember these snapshots will all be contained on the same drive so you should keep some other backup externally as well.

1 Like

That’s great! Thanks!

Do I have to remove the Grub, install grub-btrfs and do a grub-install afterwards?

And then is grub-btrfs capable of booting other systems which are not installed on btrfs in a mult-boot setup?

And another question (sorry!): for backups on another external medium, could I choose a partition with EXT4 or it needs to be btrfs as well?

Minimally, I like to have volumes for /var/cache/pacman and ~/.cache so I can exclude them from snapshots.

Additionally, the more volumes you create, the more flexible you can be with snapshot retention.

2 Likes

Grub-btrfs is in addition to the grub package, it doesn’t write the boot code so just install it, run

$ grub-mkconfig -o /boot/grub/grub.cfg

and reboot.
Grub-btrfs doesn’t add anything to os-prober so it will be the same as before, and grub is fine finding other OS’s with Manuels patch but it won’t find other btrfs installs (the grub patch conversations about this go back years!).

1 Like

you even can boot the live iso and create subvolumes from there. (sudo btrfs subvolume create @<your_subvol_name>). in the live environment, you can then move/copy the files/folders in the new subvolume as well (use of cp -rp is a good idea; -r for recursive so all subdirectories and files get copied; -p to preserve the rights/ownership - (edit:) or maybe even better: use rsync). I for myself use snapper instead of timeshift . Look here for suggested filesystem layout: https://wiki.archlinux.org/index.php/Snapper#Suggested_filesystem_layout (althought this is for snapper)
Here is a good topic on that matter on the arch forum: https://bbs.archlinux.org/viewtopic.php?id=194491

1 Like

I would definitely use rsync to create a fairly exact copy of the data on the other side.

2 Likes

I haven’t used timeshift with btrfs but I was wondering if it could be used to create btrfs snapshots locally and rsync snapshots on another drive. I guess it could be started twice with command-line options?

1 Like

So if I understand this correctly, I couldn’t be able to set up a a multi-boot system where all the systems are installed on btrfs and boot them via Grub?

Not with grub, it doesn’t see btrfs on other drives. One solution was to symlink / and /etc so grub would find them but that didn’t work for me so I ended up with ext4 as my 2nd drive. I don’t know if @manuel would kindly look at this? I’ve seen Ubuntu and Redhat bug reports on this for years and no-one seems to want to finish it.

1 Like

thats maybe even bettter :wink:

1 Like

Afaik it’s an one or the other with timeshift. Personally I don’t use either, because the restore options in timeshift always confused me. I create local btrfs snapshots with https://github.com/digint/btrbk and an external rsync backup with Back in Time.

2 Likes

that’s what btrfs send and btrfs receive are made for (https://wiki.archlinux.org/index.php/Btrfs#Send/receive) :slightly_smiling_face:

2 Likes

I recall seeing on another thread where @ricklinux posted about his setup. A triple system, if I remember correctly, all on btrfs and each one with it’s own ESP but then using rEFInd to boot them. This is way above my pay grade but that was what started me off at the first place to make a similar setup.