Setup UnraidOS Virtual Machine with VirtioFS share

Setup of VirtioFS share on Linux virtual machine!

Hi everyone!

I recently started the journey to migrate everything off of UnraidOS onto a Virtual Machine running on UnraidOS to run all my containers. A home lab of my own of sorts you could say!

With docker running on UnraidOS it was easy to mount the correct directories to the containers, but when running it through the Virtual Machine there was some other things that I had to do in order to get it working.

There are a lot of posts already on using 9p as the share mode, but lots of mention with how you lose read/write performance when running on a Virtual Machine. I've seen a lot of posts about VirtioFS as being inherently faster but nothing denoting how to get it set up on a Linux machine, only Windows.

I'm assuming you have already set up your Virtual Machine and having a linux OS running. Below are the steps to mount a path from your Unraid array into the virtual machine using Virtiofs.

The first thing we are going to want to do is set up our shares in the Virtual Machine settings, I've set up 2 shares, one on my cache array as my fast "/mnt/user/vm_appdata" share and the other just a general data storage located on my array at "/mnt/user/DebianMachine001".

Once this is done, feel free to start up (or restart) your virtual machine and open up the SSH session into it. What we are going to be doing is editing the "/etc/fstab" file to automatically mount our shares.

sudo nano /etc/fstab

This will open up the fstab file, you are going to want to add the following line to the file at the end, indicating the mount tag, the directory you want it mounted to, the driver, and other parameters. I will be mounting two shares, one is the serverdata and the other appdata.

serverdata /mnt/serverdata virtiofs rw,relatime 0 0
appdata /mnt/appdata virtiofs rw,relatime 0 0

The line has the following parts

  • "serverdata" & "appdata" - This is the Unraid Mount Tag you specified earlier
  • "/mnt/serverdata" & "/mnt/appdata" - The mnt path on the virtual machine
  • "virtiofs" - Denote the driver you are using (usually 9p or virtiofs)
  • "rw" - Denote "read and write", other options are "ro" (read only), etc
  • "relatime" - A mix between options atime and noatime for r/w performance
  • you can leave the dump/pass fields set to "0"

Once you modifed /etc/fstab go ahead and save the file and exit out. You can then run the following command to mount the files and check the verbose that they were mounted correctly.

mount -av

I already have the drives mounted but it will have a message stating that they were "successfully mounted" and you should now have access to them on your Linux Virtual Machine.

ls -l /mnt

I did some file transfers for both read/write to make sure my speeds were good and I was average around 600Mb/s for all the transfers to my array. I would highly suggested using dd for any testing on the read/write on your disk.

dd if=/path/to/source/file of=/path/to/destination/file bs=1M conv=fsync status=progress

The parameters are as follows:

  • if=/path/to/source/file: specifies the input file that you want to copy.
  • of=/path/to/destination/file: specifies the output file that you want to create.
  • bs=1M: sets the block size to 1 megabyte. This determines how much data is read and written at a time.
  • conv=fsync: disables write caching by syncing the data to disk after each write. This ensures that the write speed is accurate and not affected by caching.
  • status=progress: displays the progress of the copy operation and the transfer rate.

I hope this helped you get your share setup on your UnraidOS Virtual Machine!