From: Liu Bo <liubo2009@cn.fujitsu.com>
To: "Matthias G. Eckermann" <mge@suse.com>
Cc: Alex <alex@bpmit.com>, linux-btrfs@vger.kernel.org
Subject: Re: Create subvolume from a directory?
Date: Wed, 28 Mar 2012 10:18:44 +0800 [thread overview]
Message-ID: <4F727504.3070105@cn.fujitsu.com> (raw)
In-Reply-To: <20120327222422.GA32675@suse.com>
On 03/28/2012 06:24 AM, Matthias G. Eckermann wrote:
> Hello Alex and all,
>
> On 2012-03-27 T 17:19 +0000 Alex wrote:
>
>> Just a quick question but can't find an obvious answer.
>>
>> Can I create/convert a existing (btrfs) directory into a
>> subvolume?
>>
>> It would be very helpful when transferring 'partitions'
>> into btrfs. I found a similar question way back in
>> google, but that site is down now generally.
>
> As far as I am aware, this is not possible directly. My
> approach to this would be using copy with reflinks:
>
> ------------------------------< snip >------------------------------
>
> ## migrate /var/lib/lxc/installserver
> ## from directory to btrfs subvolume
>
> # du -ks /var/lib/lxc/installserver
> 500332 /var/lib/lxc/installserver
>
> # mv /var/lib/lxc/installserver /var/lib/lxc/installserver_tmp
>
> # btrfs subvol create /var/lib/lxc/installserver
> Create subvolume '/var/lib/lxc/installserver'
>
> # time cp -a --reflink /var/lib/lxc/installserver_tmp/rootfs /var/lib/lxc/installserver
>
This is too much weird.
AFAIK, clone between different subvolumes should be forbidden.
So this would get a "Invalid cross-device link", because an individual subvolume can be mounted directly.
thanks,
liubo
> real 0m1.367s
> user 0m0.148s
> sys 0m1.108s
>
> ## Now remove /var/lib/lxc/installserver_tmp (or not)
>
> ------------------------------< snap >------------------------------
>
> Just to compare this with a "mv":
>
> ------------------------------< snip >------------------------------
>
> ## Go back to former state
>
> # btrfs subvol delete /var/lib/lxc/installserver
> Delete subvolume '/var/lib/lxc/installserver'
>
> # btrfs subvol create /var/lib/lxc/installserver
> Create subvolume '/var/lib/lxc/installserver'
>
> # time mv /var/lib/lxc/installserver_tmp/rootfs /var/lib/lxc/installserver/
>
> real 0m12.917s
> user 0m0.208s
> sys 0m2.508s
>
> ------------------------------< snap >------------------------------
>
> While the time measurement might be flawed due to the subvol
> actions inbetween, caching etc.: I tried several times, and
> "cp --reflinks" always is multiple times faster than "mv" in
> my environment.
>
> Or did I misunderstand your question?
>
> so long -
> MgE
>
next prev parent reply other threads:[~2012-03-28 2:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-27 17:19 Create subvolume from a directory? Alex
2012-03-27 20:42 ` Chester
2012-03-27 22:24 ` Matthias G. Eckermann
2012-03-28 1:46 ` Fajar A. Nugraha
2012-03-28 9:20 ` David Sterba
2012-03-28 2:18 ` Liu Bo [this message]
2012-03-28 16:54 ` Goffredo Baroncelli
2012-03-29 1:24 ` Liu Bo
2012-05-01 17:09 ` Hubert Kario
2012-05-02 16:33 ` David Sterba
2012-05-03 13:26 ` Hubert Kario
2012-05-14 12:36 ` David Sterba
2012-03-28 9:24 ` David Sterba
2012-03-28 11:11 ` Alex
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=4F727504.3070105@cn.fujitsu.com \
--to=liubo2009@cn.fujitsu.com \
--cc=alex@bpmit.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=mge@suse.com \
/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.