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
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
--
Matthias G. Eckermann Senior Product Manager SUSE® Linux Enterprise
SUSE LINUX Products GmbH Maxfeldstraße 5 90409 Nürnberg Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html