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

Post History

60%
+1 −0
Q&A How to move a BTRFS filesystem to another drive?

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 ...

posted 3mo ago by Iizuki‭

Answer
#1: Initial revision by user avatar Iizuki‭ · 2024-09-07T07:23:46Z (3 months ago)
# 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.

```commandline
# btrfs device add /dev/newdrive /path/to/the/filesystem
# btrfs device remove /dev/olddrive /path/to/the/filesystem
```
[Dodumentation](https://btrfs.readthedocs.io/en/latest/btrfs-device.html#typical-use-cases)

## 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.