0

In essence I want to have two mirror devices but also two copies of the data on each device.

Will something like this work and behave as I expect?

btrfs balance start convert=raid1,dup,soft /mnt/sdxn/

1
  • Are you really sure you want to do this? You'll be significantly reducing write performance (massively so if either or both of the drives are HDDs rather than SSDs or NVMEs. With SSD or NVME you'll suffer write amplification which is bad enough, with HDD you'll get that plus have the head seeking back and forth all the time which is even worse), and you'll also be halving the available storage yet again (halved once for mirroring, halved again for dup) so you'll have 1/4 of the storage space. You'd be better off with just a 2-drive mirror without dup, or add a 3rd drive for three-way mirror. Commented Oct 18 at 12:05

1 Answer 1

2

I am not aware of a way to do that directly (i.e. with btrfs means only) but you could use LVM to split the devices in two parts, 95:5. Then add all four devices to the filesystem, set data to RAID1 and metadata to RAID1C4.

Warning

There seems not to be a way to prevent btrfs from putting data on the small devices. And if they are full then the filesystem is "full".

So you would have to check regularly for this problem (btrfs device usage) and run btrfs balance if necessary. But even if you just write 3% of the capacity at once you may run into severe problems.

An alternative might be to have the small devices offline most of the time; then is it obviously impossible to put data on them. From time to time (while no data is being written) add them to the filesystem and run btrfs balance to update the metadata on the small devices.

6
  • You wouldn't need lvm for this, just partitioning with fdisk/gdisk/gparted/whatever will do. but however it's done, raid-1 or any other kind involving more than one partition on a drive is a really bad idea. performance will suck, storage capacity will be smaller, and it wont provide any additional protection against drive failure. it might provide some slight extra protection against random corruption (aka "bit-rot") but that is a pretty rare occurrence, not anywhere near as big a problem as some people fear. Commented Oct 18 at 12:11
  • RAID1 and a COW fs provide adequate protection again bit-rot unless you're in an environment bombarded by radiation and in that case you'd have much bigger problems to worry about. Commented Oct 18 at 12:12
  • I don't understand why you are explaining that to me... Independent of that: You are aware that what you are criticising is very close to the default configuration (DUP) of btrfs...? Commented Oct 18 at 12:15
  • 1. Yes. I'm fully aware that you don't understand and don't want to understand. You've demonstrated that on several occasions that I'm aware of. At risk of wasting even more of my time, the reason I explained it to you was because you were the one giving bad advice. You should stop doing that, it can lead people astray. 2. there are many reasons why i don't use btrfs. poor default settings is only one of the minor reasons. A much bigger reason is that it's unreliable and even now, 16 years after it was first released, still has occasional severe bugs causing loss of the entire fs. Commented Oct 18 at 12:24
  • Cute. Do everyone including yourself a favour and stop wasting your time. Refrain form "explaining" anything to me in the future. Commented Oct 18 at 12:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.