Setup-Storage: how to specify multiple btrfs subvolumes?

Urs Ganse urs.ganse at helsinki.fi
Fri Jan 16 08:53:32 CET 2015


Hi Kerim,

On 15/01/15 18:26, Kerim Gueney wrote:
> Here is the promised config file. In this example I am using a single
> disk with two different partitions one containing btrfs and the other
> ext4 and with / in btrfs and /home in ext4:
>
> disk_config disk1
> primary    /home    50%    ext4    defaults
> primary    -   50%   -    -
>
> disk_config btrfs
> btrfs    raid1    /    disk1.2    noatime,subvol=@/

Ah, so that's how it works.

I had just assumed that the btrfs itself is specified like a "normal" 
filesystem partition and wrote:

primary /      10G-30G   btrfs  rw

this, of course, also worked, but simply produced a plain brtfs with the 
root in the / subvolume.
The subsequent btrfs lines then confused me. Maybe the documentation 
should mention more explicitly that btrfs should *not* be initialized as 
such, if any of the more advanced options are to be used?

> The raid1 is in this case redundant, because btrfs uses raid1 for data
> and metadata by default (irrc that's true even for single disk
> configurations, because you can always add a disk later and it kinda
> needs to know how to handle it). However, we decided to make that part
> mandatory.

By looking at the source, I found that "single" is also a valid choice here.
http://fai-project.org/doc/man/setup-storage.html only gives one btrfs 
example, and no formal description of what the btrfs lines should look like.

> Also note the "subvol=@/" , setup-storage will not create your / in the
> root of the filesystem but actually create a subvolume for it. It will
> be added to your fstab accordingly.
>
> So that's it. You first define your partitions and the "classical"
> filesystems in the "disk_config disk*" and then in disk_config btrfs
> part, you define all btrfs raids/partitions. If you want both / and
> /home in a subvolume each and each of them in their own paritions, then do:
>
> disk_config disk1
> primary    -   50%   -    -
> primary    -   50%   -    -
>
> disk_config btrfs
> btrfs    raid1    /    disk1.2    noatime,subvol=@/
> btrfs    raid1    /home    disk1.1   subvol=@/home

Ok, wonderful. All cleared up now.

One more thing: the regex matching btrfs-lines in setup-storage strictly 
matches spaces after the btrfs token. Maybe that should be changed to "\s"?

> Best regards
> Kerim

Cheers, and thanks alot,

//Urs


More information about the linux-fai mailing list