You are not logged in.

#1 2016-01-10 10:51:54

Krisbee
Member
From: Londinium
Registered: 2016-01-08
Posts: 10

Btrfs use : I need some advice/guidance

I don't know if Btrfs is a sane choice, but to get at least a basic understanding of the use of btrfs I've used Virtualbox to install Bunsenlabs with subvolumes for root and home.  Mine is a simple setup with btrfs on one device, there's no LVM or encryption layer and no RAID.  I'm hoping other btrfs users can offer some advice/feedback.

The Ubuntu installer, and its derivatives, can do this for the user automatically, the debian installer cannot.  This implies the btrfs configuration must be done post-install such as show here

http://blog.kourim.net/installing-debia … -subvolume

or here

http://forum.siduction.org/index.php?to … 6#msg35176

I came across this post which shows how using the debian installer in expert mode, and pausing to use the shell between install steps, you can install a debian base to subvolumes. 

http://debian-facile.org/doc:systeme:bt … all-subvol

Combining this with the bunsenlabs netinstall script gives a working system like this:

chris@deb-test:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=fe4d2a47-1e8a-42bc-8c00-d32d58a22d82 /             btrfs  rw,noatime,compress=zlib,autodefrag,subvol=debian/root        0       0
UUID=fe4d2a47-1e8a-42bc-8c00-d32d58a22d82 /home         btrfs  rw,noatime,compress=zlib,autodefrag,subvol=debian/home        0       0
# swap was on /dev/sda5 during installation
UUID=4d488fef-1da7-4f03-9846-06ecd79fe571 none            swap    sw              0       0
#/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
root@deb-test:/# mount /dev/sda1 /mnt
root@deb-test:/# cd /mnt
root@deb-test:/mnt# btrfs fi show
Label: none  uuid: fe4d2a47-1e8a-42bc-8c00-d32d58a22d82
        Total devices 1 FS bytes used 3.04GiB
        devid    1 size 7.62GiB used 4.62GiB path /dev/sda1

Btrfs v3.17
root@deb-test:/mnt# btrfs subvol list .
ID 257 gen 303 top level 5 path debian
ID 258 gen 359 top level 257 path debian/root
ID 259 gen 358 top level 257 path debian/home
ID 266 gen 204 top level 257 path debian/root-snap-20160107
ID 267 gen 139 top level 257 path debian/home-snap-20160107
root@deb-test:/mnt# tree -L 2 .
.                                                                                                                                                            
└── debian                                                                                                                                                   
    ├── home                                                                                                                                                 
    ├── home-snap-20160107                                                                                                                                   
    ├── root                                                                                                                                                 
    └── root-snap-20160107                                                                                                                                   
                                                                                                                                                             
5 directories, 0 files       

In this simple scheme, snapshots are not listed in the normal file system hierarchy after boot.  To create snapshots etc. you have to explicitly mount the parent of the root, or home, subvolume, e.g:

root@deb-test:/# mount -o subvol=debian /dev/sda1 /mnt
root@deb-test:/# cd /mnt
root@deb-test:/mnt# tree -L 1 .
.
├── home
├── home-snap-20160107
├── root
└── root-snap-20160107

4 directories, 0 files
root@deb-test:/mnt# btrfs subvolume snapshot home home-snap-$(date +%Y%m%d)
Create a snapshot of 'home' in './home-snap-20160110'
root@deb-test:/mnt# btrfs sub list .
ID 257 gen 392 top level 5 path debian
ID 258 gen 387 top level 257 path root
ID 259 gen 392 top level 257 path home
ID 266 gen 360 top level 257 path root-snap-20160107
ID 267 gen 360 top level 257 path home-snap-20160107
ID 269 gen 392 top level 257 path home-snap-20160110

My questions are:

1. Is this a good or bad scheme?  Are their better alternatives?
2. Is there any value in storing snapshots in a separate subvol?
3. Have you created your own scripts to automate snapshot management, or are using snapper or other tools?
4. How are you keeping track of space usage?
5. Have you used btrfs send/receive for backup, or relied on trad methods like rsync, fsarchiver etc.?
6. There's a 4.3 kernel in jessie backports, but no higher version of btrfs-tools. What kernel/tools version are you using for btrfs?

I'm not sure I'm ready to move from ext4 to btrfs, even on what would be a secondary machine. What's your advice and experiences?

Offline

#2 2016-01-10 11:07:30

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: Btrfs use : I need some advice/guidance

Each snapshot is stored in it's own subvolume anyway, see https://www.linux.com/learn/tutorials/7 … nux-part-2

Display used disk space with:

btrfs filesystem df /

https://wiki.archlinux.org/index.php/Bt … free_space

For automatic snapshots at boot, see:
https://wiki.archlinux.org/index.php/Bt … _each_boot

I would recommend using the kernel version from jessie-backports.

btrfs wiki wrote:

Due to the fast development speed, the state of development of the filesystem improves noticeably with every new Linux version, so it's recommended to run the most modern kernel possible.

https://btrfs.wiki.kernel.org/index.php/Main_Page

btrfs-tools is just used by gparted et al to manipulate the filesystem so it's not really critical.

Offline

#3 2016-01-10 11:30:03

Krisbee
Member
From: Londinium
Registered: 2016-01-08
Posts: 10

Re: Btrfs use : I need some advice/guidance

Head_on_a_Stick,

Thanks for the pointers. I'm not an archer so have more reading to do, more systemd magic to get my head round.  For some reason I thought you might need an up-to-date btrfs progs build, glad it's only a backport kernel install. Hopefully a new kernel will not break the existing btrfs.

What btrfs mount options have you ended up using for SSD and HDD?

Last edited by Krisbee (2016-01-10 11:31:47)

Offline

#4 2016-01-10 11:37:38

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: Btrfs use : I need some advice/guidance

Krisbee wrote:

What btrfs mount options have you ended up using

I go without an fstab and let systemd decide what's best 8)

root@Arch ~ # grep sda3 /proc/self/mounts
/dev/sda3 / btrfs rw,relatime,space_cache,subvolid=271,subvol=/arch 0 0

That example is on a crappy old spinning rust drive.

When on a SSD, systemd automatically adds the "ssd" & "compress=lzo" options cool

The ArchWiki has some recommendations:
https://wiki.archlinux.org/index.php/Sa … figuration

Personally, I would leave out "discard" and instead run fstrim(8) periodically.

Offline

#5 2016-01-10 12:10:34

Krisbee
Member
From: Londinium
Registered: 2016-01-08
Posts: 10

Re: Btrfs use : I need some advice/guidance

No fstab? I didn't know that was possilbe, but then systemd is taking over everything. Thanks again for the info.  P.S. Kernel update appears to have had no ill-effects on in-situ btrfs subvols, but only tested in Vbox so far.

Offline

#6 2016-01-10 12:15:24

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: Btrfs use : I need some advice/guidance

Krisbee wrote:

No fstab? I didn't know that was possilbe

Only because I use a very simple layout with everything in the root partition (apart from the EFI system partition and you have to use systemd-boot for that to work properly without an fstab).

[off topic]
One of the stated aims of the systemd development team is to have a stateless system, a system that will boot successfully even if there is no /etc directory mounted.

See http://0pointer.net/blog/projects/stateless.html
[/off topic]

Your post has reminded me to try a separate /home subvolume, actually, so thanks!
smile

Last edited by Head_on_a_Stick (2016-01-10 12:18:40)

Offline

Board footer

Powered by FluxBB