Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

9P Sharing files between host and guest

Featured Replies

Just thought I'd see if anyone else has tried this.  It's similar to sharing in dockers. In my xml file under devices I put a line like this

    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/mnt'/>
      <target dir='shares'/>
    </filesystem>

and then within the vm in fstab

shares   /mnt    9p  trans=virtio,version=9p2000.L,noauto,nobootwait,rw    0   0

I noauto because sometimes it errors out at vm startup.  So I just put "mount /mnt" in /etc/rc.local  I run this in an apps vm and I had to modify rc.local to start before the apps so unraid user shares are mounted before any apps. Been working well for a couple weeks with everything located in /mnt on unraid available in my apps vm under the same /mnt. No network problems, rocket rides or cifs mounting needed like in xen.

  • Replies 60
  • Views 49.7k
  • Created
  • Last Reply

Yes , I am using it  for a long time! And this is very cool way to pass trough file system :-) and for me KVM is the preferred and is stable.

  • Author

Yes , I am using it  for a long time! And this is very cool way to pass trough file system :-) and for me KVM is the preferred and is stable.

Why didn't you tell us? :) For me kvm hasn't been as stable.  I think it has to do with my motherboard/cpu. In Xen it was very stable as long as I didn't pin cores in sysconfig and xenvm.cfg.  If I did it would eventually freeze the system.  I've had kvm freeze in a similar way. Nothing in the console just frozen. Had to hard reboot. So far I've been up for several days no cachedirs and 2 vms with 2 cores and 2 GB.

Yes , I am using it  for a long time! And this is very cool way to pass trough file system :-) and for me KVM is the preferred and is stable.

Why didn't you tell us? :) For me kvm hasn't been as stable.  I think it has to do with my motherboard/cpu. In Xen it was very stable as long as I didn't pin cores in sysconfig and xenvm.cfg.  If I did it would eventually freeze the system.  I've had kvm freeze in a similar way. Nothing in the console just frozen. Had to hard reboot. So far I've been up for several days no cachedirs and 2 vms with 2 cores and 2 GB.

Some info earlier about p9 file system... I'm using this appliance for my VM:s

http://lime-technology.com/forum/index.php?topic=31623.msg311001#msg311001

  • Author

Yes , I am using it  for a long time! And this is very cool way to pass trough file system :-) and for me KVM is the preferred and is stable.

Why didn't you tell us? :) For me kvm hasn't been as stable.  I think it has to do with my motherboard/cpu. In Xen it was very stable as long as I didn't pin cores in sysconfig and xenvm.cfg.  If I did it would eventually freeze the system.  I've had kvm freeze in a similar way. Nothing in the console just frozen. Had to hard reboot. So far I've been up for several days no cachedirs and 2 vms with 2 cores and 2 GB.

Some info earlier about p9 file system... I'm using this appliance for my VM:s

http://lime-technology.com/forum/index.php?topic=31623.msg311001#msg311001

I see you tried to tell me 2 months ago but I wasn't listening since I never liked arch I never read that thread.  :)

So instead of adding the following to the VM and editing fstab as shown below. You are sharing files directly from the .xml? Is there an advantage to doing it one way vs the other?

 

Edit fstab so we can connect the mounts on boot
sudo nano /etc/fstab

Edit and paste the following
//Tower/Movies /media/Movies cifs noauto,credentials=/home/ubuntuUser/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0
//Tower/TV /media/TV cifs noauto,credentials=/home/ubuntuUser/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0

Speed and I think it's more benefit than SMB

 

With editing fstab (like I did above) a few of my apps (sickbeard) loaded before the shares were mounted. To fix this I created a crontab task that delayed the startup of sickbeard for 10 seconds after boot. Does the 9P sharing mount the shares before the apps are loaded in rc.local?

In arch I have a few apps using 9p and no issue when booting. But I changed the fstab comparing my post in the other thread, I can check this later for exact command I have

In arch you can also set to load apps after network is up, but I don't think bin hex have added this in his VM

  • Author

Speed and I think it's more benefit than SMB

 

With editing fstab (like I did above) a few of my apps (sickbeard) loaded before the shares were mounted. To fix this I created a crontab task that delayed the startup of sickbeard for 10 seconds after boot. Does the 9P sharing mount the shares before the apps are loaded in rc.local?

