How to mount 9p drive using /etc/fstab?

15,089

Solution 1

This did it for me.

https://superuser.com/q/502205/524816

All credit to @roiama for the answer (in question comments).

Solution 2

In case you are using systemd, this can be probably also a problem with the system trying to mount a little bit to early. In my case, following instructions for NFS from the Arch Wiki solved the issue:
https://wiki.archlinux.org/index.php/NFS#Mount_using_.2Fetc.2Ffstab_with_systemd

E.g this helped for me:
/blacknas/show-archive /mnt/blacknas/show-archive 9p noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=0,trans=virtio,version=9p2000.L,rw 0 0

Solution 3

Here I provide a minimal and automated runnable QEMU Buildroot example that mounts 9p directories at startup as described at: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/5b7094fb68e36c2c4af73e8a209a979ebbf32eae#9p

The fstab file is present at: https://github.com/cirosantilli/linux-kernel-module-cheat/blob/5b7094fb68e36c2c4af73e8a209a979ebbf32eae/rootfs_overlay/etc/fstab and contains entries of form:

# <file system>         <mount pt>                  <type>  <options>                       <dump>  <pass>
host_data               /mnt/9p/data                9p      trans=virtio,version=9p2000.L   0       0
host_out                /mnt/9p/out                 9p      trans=virtio,version=9p2000.L   0       0
host_rootfs_overlay     /mnt/9p/rootfs_overlay      9p      trans=virtio,version=9p2000.L   0       0
host_out_rootfs_overlay /mnt/9p/out_rootfs_overlay  9p      trans=virtio,version=9p2000.L   0       0
Share:
15,089

Related videos on Youtube

Beakie
Author by

Beakie

Updated on September 18, 2022

Comments

  • Beakie
    Beakie almost 2 years

    I can mount a drive using 9p on to my libvirt guest using the following command...

    mount -t 9p trans=virtio,version=9p2000.L,rw share /machine/host
    

    ...but can't work out what to add to /etc/fstab to do it on startup.


    I have tried...

    share /machine/host 9p trans=virtio,version=9p2000.L,rw 0 0
    

    ...but the guest fails to boot (and I get taken to Emergency mode).


    Can anyone please advise?

    Thanks

    • Admin
      Admin almost 7 years
    • Admin
      Admin over 6 years
      Please add this as an answer so I can give you credit.
    • Admin
      Admin over 6 years
      Thank you. It was a long time ago and I'm not sure which of the referenced answers would have worked for you. In this case it would be better, I tihink, for you to answer your own question with the solution that worked best. Feel free to cross-reference the superuser answer(s).
    • Admin
      Admin almost 3 years
      In 2021, the https://superuser.com/a/1565275/1055520 worked without any hassle in ArchLinux for me.
  • Tenders McChiken
    Tenders McChiken almost 4 years
    If you want to go the initramfs route, you'll also need to explicitly load them if your kernel doesn't make use of 9p modules before starting init. You can force your init system to load by including modules_load=9pnet_virtio,9p to your kernel command line if your init system supports it (e.g. systemd).