1

My PC has a SSD for the root filesystem and the home directory and a large HDD for other data. From time to time I sync the SSD content to the HDD in case the SSD fails. The HDD has a separate backup.

Now I consider if I can use the BTRFS RAID modes to achieve the same. So can I use subvolumes with RAID mode, such that the SSD is mostly used for reads/writes and the data is synced to the HDD?
In addition, I would like to have snapshots of the volume on the HDD.

It would be great, when this would work without manual work, even when the HDD was disconnected for some time.

Another option would probably be btrfs send/receive, but a RAID mode which writes the HDD when the IO is idle would allow for always having a recent copy of the data.

Edit: This is not a duplicate of these 1, 2, and 3 because I am explicitly asking for BTRFS, that has a storage pool concept instead of just using a block-level RAID.

1

How to use BTRFS for RAID between a SSD and a larger HDD?

You simply create a BTRFS volume using the two disks:

mkfs.btrfs -m raid1 -d raid1 /path/to/ssd /path/to/hdd

More examples at https://btrfs.wiki.kernel.org/index.php/UseCases

However, please note that RAID1 is not a backup mechanism.

So can I use subvolumes with RAID mode, such that the SSD is mostly used for reads/writes and the data is synced to the HDD?

No.

  1. BTRFS doesn't do RAID at the subvolume level;
  2. RAID1 I/O will read and write to both drives at the same time;

a RAID mode which writes the HDD when the IO is idle would allow for always having a recent copy of the data.

That is not how RAID works. See 1. above.

BTRFS does allow you to mix drives of different sizes and types so you can use your existing SSD + HDD to create a RAID1 array where your data will sit on both drives. However,

  1. You will be limited by the size of the smaller drive. You can use a calculator to find out what your available storage will be.
  2. Setting this up will be rather complex as you'll have to rebuild the entire system;

I would like to have snapshots of the volume on the HDD.

You can achieve this by creating a BTRFS volume on that HDD and enabling period snapshots. btrbk is a tool I use and can recommend.

Good luck! :)

  • 2
    This is unfortunate, because I really hoped to be able to just mirror a subvolume, so I have increased reading speed (I think RAID1 should be able to read in parallel) and hoped that writing may sync the slower disk lazy, because it happens on filesystem level in BTRFS. Without this, it is rather useless for me. When the system drive fails, I just restore it from a backup, so the speedup is the primary factor why I wanted the RAID setup. – allo Apr 14 '19 at 11:02
  • 1
    it's actually possible. See Use the speed of an SSD + two HDDs in RAID 1 – phuclv Apr 14 '19 at 12:13
  • 1
    @phuclv Thanks for the link. You are right, there are ways to use the speed of SSDs with the capacity of HDDs in a transparent way such as RAID arrays. However, the question was in the context of BTRFS which is not something currently supported. See btrfs.wiki.kernel.org/index.php/… – Alexandru Ungureanu Apr 14 '19 at 12:31
  • 1
    @AlexandruUngureanu I am not sure, if a RAID1 solution and dm_cache are equivalent. On the other hand, dm_cache might be what you would use when you want to achieve this on block-level. In addition I do not know if dm_cache allows to use the data on the SSD in case of a HDD failure. – allo Apr 15 '19 at 8:12
  • 1
    @allo limited by the size of the smaller drive -- A remedy to this is to create a single partition on the SSD and a partition of the same size on the HDD; then let btrfs use them. Use the rest of the HDD for other partition(s) with separate filesystem(s). – Kamil Maciorowski Apr 15 '19 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.