Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: John Center <jlcenter15@gmail.com>
To: Hugo Mills <hugo@carfax.org.uk>, linux-btrfs@vger.kernel.org
Subject: Re: How to convert a directory to a subvolume
Date: Sun, 1 May 2022 20:02:03 -0400	[thread overview]
Message-ID: <85da8da9-54ee-f65b-e79e-bb24b7540e7c@gmail.com> (raw)
In-Reply-To: <20220430201458.GG15632@savella.carfax.org.uk>

Hi Hugo,

Thanks for responding.  I guess what I don't understand, @home is a 
subvolume, but it appears as /home when it is mounted via fstab.  It has 
a top level ID of 5.  If I create a subvolume for opt, it has a top 
level of 256.  I've tried different variations of opt, /opt, & @opt, but 
they all appear as that variation under /:

john@Mariposa:~$ sudo btrfs subvolume create /@opt
Create subvolume '//@opt'

john@Mariposa:~$ sudo btrfs subvolume list /
ID 256 gen 5968 top level 5 path @
ID 257 gen 5968 top level 5 path @home
ID 259 gen 5966 top level 256 path @opt

john@Mariposa:~$ sudo btrfs subvolume delete /@opt
Delete subvolume (no-commit): '//@opt'

john@Mariposa:~$ sudo btrfs subvolume create /opt
Create subvolume '//opt'

john@Mariposa:~$ sudo btrfs subvolume list -t /
ID    gen    top level    path
--    ---    ---------    ----
256    5993    5        @
257    5993    5        @home
260    5993    256        opt


What I'm expecting is when I do the subvolume list, I would see 
something like this:

john@Mariposa:~$ sudo btrfs subvolume list -t /
ID    gen    top level    path
--    ---    ---------    ----
256    5993    5        @
257    5993    5        @home
260    5993    5        @opt

I would also think the fstab would look something like this:

UUID=ce05e908-2dce-4368-b864-2f29650185e8 /               btrfs   
defaults,space_cache=v2,subvol=@ 0 1
#
UUID=ce05e908-2dce-4368-b864-2f29650185e8 /home btrfs   
defaults,space_cache=v2,subvol=@home 0       2
#
UUID=ce05e908-2dce-4368-b864-2f29650185e8 /opt           btrfs 
defaults,space_cache=v2,subvol=@opt 0       2

I also thought I would have to mount the subvolume like a directory.

So, what am I missing between what I'm seeing vs what I think I should 
be seeing?

Thanks for your help!

     -John


On 4/30/22 4:14 PM, Hugo Mills wrote:
> On Sat, Apr 30, 2022 at 04:08:59PM -0400, John Center wrote:
>> Hi,
>>
>> I just installed Ubuntu 22.04 with a btrfs raid1 root filesystem.  I want to convert a directory, like /opt, into a subvolume. I haven’t been having much luck.  /opt is empty right now, so it’s a good candidate for conversion.  Could someone please explain how to do it?  I’ve been at a dozen different websites, & tried different variations of the “btrfs subvolume create” command, but nothing works when I go to mount it.  I think I’m missing something simple, but not sure what it is.
>     You can't convert a directory into a subvolume.
>
>     Since the directory in question is empty, just delete it and create
> a subvol there instead:
>
> # rmdir /opt
> # btrfs sub create /opt
>
>     If there's stuff in there, you need to create the subvolume with a
> different name, copy the contents of the directory into it (optionally
> with --reflink=always) and then delete the original directory and move
> the subvolume into its place.
>
>     Hugo.
>

  reply	other threads:[~2022-05-02  0:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-30 20:08 How to convert a directory to a subvolume John Center
2022-04-30 20:14 ` Hugo Mills
2022-05-02  0:02   ` John Center [this message]
2022-05-02 13:16     ` Chris Murphy
2022-05-02 15:37       ` John Center
2022-05-02 16:15         ` Chris Murphy
2022-05-02 18:51           ` John Center
2022-05-01  5:05 ` Chris Murphy

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=85da8da9-54ee-f65b-e79e-bb24b7540e7c@gmail.com \
    --to=jlcenter15@gmail.com \
    --cc=hugo@carfax.org.uk \
    --cc=linux-btrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox