1

I want to build a file server/NAS while using btrfs to protect the data (from bitrot), but I'd like to use my existing KVM/QEMU server (debian with btrfs raid1) and create a VM for this purpose.

If I create the VM and store the data in a ext4 file system, would the btrfs checksumming on the host server detect data corruption on the VM?

--------------------
|    KVM server    |
|   btrfs - raid1  |
|   -----------    |
|   | VM-ext4 |    |
|   -----------    |
|------------------|

If the previous answer is no, would I have to create the VM with btrfs as its file system also?

In this case, to keep the "self-healing" feature of btrfs, I would have to create at least 2 virtual disks to have btrfs in raid1.

---------------------
|     KVM server    |
|    btrfs - raid1  |
|   ------------    |
|   | VM-btrfs |    |
|   | 2 x vda  |    |
|   ------------    |
|-------------------|

But this way I would be wasting a lot of space... raid1 in host server plus raid1 in VM.

Or perhaps the best solution is to implement the file server directly on the host server (although I'd prefer to keep some separation between these two roles)?

update 1
Although I have a preference for btrfs, my main question is about the usefulness of either btrfs/zfs in detecting and correcting silent corruption in VM disks. How can these file systems distinguish silent corruption from normal disk writes on the virtual disk?

update 2
After googling a bit more I could only find some more info on this question from serverfault.
According to some of the comments the virtual guest system would also be at risk unless a more complex file system was implemented (likely a raid1 guest file system inside a raid1 host file system).

So my idea now is this:

  • set up the file server on the kvm host server
  • keep the critical data secure on the file server (which is already using btrfs) and share it with the VMs via NFS
  • disable COW for the VM disk image folder
  • create kvm snapshots of the VMs and backup its configuration files to the NFS shares

Is this a reasonable solution or am I forgetting some important detail?

  • According to this article, Btrfs is not recommended for storing virtual machines. ZFS may perform better and still protect your data from silent corruption. – Deltik Feb 2 '16 at 2:34
1

I'm mostly basing on that serverfault post but I'll try to answer myself.

If I create the VM and store the data in a ext4 file system, would the btrfs checksumming on the host server detect data corruption on the VM?

No. From what I gathered there's no way the host system could detect data corruption on the VM file system.

If the previous answer is no, would I have to create the VM with btrfs as its file system also?

Yes.

Or perhaps the best solution is to implement the file server directly on the host server (although I'd prefer to keep some separation between these two roles)?

In my case the solution will be:

  • set up the file server on the kvm host server
  • keep the critical data secure on the file server (which is already using btrfs) and share it with the VMs via NFS
  • disable COW for the VM disk image folder
  • create kvm snapshots of the VMs and backup its configuration files to the NFS shares

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.