How do I deal with BTRFS raid1 when usb disk device mappings changes?

0

I created a btrfs raid1 one by using "mkfs.btrfs /dev/sdc1 /dev/sdg1". It worked fine but next time I restarted my pc it seemed like the sdg device became sdf therefor btrfs refused to mount this raid1.

Is there a way to create this btrfs raid1 without using device mappings?

thanks

yarun can

Posted 2014-08-17T15:29:10.267

Reputation: 800

Answers

1

You will need to mount the filesystem using its UUID rather than the partition name.

To find the UUID of /dev/sdf1 use the blkid command or:

ls -l /dev/disk/by-uuid | grep sdf1

You should see that both partitions in your BTRFS RAID1 device have the same UUID. Now you can mount it like so:

mount -U uuid /mountpoint

and add it to /etc/fstab so it is mounted at boot:

UUID=uuid /mountpoint btrfs defaults 0 0

user154424

Posted 2014-08-17T15:29:10.267

Reputation: 96

It's worth noting that this is not BTRFS-specific. The problem can and does affect any filesystem, and mounting by UUID is the correct solution in all cases. – Mikkel – 2016-07-10T17:21:28.133