So I had a chance to test this with multiple shares and I have to say this is an incredible speed improvement with Rust virtiofs. @SimonF this should really be implemented in 6.13.
Here is what I did.
First I created a directory on my flash:
/boot/virtiofsd
In the directory I placed the rust version of virtiofsd and a shell script for each share I want to mount. In my case I have:
appdata.sh
archives.sh
backup.sh
communityapplicationsappdatabackup.sh
downloads.sh
movies.sh
music.sh
software.sh
Note: Make these scripts using nano on the server. They must be formatted for UNIX. Making them in Notepad or Notepad++ on Windows will format them MSDOS and Virtiofs will die when booting the vm.
Each shell script is exactly what @jch shared but modified for each individual share I want to mount in Windows. I modified the script to store virtiofsd in /usr/libexec:
Here is an example for my Music share, all of the other shares are the same:
#!/bin/bash
# process -o option but ignore it because unraid generates the command for us
VALID_ARGS=$(getopt -o o -l fd: -- "$@")i
if [[ $? -ne 0 ]]; then
exit 1;
fi
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
--fd )
FD="$2"
shift 2
;;
-o )
shift 1
;;
-- )
shift;
break
;;
* )
shift;
;;
esac
done
# https://gitlab.com/virtio-fs/virtiofsd
/usr/libexec/virtiofsd \
--fd="$FD" \
--shared-dir="/mnt/user/Music" \
--xattr \
--cache="never" \
--sandbox="chroot" \
--inode-file-handles="mandatory" \
--announce-submounts
Change --shared-dir= and rinse and repeat for each individual share with a new shell script.
Next I modified my go file /boot/config/go
#replace Virtiofsd with Rust version
mv /usr/libexec/virtiofsd /usr/libexec/virtiofsd.old
cp /boot/virtiofsd/virtiofsd /usr/libexec/virtiofsd
chmod +x /usr/libexec/virtiofsd
#copy mount scripts for each virtofs share
#appdata
cp /boot/virtiofsd/appdata.sh /usr/libexec/appdata.sh
chmod +x /usr/libexec/appdata.sh
#archives
cp /boot/virtiofsd/archives.sh /usr/libexec/archives.sh
chmod +x /usr/libexec/archives.sh
#backup
cp /boot/virtiofsd/backup.sh /usr/libexec/backup.sh
chmod +x /usr/libexec/backup.sh
#communityapplicationsappdatabackup
cp /boot/virtiofsd/communityapplicationsappdatabackup.sh /usr/libexec/communityapplicationsappdatabackup.sh
chmod +x /usr/libexec/communityapplicationsappdatabackup.sh
#downloads
cp /boot/virtiofsd/downloads.sh /usr/libexec/downloads.sh
chmod +x /usr/libexec/downloads.sh
#movies
cp /boot/virtiofsd/movies.sh /usr/libexec/movies.sh
chmod +x /usr/libexec/movies.sh
#music
cp /boot/virtiofsd/music.sh /usr/libexec/music.sh
chmod +x /usr/libexec/music.sh
#software
cp /boot/virtiofsd/software.sh /usr/libexec/software.sh
chmod +x /usr/libexec/software.sh
#tv
cp /boot/virtiofsd/tv.sh /usr/libexec/tv.sh
chmod +x /usr/libexec/tv.sh
I appended the following to the go file so this is persistent upon boot. This renames the original virtiofsd to virtiofsd.old, copies the rust version to /usr/libexec and then copies each of my mount scripts to /usr/libexec and makes them executable.
Now for the xml, this part is easy. For each mount, replace
<binary path='/usr/libexec/virtiofsd' xattr='on'>
with
<binary path='/usr/libexec/script.sh' xattr='on'>
This is what my finished XML looks like for my environment:
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/appdata.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/appdata'/>
<target dir='appdata'/>
<alias name='fs0'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/archives.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/Archives'/>
<target dir='Archives'/>
<alias name='fs1'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/backup.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/Backup'/>
<target dir='Backup'/>
<alias name='fs2'/>
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/communityapplicationsappdatabackup.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/CommunityApplicationsAppdataBackup'/>
<target dir='CommunityApplicationsAppdataBackup'/>
<alias name='fs3'/>
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/downloads.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/Downloads'/>
<target dir='Downloads'/>
<alias name='fs4'/>
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/movies.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/Movies'/>
<target dir='Movies'/>
<alias name='fs5'/>
<address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/music.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/Music'/>
<target dir='Music'/>
<alias name='fs6'/>
<address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/software.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/Software'/>
<target dir='Software'/>
<alias name='fs7'/>
<address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' queue='1024'/>
<binary path='/usr/libexec/tv.sh' xattr='on'>
<cache mode='always'/>
<sandbox mode='chroot'/>
</binary>
<source dir='/mnt/user/TV'/>
<target dir='TV'/>
<alias name='fs8'/>
<address type='pci' domain='0x0000' bus='0x0b' slot='0x00' function='0x0'/>
</filesystem>
Once done, reboot the server so the go file moves all of the files and sets permissions.
This is a huge improvement over the stock config. Thanks for this @jch. Hopefully we can get these settings implemented in 6.13.