Skip to content

Instantly share code, notes, and snippets.

@mauri870
Last active August 4, 2022 13:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauri870/e35cd6e508c95dd59ec9d394c1eec470 to your computer and use it in GitHub Desktop.
Save mauri870/e35cd6e508c95dd59ec9d394c1eec470 to your computer and use it in GitHub Desktop.
Sharing UNIX files with a Plan9 instance through 9P

Hi,

this gist summarizes how to share UNIX files/folders with a Plan9 instance using u9fs.

First of all, grab the latest u9fs release from source or install it with the package manager of your preference, then build and install.

Please be sure to find the correct path to your u9fs binary because it may differ based on the installation, normally it is /usr/local/bin/u9fs or /usr/bin/u9fs.

On older unix/linux systems you may use inetd, which is already covered by the u9fs man page.

This tutorial will cover xinetd which is present in newer systems.

Open the /etc/services file and ensure the following line is present:

9pfs              564/tcp

Then create a file named /etc/xinetd.d/u9fs with the following contents (make adjustments as needed):

service 9pfs
{
        socket_type = stream
        protocol = tcp
        wait = no
        user = root
        server = /usr/bin/u9fs
        server_args = -D -n -z -u myuser -na none /my/folder/to/share
        instances = 2
        port = 564
}

Run chmod 600 /etc/xinetd.d/u9fs.

Now you just need to restart the xinetd daemon

systemctl restart xinetd
systemctl status xinetd

u9fs logs are located at /tmp/u9fs.log by default

In a plan 9 system you can run the following commands to mount (qemu host in this example):

srv tcp!10.0.2.2!9fs
mount -c /srv/tcp!10.0.2.2!9fs /n/qemuhost device

The 9p service containing the shared folder is now mounted at /n/qemuhost.

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment