Umm… I’ve had this on my list of things to investigate, so your question got me looking into this some.
I haven’t had success yet, but thought I would mention at a high level what I have come across…
Some people have posted solutions using 9p as a filesystem driver instead of virtiofs, but it looks like 9p is now considered old (and best I can tell hassOS doesn’t support it anyway).
Having said that, virtiofs requires a virtiofsd (daemon) running on the host as well as some sort of memory sharing that has to be enabled between guest and host (I think this is for passing file information between guest and host). I use Ubuntu QEMU/KVM, and the virtiofsd is not available until 22.0.4. My “sandbox” system is only running 20.04 so I can’t test this out. Another thing, I believe you have to tell qemu in the XML which “driver” to use so you also need a line like: <driver type='virtiofs' queue='1024'/>. The other thing I haven’t verified is whether hassOS actually supports virtio filesystem, but what playing around I’ve done, it seems to.
Thanks for your reply.
I’ve had another play with this and done a bit more reading.
It appears that the guest OS needs to have version 5.4 of the linux kernel in order to support virtiofs. It seems that HassOS only has version 5.15.
However - it looks like it has been upgraded to 6.1 (5 days ago) so it looks like it will work in the next release
Success! I just gave it a try, and functionally, it works better than I expected. The HA container can mount the filesystem too which is what I didn’t expect.
A few details…
I recently upgraded by Ubuntu Desktop to 22.04 and this contains the updates needed to run the virtiofs daemon which is needed here.
I use virt-manager to manage my VM. With the VM shutdown make the following changes:
For the VM… Memory-> tick the “Enable Shared memory”
Add New Hardware->Filesystem.
Driver: virtoifs,
Source path: <local Host directory you want to pass-thru>. Example:/home/tommy/mount4hass
Target path: myshare_label
Startup the VM
If you don’t use virt-manager, here are the relevant XML entries that virt-manager produced:
Go inside the HA container (from HAOS shell docker exec -it homeassistant /bin/bash):
Create a subdirectory under /media. I used mkdir /media/my_passthru
mount it: mount -t virtiofs myshare_label /media/my_passthru
From my Ubuntu Desktop I put a jpeg file in /home/tommy/mount4hass/my_pict.jpg
In the HA UI->Media->Local Media->my_passthru I see the my_pict.jpg file and clicking on it it does display the image.
As a note: If you are using Samba share, the /media/my_passthru/ is shown but it will not show the my_pict.jpg file under it.
To make this more permanent, you could create an entry in /etc/fstab, but my guess is this will get blown away each time you upgrade homeassistant. Instead you should be able to execute a shell command at HA startup that executes the mount command (I haven’t tried this).