linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* help with mounting subvolumes
@ 2023-03-24 17:20 Matt Zagrabelny
  2023-03-24 17:58 ` Andrei Borzenkov
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Zagrabelny @ 2023-03-24 17:20 UTC (permalink / raw)
  To: Btrfs BTRFS

Greetings,

I do not use subvolumes (yet). I've searched the internet for some
tutorials on mounting subvolumes, but the documentation seems lacking.

So far, I've tried...

# btrfs subvolume create /foo
# mount -t btrfs -o subvol=foo,defaults,nodatacow
/dev/disk/by-uuid/5f33a159-4475-44e5-a5f8-40a23e18983a /mntfoo
mount: /mntfoo: mount(2) system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.

However /mntfoo exists:

# stat /mntfoo
  File: /mntfoo
  Size: 0               Blocks: 0          IO Block: 4096   directory
Device: 0,28    Inode: 9719644     Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-03-23 17:10:27.323613246 -0500
Modify: 2023-03-23 17:10:27.323613246 -0500
Change: 2023-03-23 17:10:27.323613246 -0500
 Birth: 2023-03-23 17:10:27.323613246 -0500

Also, dmesg does not have any additional info on the error.

Is there canonical documentation about mounting subvolumes?

What am I missing regarding subvolumes and mounting them?

Thanks for the help!

-m

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: help with mounting subvolumes
  2023-03-24 17:20 help with mounting subvolumes Matt Zagrabelny
@ 2023-03-24 17:58 ` Andrei Borzenkov
  2023-03-27 17:14   ` Matt Zagrabelny
  0 siblings, 1 reply; 3+ messages in thread
From: Andrei Borzenkov @ 2023-03-24 17:58 UTC (permalink / raw)
  To: Matt Zagrabelny, Btrfs BTRFS

On 24.03.2023 20:20, Matt Zagrabelny wrote:
> Greetings,
> 
> I do not use subvolumes (yet). I've searched the internet for some
> tutorials on mounting subvolumes, but the documentation seems lacking.
> 
> So far, I've tried...
> 
> # btrfs subvolume create /foo
> # mount -t btrfs -o subvol=foo,defaults,nodatacow
> /dev/disk/by-uuid/5f33a159-4475-44e5-a5f8-40a23e18983a /mntfoo
> mount: /mntfoo: mount(2) system call failed: No such file or directory.
>         dmesg(1) may have more information after failed mount system call.
> 
> However /mntfoo exists:
> 

It does not say "mount point does not exist".

Argument of subvol= option must be full path from the top level 
directory. You root filesystem most likely is already located in one of 
btrfs subvolumes, so subvolume foo is inside other subvolume and you 
need to provide full path.

tw:/home/bor # mount /dev/vda2 -o subvol=foo /tmp/foo
mount: /tmp/foo: mount(2) system call failed: No such file or directory.
        dmesg(1) may have more information after failed mount system call.
tw:/home/bor # mount /dev/vda2 -o subvol=/@/.snapshots/1/snapshot/foo 
/tmp/foo
tw:/home/bor #



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: help with mounting subvolumes
  2023-03-24 17:58 ` Andrei Borzenkov