The advantage is not using your virtual network especially for intensive operations like, par, rar, usnet and torrents.

 

I had a problem with sickrage and nzbget.  I renamed the init symlinks in /etc/rc2.d of my apps from 20 to 99 so they start last.  Then changed rc.local from 99 to 98. Check this page it explains the different rc.x runlevels. You'll have to check which level your vm runs or just change them all, rc0.d, rc1.d...rc6.d

http://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts

 

By doing this you could also make it so one app starts before the other.

 

My current /etc/fstab is as follows:

 

//pithos.private/media/MOVIES\040-\040HD /home/archedraft/media/movies cifs noauto,credentials=/home/archedraft/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0
//pithos.private/media/TV\040SERIES /home/archedraft/media/tv cifs noauto,credentials=/home/archedraft/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0
//pithos.private/downloads /home/archedraft/media/downloads cifs noauto,credentials=/home/archedraft/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0

 

1. I am assuming if I wanted to add this to my .xml it should read like this below?

 

    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/media/MOVIES\040-\040HD'/>
      <target dir='/home/archedraft/media/movies'/>
    </filesystem>

 

2. /etc/fstab should read is as follows:

 

shares   /media/MOVIES\040-\040HD    9p  trans=virtio,version=9p2000.L,noauto,nobootwait,rw    0   0

 

3. Do I need to make 3 separate filesystem codes in my .xml for each share or can you add multiple shares to one filesystem code?

 

<filesystem type='mount' accessmode='passthrough'>

      <source dir='/mnt'/>

      <target dir='shares'/>

    </filesystem>

 

4. I am assuming I do not need to install a 9P program in my ubuntu server?

5. Due to the shares being passthrough, I should not have to have a .smbcredentials file correct?

My current /etc/fstab is as follows:

 

//pithos.private/media/MOVIES\040-\040HD /home/archedraft/media/movies cifs noauto,credentials=/home/archedraft/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0
//pithos.private/media/TV\040SERIES /home/archedraft/media/tv cifs noauto,credentials=/home/archedraft/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0
//pithos.private/downloads /home/archedraft/media/downloads cifs noauto,credentials=/home/archedraft/.smbcredentials,noperm,noserverino,uid=nobody,gid=users 0 0

 

1. I am assuming if I wanted to add this to my .xml it should read like this below?

 

    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/media/MOVIES\040-\040HD'/>
      <target dir='/home/archedraft/media/movies'/>
    </filesystem>

 

2. /etc/fstab should read is as follows:

 

shares   /media/MOVIES\040-\040HD    9p  trans=virtio,version=9p2000.L,noauto,nobootwait,rw    0   0

 

3. Do I need to make 3 separate filesystem codes in my .xml for each share or can you add multiple shares to one filesystem code?

 

<filesystem type='mount' accessmode='passthrough'>

      <source dir='/mnt'/>

      <target dir='shares'/>

    </filesystem>

 

4. I am assuming I do not need to install a 9P program in my ubuntu server?

5. Due to the shares being passthrough, I should not have to have a .smbcredentials file correct?

 

For target dir, that's the share name you add first in the fstab, give it name like cache,user......source dir is the file system you like to pass trough.

 

And you give one for each pass trough , like you have above.

 

To get this to work, the VM kernel needs this 9p modules, Ubuntu I think is OK.

 

Number 1 and 2 I think is wrong, look here...

http://lime-technology.com/forum/index.php?topic=31623.msg311001#msg311001

 

Example.....

 

Below folders are created in my VM

 

  /mnt/cache

  /mnt/user

 

 

My VM fstab

cache  /mnt/cache      9p      trans=virtio,version=9p2000.L,rw        0 0

user    /mnt/user      9p      trans=virtio,version=9p2000.L,rw        0 0

 

 

Part of My XML file

 

<filesystem type='mount' accessmode='passthrough'>   

  <source dir='/mnt/cache/'/>                       

  <target dir='cache'/>                                                   

</filesystem>                                       

                                                     

<filesystem type='mount' accessmode='passthrough'>   

  <source dir='/mnt/user/'/>                         

  <target dir='user'/>                                                         

