Linux – How to rename a BTRFS subvolume

backupbtrfsfilesystemslinux

I have a BTRFS filesystem with a set of subvolumes in it. So far so good. I need to change the name of a subvolume, unfortunately the btrfs program does not allow me to rename a subvolume. Searching with Google has yielded some results, one said I can just mv, the other said I can just snapshot to a new name and delete the old subvolume. Before I crash my partition and have to reload it from the backup (it's quite large), my question is:

  • What is the currently best way to rename a subvolume?
  • Is it ok to just mv it, or will it invalidate some internal structures?
  • Is making a new snapshot and removing the old subvolume the way to go, or has this some drawbacks?

I know everything is still experimental, but for my purposes it has been working quite well (so far, and I have incremental backups for each day).

Best Answer

Just mv it. That's the recommended way in the Ubuntu community documentation.

And to further clarify why that is the right way to do it, here is a quote from the btrfs sysadmin guide:

Snapshots

A snapshot is simply a subvolume that shares its data (and metadata) with some other subvolume, using btrfs's COW capabilities. Once a [writable] snapshot is made, there is no difference in status between the original subvolume, and the new snapshot subvolume. To roll back to a snapshot, unmount the modified original subvolume, and mount the snapshot in its place. At this point, the original subvolume may be deleted if wished. Since a snapshot is a subvolume, snapshots of snapshots are also possible.

Related Question