All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Heckemann <linus@schreibt.jetzt>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-bcachefs@vger.kernel.org, dhowells@redhat.com
Subject: Re: Mounting subvolumes or subtrees
Date: Mon, 18 Sep 2023 13:08:35 +0000	[thread overview]
Message-ID: <yga1qeviq7g.fsf@localhost> (raw)
In-Reply-To: <20230822193355.d73i4pd5figg6hnm@moria.home.lan>

Kent Overstreet <kent.overstreet@linux.dev> writes:

> On Sun, Aug 20, 2023 at 07:11:06PM +0000, Linus Heckemann wrote:
>> Hi all!
>> 
>> I'd like to use bcachefs as my root filesystem -- but I don't want / to
>> be the root of the filesystem.
>> 
>> This is achievable with btrfs using subvolume mounts (passing -o
>> subvol=... or -o subvolid=... to the mount program), but having looked
>> at the way it's handled on the kernel side (duplication of code from
>> fs/super.c in fs/btrfs/super.c) I'm pretty sure that's not something
>> that should be repeated in bcachefs.
>> 
>> It can also be done by having an initramfs that mounts the root of the
>> filesystem, then bind-mounts a subpath of that and
>> switch_root/pivot_root-ing into the bind mount. However, this approach isn't
>> representable in a classic fstab -- the root of the filesystem needs to
>> be mounted somewhere, but given that I want the subtree to be /, we have
>> nowhere to mount it.
>> 
>> One idea I have -- and I haven't read enough code yet to tell whether
>> the APIs already support this -- is that the new mount API
>> (fsopen/move_mount flow) could be used as-is or extended to support
>> mounting a subtree of a filesystem without needing an intermediate mount
>> of its root. This would allow _all_ filesystems to benefit from this
>> ability, not just bcachefs -- and to represent this as a "fake mount
>> option", much like X-mount.mkdir, in util-linux, making it possible to
>> put this type of mount in an fstab.
>> 
>> I'd appreciate any opinions on whether my thoughts make sense, and how
>> else my goal might be achievable.
>
> David Howells might have some thoughts?

I had a chat with Christian Brauner at All Systems Go, and he pointed me
to https://uapi-group.org/kernel-features/ -- so this is indeed not
currently possible, but there is some agreement that it would make sense.

The relevant point on that page at the time of writing:
> Ability to mount sub-directories of regular file systems instead of
> the top-level directory. i.e. for a file system /dev/sda1 which
> contains a sub-directory /foobar mount /foobar without having to mount
> its parent directory first. Consider something like this:
>
> mount -t ext4 /dev/sda1 somedir/ -o subdir=/foobar
>
> Use-Case: systemd-homed currently mounts a sub-directory of the
> per-user LUKS volume as the user’s home directory (and not the root
> directory of the per-user LUKS volume’s file system!), and in order to
> implement this invisibly from the host side requires a complex mount
> namespace exercise.

      reply	other threads:[~2023-09-18 15:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-20 19:11 Mounting subvolumes or subtrees Linus Heckemann
2023-08-22 19:33 ` Kent Overstreet
2023-09-18 13:08   ` Linus Heckemann [this message]

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=yga1qeviq7g.fsf@localhost \
    --to=linus@schreibt.jetzt \
    --cc=dhowells@redhat.com \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcachefs@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.