</filesystem>                                       

OK, understood. I'll give this a try this afternoon. Thanks for the example! I am guessing that your "cache" and "user" mounts are the main shares you have setup in unRAID? So for my setup my "cache" share would be "media".

Yes, like this

 

<filesystem type='mount' accessmode='passthrough'>     
   <source dir='/mnt/media/'/>                          
   <target dir='anynameyouliketouse'/>                                                           
</filesystem>                

 

in VM

 

mkdir /mnt/folderyouhavecreated     

 

fstab

anynameyouliketouse /mnt/folderyouhavecreated      9p      trans=virtio,version=9p2000.L,rw        0 0

 

:-)

//Peter

I got the following error when I tried.

 

qemu-system-x86_64: -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=media,bus=pci.2,addr=0x1: Device initialization failed.
qemu-system-x86_64: -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=media,bus=pci.2,addr=0x1: Device 'virtio-9p-pci' could not be initialized

 

That is what I added to my .xml file

    
    <filesystem type='mount' accessmode='passthrough'>
          <source dir='/mnt/media'/>
          <target dir='media'/>
    </filesystem>

 

Do I need to add the following to syslinux.cfg before passthrough will work?

label KVM unRAID OS
  menu default
  kernel /bzimage
  append intel_iommu=on quiet vfio_iommu_type1.allow_unsafe_interrupts=1 initrd=/bzroot acpi_sleep=s3_bios

  • Author

Does /mnt/media exist on unraid? The source dir has to be  an existing path in unraid. I didn't add anything to syslinux.

  • Author

Something that may be of interest too. Because I moved from xen vm to dockers to kvm vm I just left my paths from docker intact in each app. Then in the vm I mount /mnt from unraid to /mnt in vm. Then I symlinked say /mnt/user/movies to a symlink /movies same with/mnt/cache/downloads to /downloads etc. I put all my configs in /opt/appdata and created a symlink /configs

So here is a quick write up for anyone who needs a little more guidance (like myself  :P):

 

1. First edit your .xml file (source dir = unraid mount) (traget dir = label)

 

    <filesystem type='mount' accessmode='passthrough'>
          <source dir='/mnt/user/MEDIA/MOVIES - HD'/>
          <target dir='movies'/>
    </filesystem>
    
    <filesystem type='mount' accessmode='passthrough'>
              <source dir='/mnt/user/MEDIA/TV SERIES'/>
              <target dir='tv'/>
    </filesystem>
    
    <filesystem type='mount' accessmode='passthrough'>
              <source dir='/mnt/user/downloads'/>
              <target dir='downloads'/>
    </filesystem>
    

 

2. Then startup the VM

 

3. edit fstab

sudo nano /etc/fstab

movies	/home/archedraft/media/movies    9p  trans=virtio,version=9p2000.L,_netdev,rw   0 0
tv	/home/archedraft/media/tv	  9p trans=virtio,version=9p2000.L,_netdev,rw   0 0
downloads	/home/archedraft/media/downloads    9p  trans=virtio,version=9p2000.L,_netdev,rw   0 0

 

4. Create the mount directories in your VM

Sudo mkdir /home/archedraft/media/movies

 

 

5. edit nano [EDIT: You don't need to do this step unless you use this in fstab "trans=virtio,version=9p2000.L,noauto,nobootwait,rw"]

sudo nano /etc/rc.local

mount /home/archedraft/media/movies
mount /home/archedraft/media/tv
mount /home/archedraft/media/downloads

 

6. reboot

Hi archedraft,

Any  reason to use the  /etc/rc.local ?

 

If you skip that, and  do

mount -a

after you have edit the fstab and created the mount directories in your VM, what do you see? are the share mounted ? thats the way I used it. no extra mount command in other files.

 

//Peter

 

He uses the noauto option in fstab and needs to mount it manually after boot. He did mention something about why in an earlier post I think.

  • Author

With auto mount it will error during vm boot sometimes.  Sometimes it would get stuck during boot saying press m or s or something like that. But when you manually mount with rc.local it always works.

Just wondering if that was a problem with cifs shares you had or on the passthrough you have now also?

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.