Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Bob Williams <linux@barrowhillfarm.org.uk>
To: linux-btrfs@vger.kernel.org
Subject: Re: A question about subvolumes
Date: Fri, 04 Jul 2014 22:06:55 +0100	[thread overview]
Message-ID: <53B7176F.1020409@barrowhillfarm.org.uk> (raw)
In-Reply-To: <53B710C9.9020601@libero.it>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/07/14 21:38, Goffredo Baroncelli wrote:
> On 07/04/2014 04:38 PM, Bob Williams wrote:
>> I have a disc formatted as btrfs, on which is mounted /home.
>> 
>> /home/bob is a regular directory.
>> 
>> /home/bob/Documents is a btrfs subvolume
>> 
>> /home is btrfs root
>> 
>> If I do
>> 
>> # mv /home/bob /home/bob_original # btrfs subvolume create
>> /home/bob # mv /home/bob_original/* /home/bob/ # rm
>> /home/bob_original
>> 
>> will the original subvolume /home/bob/Documents survive this 
>> operation, and will it now exist as a subvolume under the new 
>> subvolume /home/bob?
> 
> Yes.
> 
> A subvolume is a way to partition a btrfs file-system. You can
> think a subvolume like a filesystem. For objects like files and
> directory a move command between *different* subvolumes is equal to
> a copy+remove. If fact is like you are moving data between
> different file-systems.
> 
> Instead moving a subvolume  in *its btrfs filesystem* is a cheap
> operation (is like moving a link); this is true even if you move a
> subvolume between different subvolumes.
> 
> To increase the speed when you move files between subvolumes (of
> the *same* btrfs filesystem), you could do a "cp --reflink" + "rm"
> instead of a "mv"; eg
> 
> # mv subvolume-A/* subvolume-B/
> 
> is equal to
> 
> # cp -rf  subvolume-A/* subvolume-B/ # rm -rf subvolume-A/*
> 
> but # cp --reflink -R  subvolume-A/* subvolume-B/ # rm -rf
> subvolume-A/
> 
> is faster  because "cp --reflink" shared the data between source
> and destination. This means that you are doing a copy (and a
> delete) of metadata only.
> 
> 
Thank you, Goffredo. As the current /home/bob is not a subvolume, but
a regular linux directory/folder, will the "cp --reflink" still carry
the same speed advantage?

In other words, using your example above, will this work:

	# cp --reflink -R normal_directory-A/* subvolume-B/
	# rm -rf normal_directory-A/


- -- 
Bob Williams
System:  Linux 3.11.10-17-desktop
Distro:  openSUSE 13.1 (x86_64) with KDE Development Platform: 4.13.2
Uptime:  06:00am up 5 days 20:14, 3 users, load average: 0.00, 0.04, 0.08
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlO3F24ACgkQ0Sr7eZJrmU5UaACfcxJObM9sEzaRIoDGBhXCsWXz
lb4An3OwTzXu/l4r/IhT1u+DbLcVPg3h
=S0Hg
-----END PGP SIGNATURE-----

  reply	other threads:[~2014-07-04 21:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04 14:38 A question about subvolumes Bob Williams
2014-07-04 20:38 ` Goffredo Baroncelli
2014-07-04 21:06   ` Bob Williams [this message]
2014-07-05  6:27     ` Goffredo Baroncelli
2014-07-05 11:43       ` Bob Williams
2014-07-05 16:06         ` Austin S Hemmelgarn
2014-07-05 23:49           ` Chris Samuel

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=53B7176F.1020409@barrowhillfarm.org.uk \
    --to=linux@barrowhillfarm.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