You are not logged in.

#1 2021-12-05 15:17:57

Cvlc
Member
Registered: 2020-03-26
Posts: 295

[SOLVED] Btrfs mount options without fstab

Hi,

I would say that there isn't, but before giving up, is there anyplace that I would have missed, other than fstab, where it is possible to store mount options for btrfs subvolumes ? the idea would be to use Discoverable Partitions to simplify configuration, but I cannot find a way to set options like discard or compress any other way than fstab. I was thinking about something equivalent to the "cryptsetup --persistent" flag, or the features which can be set during mkfs :

$ mkfs.btrfs -R list-all
Runtime features available:
quota               - quota support (qgroups) (0x1, compat=3.4)
free-space-tree     - free space tree (space_cache=v2) (0x2, compat=4.5, safe=4.9, default=5.15)

$ mkfs.btrfs -O list-all
Filesystem features available:
mixed-bg            - mixed data and metadata block groups (0x4, compat=2.6.37, safe=2.6.37)
extref              - increased hardlink limit per file to 65536 (0x40, compat=3.7, safe=3.12, default=3.12)
raid56              - raid56 extended format (0x80, compat=3.9)
skinny-metadata     - reduced-size metadata extent refs (0x100, compat=3.10, safe=3.18, default=3.18)
no-holes            - no explicit hole extents for files (0x200, compat=3.14, safe=4.0, default=5.15)
raid1c34            - RAID1 with 3 or 4 copies (0x800, compat=5.5)
zoned               - support zoned devices (0x1000, compat=5.12)

Furthermore, for the time being the mount options are the same for all subvolumes, so I guess that if the root (default btrfs subvolume) is automounted with the right flags, then all others will follow. Although, (I'm realizing this as I write) root being a subvolume in my setup, I guess other subvolumes wouldn't be mounted anyway without being in fstab...

[SOLUTION]
put options in rootflags in kernel command line

Last edited by Cvlc (2021-12-16 00:29:01)

Offline

#2 2021-12-05 16:03:20

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Btrfs mount options without fstab

Use the bootloader to apply options at the kernel command line with the rootflags= parameter.


Jin, Jîyan, Azadî

Offline

#3 2021-12-05 16:14:32

Cvlc
Member
Registered: 2020-03-26
Posts: 295

Re: [SOLVED] Btrfs mount options without fstab

Wouldn't root be remounted without the options by systemd-remount-fs.service though ?

Offline

#4 2021-12-05 17:04:47

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Btrfs mount options without fstab

I think that would honour the kernel command line setting. Try it and report back.

EDIT: got curious and tried it myself by changing my rootflags=subvol=arch parameter to rootflags=subvol=arch,noatime; it is applied in the running system:

$ findmnt /
TARGET SOURCE                FSTYPE OPTIONS
/      /dev/nvme0n1p2[/arch] btrfs  rw,noatime,ssd,space_cache,subvolid=509,subvol=/arch
$

But note that noatime is utterly pointless — the performance gain is so miniscule as to be unmeasurable and my SSD will probably last longer than most spinning rust drives so there is no need to restrict writes.

Last edited by Head_on_a_Stick (2021-12-05 19:16:32)


Jin, Jîyan, Azadî

Offline

#5 2021-12-05 19:15:56

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Btrfs mount options without fstab

Cvlc wrote:

Furthermore, for the time being the mount options are the same for all subvolumes, so I guess that if the root (default btrfs subvolume) is automounted with the right flags, then all others will follow. Although, (I'm realizing this as I write) root being a subvolume in my setup, I guess other subvolumes wouldn't be mounted anyway without being in fstab...

A common misconception with btrfs is that you can have different mount options for different subvolumes. You can't.
All subvolumes on a system using btrfs inherit the mount options from either the root volume or the first volume mounted (I can't remember which).


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2021-12-14 16:46:42

Cvlc
Member
Registered: 2020-03-26
Posts: 295

Re: [SOLVED] Btrfs mount options without fstab

Hi

Just came across this by chance :
https://man.archlinux.org/man/btrfs-property.8.en

Is it a good way to set compression for the whole file system, and not needing fstab or kernel parameters ?

Offline

#7 2021-12-14 22:38:30

Cvlc
Member
Registered: 2020-03-26
Posts: 295

Re: [SOLVED] Btrfs mount options without fstab

Head_on_a_Stick wrote:

I think that would honour the kernel command line setting. Try it and report back.

EDIT: got curious and tried it myself by changing my rootflags=subvol=arch parameter to rootflags=subvol=arch,noatime; it is applied in the running system:

Strange, tried it as well (look for compress-force), but it doesn't work for me :

$ cat /etc/kernel/cmdline
root=/dev/mapper/root rootflags=subvol=@,compress-force=zstd,discard=async nowatchdog rw quiet bgrt_disable

$ sudo journalctl -b | grep "Command line"
déc. 14 23:30:20 archlinux kernel: Command line: root=/dev/mapper/root rootflags=subvol=@,compress-force=zstd,discard=async nowatchdog rw quiet bgrt_disable

$ findmnt | grep root
/                                       /dev/mapper/root[/@]                    btrfs           rw,relatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=256,subvol=/@
...

subvolumes are mounted with compress which is the setting from fstab.

Last edited by Cvlc (2021-12-14 22:39:02)

Offline

#8 2021-12-15 05:56:14

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Btrfs mount options without fstab

If you have a setting in fstab then it will over-ride the kernel command line option. I don't have /etc/fstab smile


Jin, Jîyan, Azadî

Offline

#9 2021-12-15 20:30:58

Cvlc
Member
Registered: 2020-03-26
Posts: 295

Re: [SOLVED] Btrfs mount options without fstab

Oh ok will try that then, thanks

Clearly that would be in favour of using nested layouts then

[edit ] OK that definitely works ! Thanks. I find it much "nicer" to only send the mount options once, as filling everything redundantly in fstab kind of suggests that these options could be different per subvolume, when they can't.

Why does genfstab add a line for root during install then, if it's not needed ?

Last edited by Cvlc (2021-12-15 20:48:23)

Offline

#10 2021-12-15 20:53:04

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Btrfs mount options without fstab

I think most people would prefer to set options in fstab. I think we're just weird big_smile


Jin, Jîyan, Azadî

Offline

Board footer

Powered by FluxBB