My Little Corner of the Net

Moving a Multi-Volume btrfs File System to a New Machine

A few years ago, I set up a “franken-NAS” using an Atomic Pi (a single-board computer running an Intel Atom processor that was originally intended to be used in some type of robot), a USB3 hard drive “toaster,” and a couple of WD Red hard drives. When I set it up, I decided to use btrfs in a RAID 1 (mirrored) configuration for redundancy. While it wasn’t super fast, it worked for the most part, though the board has always been a bit flaky. A while back, I bought a ZimaBoard to replace it, but until now, I hadn’t gotten around to doing it. The other day, however, I noticed that I couldn’t access the Atomic Pi machine anymore.

While the Atomic Pi has on-board eMMC storage, on which I installed the OS, it is only 16Gb and not enough for everything I was trying to do. Not wanting my home directories to be stored on the NAS hard drives (though I really had no reason not to), I added a SD card to the system and mounted it as my /home partition. As all SD cards tend to do, mine failed throwing the system into an unstable state.

I decided that now was the time to switch hardware, but how? I don’t have a ton of experience with btrfs and, while I found lots of tutorials for moving data to a new physical drive, I did not find much about moving drives between machines. Fortunately it wasn’t very difficult to figure out.

Note, while the ZimaBoard has two SATA ports on bard, I am still using the toaster for the time being, as I currently have an SSD plugged into one of the on-board ports. Since the board does have a PCIe slot, I may look into adding a multiport SATA card in the future, which would likely improve speeds.

Both systems are currently running Debian Bookworm.

Debian doesn’t have btrfs support installed by default, so first I needed to install it:

sudo apt update
sudo apt install btrfs-progs

Then I was able to run this command to find the filesystem:

sudo btrfs filesystem show

The output of this command looked like this. As you can see, the ZimaBoard found both drives and understood they were both part of the same firesystem.

Label: none  uuid: 34410f56-0d5b-4a25-b699-275d578c515b
    Total devices 2 FS bytes used 668.46GiB
    devid    1 size 9.10TiB used 670.01GiB path /dev/sdb
    devid    2 size 9.10TiB used 670.01GiB path /dev/sdc

If that doesn’t work, you can try btrfs device scan --all-devices, but my system found it right away, so I didn’t need to.

Now that we know that the system was able to find the btrfs volume, I need to create a directory for the mount point and mount the volume onto it (when I first set up the Atomic Pi I chose to use /external since these were “external,” USB-connected drives, so I’m sticking with that):

sudo mkdir /external
sudo mount /dev/sdb /external

Note, you can use the device path of any of the physical devices (/dev/sdc would have worked too). You should now be able to enter that directory and see the volume’s contents:

cd /external
ls -la

To have the volume mount automatically when the system boots, edit the /etc/fstab file:

vim /etc/fstab

and add the following line to the end of it:

UUID=34410f56-0d5b-4a25-b699-275d578c515b /external      btrfs   defaults,nofail 0   2

Here I’m using the volume’s UUID instead of the device path as it’s more durable (remember to change it to match the one returned for your system when you ran btrfs filesystem show). I’m using the nofail flag so that I can disconnect the drives and still boot up the machine without any issues if I ever need to do that for debugging or fixing issues.

So now I have my NAS moved over to better hardware. Of course, I’m not out of the woods quite yet as there’s still a handful of user accounts that need to be created, there’s probably a number of software packages that need to be installed, and I need to attempt to recover what I can from the corrupted SD card. But soon, hopefully, I’ll finally be up and running on the new hardware.

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

<