0

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?

crackpot
  • 103
  • 2
  • Im not sure why or what you want to solve with this, but remind that you can mount any path to another – djdomi Jul 15 '23 at 16:09

1 Answers1

1

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.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300