# Is ZFS suitable for use with virtual machines?



## spanglefox (Nov 13, 2013)

Having done a quick search in the forums I have come up with the following questions:

Has anyone used ZFS to host virtual machines? Concentrating mainly on any speed increase over UFS. (The setup involves using a 2 disk mirror).

Would it be recommended to run ZFS; particularly on a machine where a high percentage of RAM is dedicated to virtual machines?

Ideally I would test it out myself but currently do not have the available hardware to do so.

In the great oxymoronic tradition: I don't want to create a poll (as there are methods to do so here) but I do not mind if answers take that form. So if you wish to respond with a simple yes/no to save time that would still be appreciated.

Thanks in advance.


----------



## abhay4589 (Nov 13, 2013)

If by Virtual machines you mean KVM then yes. I have run it and it runs well enough although it's not native performance. If you are looking for speed gains then I doubt that somehow unless you have enough RAM to satisfy it.


----------



## spanglefox (Nov 14, 2013)

Yes, was actually looking at VirtualBox performance. Basically which is better UFS or ZFS mirror for performance?


----------



## Savagedlight (Nov 14, 2013)

This depends a lot on your particular use case, hardware, and configuration. ZFS loves memory - do you have enough to satisfy both ZFS and your VMs? How much memory can you give ZFS? How much data are we talking about? Do you have more reads or writes? Do you have easily compressible data?

Answers to these questions may shed some light on which alternative is likely to be the better performer.


----------



## abhay4589 (Nov 14, 2013)

Virtualbox in Production env, You might want to think again.
UFS is better.


----------



## kpa (Nov 14, 2013)

I don't know if it's a good idea but can you use ZVOLs as disk devices for VirtualBox guests instead of using file based virtual disks?


----------



## usdmatt (Nov 14, 2013)

> Is ZFS suitable for use with virtual machines?



Yes.

Will ZFS perform better with just a mirror? Probably not, at least if you just do straight forward performance tests, ZFS has a lot more to do for every read and write. The fact that this makes the filesystem a reasonable percentage slower that the theoretical maximum of the disks only really becomes worth it if you want the ZFS features or have enough disks to make up for it.

That's not to say ZFS isn't a great base for virtual machines, especially in more serious environments where you do have more disks/faster hardware. The fact that every block of your virtual machine's data is guaranteed consistent being the most obvious one. Another one being the ability to easily keep previous versions of the VMs with snapshots and efficiently send those copies off to a secondary pool. (Yes, A so called 'crash consistent' copy isn't perfect but generally good enough to recover from - An additional backup of any user data from inside the VM being advisable if the data is important)

It isn't completely clear-cut though. ZFS compression (which you should use - newest LZ4 preferably) may reduce the amount of disk IO required for the same operation when compared to UFS, and the aggressive caching may mean more of the VM data you access regularly comes from RAM. You'd have to test both with your virtual machines to really know.

It all comes down to whether you are willing to take a performance hit for these features, or if you're happy to run on UFS.

Partially related, but I'm still not sold on the idea of running ZFS as the filesystem inside a FreeBSD VM itself.


----------



## gkontos (Nov 14, 2013)

I don't think that it is a good idea to have both the Storage and the Hypervisor on the same box when it comes to ZFS.

VM's will require memory and ZFS will require memory so finding the right balance is not going to be easy.

Regarding performance, the more VDEV's you use the more throughput you can gain. RAID10 or stripped mirrors are the ideal candidates usually.


----------



## spanglefox (Nov 15, 2013)

Thanks one and all for your replies.

I found this forum post, finally, which is in a similar vein.

I don't think there is a clear cut way of telling which is best purely by theory. Luckily my parameters have changed a little and I can actually test. I have a third HDD that I can use and going to use one for main OS and then try out UFS mirror then ZFS mirror. Using the mirror purely for the machine disk image.



> Virtualbox in Production env, You might want to think again.


Yes, some thought was given to this as sadly the other virtualisation product I looked at just stuck two fingers up in the air and refused to work with any Virt-IO kit (KVM). Hoping bhyve might be the answer to this once it has been finished. In fairness to VirtualBox it has worked quite stably over the past two years and runs the Virt-IO. We are virtualising Microsoft Server 2008 R2 and Server 2012 R2.


----------

