Score:0

Is it possible to relocate the mount point of a btrfs subvolume within the same root?

in flag

I have created a btrfs subvolume in the path of /docker/nc/data. As shown below:

$ sudo btrfs subvolume list /
ID 256 gen 13908 top level 5 path docker
ID 257 gen 13877 top level 256 path docker/nc/data

Is it possible to move the subvolume somewhere within the subvolume docker? I.e.

/docker/nc/config/data

There are nearly 90GiB of data in it. Is it possible to be done without copying?

djdomi avatar
za flag
Im not sure why or what you want to solve with this, but remind that you can mount any path to another
Score:1
sa flag

Yes, it is possible to relocate a Btrfs subvolume within the same root without copying the data. Btrfs provides the ability to perform subvolume relocation using the Btrfs subvolume set command with the '-r' option. Here's how you can achieve it:

Ensure that you have enough free space within the target subvolume (docker) to accommodate the data from the subvolume you want to move (docker/nc/data).

Before proceeding, make sure there are no active processes accessing or modifying the subvolume you want to relocate. It's recommended to unmount the subvolume if it is currently mounted.

Open a terminal or shell and run the following command to perform the subvolume relocation:

sudo btrfs subvolume set-default <new_path> <old_path>

In your case, the command would look like this:

sudo btrfs subvolume set-default /docker/nc/config/data /docker/nc/data
  1. After executing the command, the subvolume will be relocated to the new path without copying the data. It's important to note that the process is instantaneous as it simply updates the metadata of the subvolume.

  2. Finally, you can verify the relocation by listing the subvolumes again:

sudo btrfs subvolume list /

You should see that the subvolume docker/nc/data has been relocated to the new path docker/nc/config/data while preserving the data.

Remember to update any references or configurations that rely on the old path to reflect the new path.

Please note that it is always recommended to have backups of your data before performing any modifications to your file system structure.

crackpot avatar
in flag
Thanks a ton for the detailed explanation. You are my life saver!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.