From: Goffredo Baroncelli <kreijack@inwind.it>
To: Nicholas D Steeves <sten@debian.org>
Cc: "Brian J. Murrell" <brian@interlinx.bc.ca>, linux-btrfs@vger.kernel.org
Subject: Re: P.S. Re: Odd snapshot subvolume
Date: Mon, 14 Apr 2025 21:06:56 +0200 [thread overview]
Message-ID: <93a7fd2e-d667-4b9c-b2b9-dc4f05e7055d@inwind.it> (raw)
In-Reply-To: <87tt6q1tn3.fsf@navis.mail-host-address-is-not-set>
On 14/04/2025 20.32, Nicholas D Steeves wrote:
> Of course 'subvolume show' gets subvolume UUID, 'filesystem show' gets
> filesystem UUID, and this is too complicated. Yes, it's logical, once
> one understands btrfs, but multiple of my colleagues have looked at
> stuff like this, thrown up their arms, and exclaimed things to the
> effect of "I have more important things to think about".
:-)
> To encourage btrfs adoption I think we need to do better. After
> considering alternatives, I wonder if there is anything simpler/better
> than
>
> # findmnt -n -o SOURCE /foo | cut -d[ -f1
>
> to get the device suitable for mounting -o subvolid=5 | subvol=/ ? Ie:
> "Just let me see everything with as little fuss as possible. Make it
> simple!", without relying on fstab.
Below a bit simpler command options set
# findmnt -n -v -o SOURCE /foo
However I have to point out that this is not a specific BTRFS problem. See below
ghigo@venice:/tmp/test$ mkdir t
ghigo@venice:/tmp/test$ mkdir t2
ghigo@venice:/tmp/test$ truncate -s 1G disk.img
ghigo@venice:/tmp/test$ sudo losetup -f disk.img
ghigo@venice:/tmp/test$ sudo mkfs.ext4 /dev/loop0
ghigo@venice:/tmp/test$ sudo mount /dev/loop0 t/
ghigo@venice:/tmp/test$ sudo touch t/a
ghigo@venice:/tmp/test$ sudo mkdir t/b
ghigo@venice:/tmp/test$ sudo touch t/b/c
ghigo@venice:/tmp/test$ sudo mount -o X-mount.subdir=b /dev/loop0 t2
ghigo@venice:/tmp/test$ ls t2/
c
ghigo@venice:/tmp/test$ findmnt t2/
TARGET SOURCE FSTYPE OPTIONS
/tmp/test/t2 /dev/loop0[/b] ext4 rw,relatime
ghigo@venice:/tmp/test$ findmnt -n -o FSTYPE,SOURCE t2/
ext4 /dev/loop0[/b]
For *any* filesystem, it is possible to mount a subdir of a filesystem as root.
BTRFS subvolume has some special properties (e.g. it is a "barrier" for the snapshot).
However the possibility to be mounted is not one of these BTRFS special properties.
If you want to know which subvolume is mounted, you have to look to the "subvol"
option in the mount command. However even a sub directory of a subvole can be mounted
ghigo@venice:/tmp/test$ sudo mount -o X-mount.subdir=b,subvol=/subb /dev/loop1 t5
ghigo@venice:/tmp/test$ findmnt t5
TARGET SOURCE FSTYPE OPTIONS
/tmp/test/t5 /dev/loop1[/subb/b] btrfs rw,relatime,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/subb
This to say that event for the common case "findmnt -n -v -o SOURCE <path>" may be
overkilling, there are some corner case where it is needed. To understand the situation I suggest to use
ghigo@venice:/tmp/test$ findmnt -o FSTYPE,FSROOT,SOURCE -v t5
FSTYPE FSROOT SOURCE
btrfs /subb/b /dev/loop
>
> Cheers,
> Nicholas
>
Ciao
Goffredo
--
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5
next prev parent reply other threads:[~2025-04-14 19:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-14 14:34 Odd snapshot subvolume Brian J. Murrell
2025-04-14 17:04 ` Andrei Borzenkov
2025-04-14 19:11 ` Brian J. Murrell
2025-04-14 17:14 ` Nicholas D Steeves
2025-04-14 17:24 ` P.S. " Nicholas D Steeves
2025-04-14 17:54 ` Goffredo Baroncelli
2025-04-14 18:32 ` Nicholas D Steeves
2025-04-14 19:06 ` Goffredo Baroncelli [this message]
2025-04-17 21:22 ` Nicholas D Steeves
2025-04-18 16:38 ` Goffredo Baroncelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=93a7fd2e-d667-4b9c-b2b9-dc4f05e7055d@inwind.it \
--to=kreijack@inwind.it \
--cc=brian@interlinx.bc.ca \
--cc=linux-btrfs@vger.kernel.org \
--cc=sten@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox