LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Btrfs: Moving a large chuck of data from filesystem to subvolume (https://www.linuxquestions.org/questions/linux-software-2/btrfs-moving-a-large-chuck-of-data-from-filesystem-to-subvolume-4175519166/)

vinbob 09-17-2014 09:20 AM

Btrfs: Moving a large chuck of data from filesystem to subvolume
 
Hi,

I've recently converted an ext4 filesystem with 2.5TB of data to btrfs and I would like to have that data, now residing in the root of the filesystem (subvolid 0) in a subvolume so the subvolume can be snapshotted on a regular basis.
I'm new to using Btrfs and I'd like some opinion on the best way to move this data and I haven't found any specific info on standard practice in this situation after the usual flurry of Google searches etc.

So would it be necessary to create a subvolume and move the data from the filesystem to the subvolume? aka;

Code:

# btrfs subvolume create /mnt/subvol1
# mv /mnt/dir1 /mnt/dir2 /mnt/dir3 /mnt/subvol1/

... which will take ages.


Or is it just as valid to create a rw snapshot, delete the data above the snapshot path, and use that subvolume as my data filesystem going forward, aka;

Code:

# btrfs subvolume snapshot /mnt /mnt/subvol1
# rm -rf /mnt/dir1 /mnt/dir2 /mnt/dir3
# umount /mnt
# mount -o subvol=subvol1 /dev/sdb /mnt

... which will take no time at all.


Opinions?

Thanks in advance.

vinbob 09-18-2014 04:42 AM

Well I got some advice on the btrfs IRC and indeed there is no point doing a mv from the filesystem's root path to a subvolume. There is no issue with doing that, however on btrfs it'll take as long as it takes to move full copies of th files as if moving between two physical devices (in my situation 2.5TB).

There is also no issue with creating a snapshot subvolume and deleting the originals but after advice I ended up just creating a subvolume and reflink copies of the data in the new subvolume. This completes quickly and doesn't use any extra disk space, I could then delete the original data.

For anyone else who may be questioning how this should be done, here's what I did;

Code:

# cd /mnt  # (/mnt being my btrfs filesystem root in this example)
# btrfs subvolume create subvol1
# cp -pr --reflink=always dir1 dir2 dir3 subvol1/
# rm -rf dir1 dir2 dir3

Simple as that, then I could mount the subvolume as the default subvolume and I can begin to take regular in-line snapshots of it and any other subvolumes I choose to create.


All times are GMT -5. The time now is 09:02 PM.