@ 2023-03-27 17:14   ` Matt Zagrabelny
  0 siblings, 0 replies; 3+ messages in thread
From: Matt Zagrabelny @ 2023-03-27 17:14 UTC (permalink / raw)
  To: Andrei Borzenkov; +Cc: Btrfs BTRFS

Hello Andrei!


On Fri, Mar 24, 2023 at 12:59 PM Andrei Borzenkov <arvidjaar@gmail.com> wrote:
>
> On 24.03.2023 20:20, Matt Zagrabelny wrote:
> > Greetings,
> >
> > I do not use subvolumes (yet). I've searched the internet for some
> > tutorials on mounting subvolumes, but the documentation seems lacking.
> >
> > So far, I've tried...
> >
> > # btrfs subvolume create /foo
> > # mount -t btrfs -o subvol=foo,defaults,nodatacow
> > /dev/disk/by-uuid/5f33a159-4475-44e5-a5f8-40a23e18983a /mntfoo
> > mount: /mntfoo: mount(2) system call failed: No such file or directory.
> >         dmesg(1) may have more information after failed mount system call.
> >
> > However /mntfoo exists:
> >
>
> It does not say "mount point does not exist".
>
> Argument of subvol= option must be full path from the top level
> directory. You root filesystem most likely is already located in one of
> btrfs subvolumes, so subvolume foo is inside other subvolume and you
> need to provide full path.
>
> tw:/home/bor # mount /dev/vda2 -o subvol=foo /tmp/foo
> mount: /tmp/foo: mount(2) system call failed: No such file or directory.
>         dmesg(1) may have more information after failed mount system call.
> tw:/home/bor # mount /dev/vda2 -o subvol=/@/.snapshots/1/snapshot/foo
> /tmp/foo
> tw:/home/bor #

Thank you for the assistance. I'm learning much.

I'm still hitting an error using the "/@/.snapshots..." syntax:

root@ziti:~# cd /
root@ziti:/# lsblk -f
NAME        FSTYPE FSVER LABEL UUID
FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1
├─nvme0n1p1 vfat   FAT32       BFD8-2BC8
505.2M     1% /boot/efi
├─nvme0n1p2 btrfs              5f33a159-4475-44e5-a5f8-40a23e18983a
 66G    71% /
└─nvme0n1p3 swap   1           9800be53-1f85-47bc-bc8b-ed4592b123fd
            [SWAP]
root@ziti:/# btrfs subvolume list /
ID 256 gen 606183 top level 5 path @rootfs
root@ziti:/# btrfs subvolume create subv_content
Create subvolume './subv_content'
root@ziti:/# mkdir subv_mnt
root@ziti:/# date > subv_content/foo
root@ziti:/# btrfs subvolume list /
ID 256 gen 606187 top level 5 path @rootfs
ID 257 gen 606187 top level 256 path subv_content
root@ziti:/# mount /dev/nvme0n1p2 -o subvolid=257 /subv_mnt
root@ziti:/# ls /subv_mnt
foo
root@ziti:/# umount /subv_mnt
root@ziti:/# mount /dev/nvme0n1p2 -o
subvol=/@/.snapshots/1/snapshot/subv_content /subv_mnt
mount: /subv_mnt: mount(2) system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.
root@ziti:/#

As you can see, I can successfully mount the subvolume using the
subvolid options, but I'd like to understand how to get the subvol
option to work.

From man 5 btrfs:

subvol=<path>
  Mount subvolume from path rather than the toplevel subvolume. The
path is always treated as relative to  the
  toplevel subvolume.  This mount option overrides the default
subvolume set for the given filesystem.

I was going to ask about the "path is always treated as relative",
which seems to somewhat conflict with your recommendation of "must be
full path from the top level".

Maybe the man page could be clarified a bit?

Nevertheless, I started trying different permutations of subvolume
names and this one seemed to work:

root@ziti:/# mount /dev/nvme0n1p2 -o subvol=@rootfs/subv_content /subv_mnt
root@ziti:/#

From which "btrfs subvolume list -a /" tells me the path to use for
the mount option of subvol:

root@ziti:/# btrfs subvolume list -a /
ID 256 gen 606213 top level 5 path <FS_TREE>/@rootfs
ID 257 gen 606190 top level 256 path @rootfs/subv_content

Maybe the man page could include the above command to help noobs like
me determine the right path to use?

Anyhow, thanks again for the help!

-m

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-27 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 17:20 help with mounting subvolumes Matt Zagrabelny
2023-03-24 17:58 ` Andrei Borzenkov
2023-03-27 17:14   ` Matt Zagrabelny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).