9

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).

4

3 Answers 3

4

This did it for me.

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

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

1
  • 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). Jul 6, 2020 at 10:07
3

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

1
  • Thanks Fryderyq :) This is to confirm this also works on Debian 10 Buster. /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
    – Francewhoa
    Jun 17, 2023 at 3:36
2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .