4

What is the purpose/reasoning/technical-reason why my opensuse tumbleweed system has so many folders of my filesystem "wrapped" (not sure if that's the right word) as sub volumes on btrfs?

Does it have something to do with btrfs snapshots?

Many of the entries are subdirectories of /var, and then my home directory is mapped in fstab as xfs. What is the reason for these two filesystem types? I suspect that it has something to do with the fact that btrfs can "revert" failed system updates using its snapshots, but I don't understand why not just create a tiny non-btrfs filesystem and mount it on /var?

Besides lots of /var directories, it seems /opt /src and /tmp have subvolume entries. Here is a complete unmodified factory-defaults-only fstab from my tumbleweed system.

Besides the usual SWAP and the / which is btrfs, what is surprising to me is the sheer volume of subvolumes.

UUID=fd443d26-5ded-4f57-a51e-824eec3d2199 swap swap defaults 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 / btrfs defaults 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /opt btrfs subvol=@/opt 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /srv btrfs subvol=@/srv 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /tmp btrfs subvol=@/tmp 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /usr/local btrfs subvol=@/usr/local 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/crash btrfs subvol=@/var/crash 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/lib/libvirt/images btrfs subvol=@/var/lib/libvirt/images 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/lib/mailman btrfs subvol=@/var/lib/mailman 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/lib/mariadb btrfs subvol=@/var/lib/mariadb 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/lib/mysql btrfs subvol=@/var/lib/mysql 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/lib/named btrfs subvol=@/var/lib/named 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/lib/pgsql btrfs subvol=@/var/lib/pgsql 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/log btrfs subvol=@/var/log 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/opt btrfs subvol=@/var/opt 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/spool btrfs subvol=@/var/spool 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /var/tmp btrfs subvol=@/var/tmp 0 0
UUID=7126f15f-0443-4e1d-b74e-406266534887 /.snapshots btrfs subvol=@/.snapshots 0 0
UUID=edf9aa3f-621f-40d2-9e7a-433b50673642 /home                xfs        defaults              1 2
  • Can you post more of your fstab? It's going to be hard to glean a pattern from a single line. You may run across someone who happens to know this specific thing already but you're much more likely to run into someone who can just figure it out if they can see the lines you're talking about. – Bratchley May 23 '16 at 20:37
  • okay posted entire fstab – Warren P May 24 '16 at 10:49
  • Looking at it, it's definitely about snapshots. SuSE has a benefit/liability of veering close to being over-engineered a lot of the time. You'll notice a lot of them are app roots. Meaning the intention is to allow you to revert mailman changes without it impacting your mariadb or bind installs. Another part of this is that you're apparently running several different daemons (bind, mailman, libvirt, mysql, mariadb, etc. Adding those adds about six lines to it by itself. Their install probably adds quite a few subvolumes but it appears to be longer because you also have a lot going on. – Bratchley May 24 '16 at 14:48
  • Ah I see. This makes sense. So each app root in /var is a separately revertable area of my system state. I think that makes a clearer answer than the existing one, so feel free to convert that to an answer. – Warren P May 24 '16 at 16:38
  • I found a tutorial on the usage of "snapper" tools with btfs. This shows how to restore or temporarily mount old snapshots and get some prior data back from your btrfs filesystem.... en.opensuse.org/openSUSE:Snapper_Tutorial – Warren P May 24 '16 at 20:40
2

I believe that btrfs is now the preferred filesystem if you want to allocate your whole disc (or most of it) to a filesystem. It is often (always) chosen now for root. Yes, snapshots are a big part of that. The booting system can now actually boot from a previous snapshots, and snapshots are taken automatically. It's saved me once.

The xfs filesystem is chosen for home directories only if you chose to separate it from root, and I believe it has to do with how often the files in home directories change, but I may be smoking something. It seems to be much more supported these days than ext3 or ext4. Here's an openSUSE thread on the question, with no real answer: https://forums.opensuse.org/showthread.php/501150-BTRFS-Question-gt-13-1-to-13-2

  • This is a reasonably accurate answer. I'll just suggest additionally that users can read up about "snapper" tools and manually revert parts of their filesystem using these subvolumes. It seems I installed a LOT Of extra services (it's my home PC and I'm just trying stuff) that probably don't need to stay around. – Warren P May 25 '16 at 17:58
  • Another surprising thing about BTRFS is that the output of the df utility can be wrong because it does not understand about BTRFS volume metadata, and can misreport space used. Unfortunately the BTRFS utility for space reporting only reports total volume size and amount used and requires you to do the subtraction in your head to obtain "gigabytes free" space on your drive. – Warren P Oct 17 '16 at 11:15
3

The Btrfs subvolumes excludes mainly directories with temporal files, database data etc. It reduces sizes of snapshots. Copying from the upstream documentation https://www.suse.com/documentation/sles-12/stor_admin/data/sec_filesystems_major.html openSUSE documentation is more brief, but I think it is also clear in the purpose of Btrf subvolumes https://doc.opensuse.org/documentation/leap/reference/html/book.opensuse.reference/cha.snapper.html#sec.snapper.setup

Default Subvolume Setup for the Root Partition

/boot/grub2/i386-pc,/boot/grub2/x86_64-efi, /boot/grub2/powerpc-ieee1275, /boot/grub2/s390x-emu

A rollback of the boot loader configuration is not supported. The directories listed above are architecture-specific. The first two directories are present on x86_64 machines, the latter two on IBM POWER and on IBM z Systems, respectively.

/home

If /home does not reside on a separate partition, it is excluded to avoid data loss on rollbacks.

/opt, /var/opt

Third-party products and add-ons usually get installed to /opt. It is excluded to avoid uninstalling these applications on rollbacks.

/srv

Contains data for Web and FTP servers. It is excluded to avoid data loss on rollbacks.

/tmp, /var/tmp, /var/crash

All directories containing temporary files are excluded from snapshots.

/usr/local

This directory is used when manually installing software. It is excluded to avoid uninstalling these installations on rollbacks.

/var/lib/libvirt/images

Default directory for all VM images created via libvirt. Excluded from snapshots. By default, this subvolume is created with the option no copy on write.

/var/lib/named

Contains zone data for the DNS server. Excluded from snapshots to ensure a name server can operate after a rollback.

/var/lib/mailman, /var/spool

Directories containing mail queues or mail are excluded to avoid a loss of mail after a rollback.

/var/lib/mariadb

For the MariaDB data. Excluded from snapshots. By default, this subvolume is created with the option no copy on write.

/var/lib/pgsql

Contains PostgreSQL data. Excluded from snapshots. By default, this subvolume is created with the option no copy on write.

/var/log

Log file location. Excluded from snapshots to allow log file analysis after the rollback of a broken system.

So, yes, Btrfs is the default file system for root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.