All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthias G. Eckermann" <mge@suse.com>
To: Alex <alex@bpmit.com>, linux-btrfs@vger.kernel.org
Subject: Re: Create subvolume from a directory?
Date: Wed, 28 Mar 2012 00:24:22 +0200	[thread overview]
Message-ID: <20120327222422.GA32675@suse.com> (raw)
In-Reply-To: <loom.20120327T190041-268@post.gmane.org>

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.
>=20
> Can I create/convert a existing (btrfs) directory into a
> subvolume?
>=20
> 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=20
## 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/l=
xc/installserver

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/installser=
ver/

real    0m12.917s
user    0m0.208s=20
sys     0m2.508s=20

------------------------------< 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

--=20
Matthias G. Eckermann     Senior Product Manager   SUSE=C2=AE Linux Ent=
erprise
SUSE LINUX Products GmbH  Maxfeldstra=C3=9Fe 5          90409 N=C3=BCrn=
berg Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer, HRB 16746 (AG N=C3=
=BCrnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-03-27 22:24 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 [this message]
2012-03-28  1:46   ` Fajar A. Nugraha
2012-03-28  9:20     ` David Sterba
2012-03-28  2:18   ` Liu Bo
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=20120327222422.GA32675@suse.com \
    --to=mge@suse.com \
    --cc=alex@bpmit.com \
    --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 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.