Re: Can I convert an existing directory into a subvolume?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Apr 15, 2014, at 7:10 AM, Bob Williams <linux@xxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi,
> 
> I'm new to btrfs, just dipping my toes in the water...
> 
> I've got two partitions, / on /dev/sda2 and /home on /dev/sda3, both
> formatted as btrfs in a new openSUSE 13.1 installation. I copied the
> whole of /home (4 users) into the btrfs formatted /home partition from
> an ext4 backup.
> 
> I would like to create snapshots of /home/user/Documents for example,
> but I understand these have to be subvolumes first. Googling tells me I
> can't convert a conventional subdirectory into a subvolume, so I'm
> guessing I'll have to create a new /home/user/Documents subvolume and
> then copy all the contents from the subdirectory. Correct? Then delete
> the subdirectory?

Create a new subvolume, move files into the new subvolume as if it were a directory, remove old directory, rename subvolume to the name of the deleted directory.

btrfs subvolume create /home/user1/Documentss
mv /home/user1/Documents/* /home/user1/Documentss/
rmdir /home/user1/Documents
mv /home/user1/Documentss  /home/user1/Documents

One possible gotcha is the ownership of the subvolume at creation time. If you do this as root then you need to chown after you're done; or you need to be logged in as the user who will own the Documents directory in each of the four cases. If you're using SELinux another gotcha is with copying files, which causes them to inherit the security context of the directory copied into, whereas mv preserves existing context. You can just restorecon -Rv /home/user once you're done to make sure the subvolume and its contents have the right labeling.


Chris Murphy

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux