Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

How to move a BTRFS filesystem to another drive?

+1
−0

How to migrate a single device BTRFS filesystem to a new drive? I don't want to send individual subvolumes, but instead the entire filesystem with its subvolume layout intact. Changing the filesystem UUID is fine.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

1 answer

+1
−0

A convenient but a little risky method

Don't do this unless you have backups on a separate drive, and are prepared to restore from them.

Properties

Pros

  • Easy
  • Uses native BTRFS tools
  • Can be done on a live system, even if / is on this filesystem.
    • Though you will need to update mount configs, initramfs and bootloader if you intend to boot into the migrated filesystem.

Cons

  • The filesystem on the old drive will be left unusable.
  • An interruption (like powerloss) during the operation can lead to data loss.

Neutral

  • This method will leave the filesystem UUID unchanged, so you don't have to update your configs in places like /etc/fstab.

Instructions

We leverage the fact that BTRFS is a multi-drive capable filesystem. First we add the new drive to the filesystem, and then we remove the old one. BTRFS will take care of moving the data behind the scenes.

Make sure that the new drive is at least as big as the old one. Don't create a new filesystem there prior.

# btrfs device add /dev/newdrive /path/to/the/filesystem
# btrfs device remove /dev/olddrive /path/to/the/filesystem

Dodumentation

Notes

  • I speak of "drives" but this can mean any type of block device. E.g. a partition or an opened dm-crypt container.
  • This method generalizes to any number of drives. E.g. changing 2 drives from a 5 drive filesystem.
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »