[pve-devel] [PATCH v1 pve-storage 0/2] SSHFS Example Storage Plugin

Max Carrara m.carrara at proxmox.com
Wed Apr 16 14:47:33 CEST 2025


SSHFS Example Storage Plugin - v1
=================================

Add a custom storage plugin based on SSHFS [0] to serve as an example
for an upcoming storage plugin development guide. This plugin should
also be ready for production usage, though it would be nice to get some
more testing (and potentially performance-tuning) done.

The plugin demonstrates how the following things should be handled:
- handling sensitive properties (shout-out to Fiona [1])
  - the private key is copied to /etc/pve/priv/storage/${PRIV_KEY}.key
    instead of being put into /etc/pve/storage.cfg
  - on removal of the storage, the private key is also removed 
  - though not really that nicely supported via the CLI, updating the
    private key file is also handled
- making use of /etc/pve/priv/known_hosts for easy setup on a cluster
  and marking the storage as shared automatically
- connection checking (since it's a network storage)
- conditionally creating the mountpoint and mounting the storage if not
  already mounted
- unmounting the storage on removal (not deactivation!)
- handling "notes" and "protected" attributes for backups

Furthermore, the plugin lives in its own subdir inside `pve-storage`,
complete with its own `debian/` dir and `Makefile` in order to
demonstrate how to package a plugin for Debian.

NOTE: The plugin is *not* built via the top-level `Makefile` at the
moment.

How to Use & Test
-----------------

You'll need some kind guest you can SSH into with pubkey auth.
On that host, it's best to create some directory for SSHFS, e.g.:

    mkdir -p /srv/sshfs && chmod 750 /srv/sshfs

The plugin can easily be built via `make deb` inside
`example/sshfs-plugin`. Once built and installed on a different PVE host
of your choice, you should first deploy a private key for SSHFS, e.g.:

  ssh-copy-id -i ~/.ssh/id_my_private_key \
    -o UserKnownHostsFile=/etc/pve/priv/known_hosts [USER]@[HOST]

Then, using the deployed key, the storage can be added as follows:

  pvesm add sshfs [STOREID] \
    --username [USER] \
    --server [HOST] \
    --sshfs-remote-path /srv/sshfs \
    --path /mnt/path/to/storage \
    --sshfs-private-key ~/.ssh/id_my_private_key

The storage should then pop up in the UI. It should be functionally
equivalent to most other dir-based network storages, except that imports
aren't supported in order to keep the example from becoming too complex.

Would be nice if somebody could give this a spin! I think there's
definitely room for some performance improvements, but so far the
storage was doing *alright*. IOPS are terrible, though.

References
----------

[0]: https://github.com/libfuse/sshfs
[1]: https://lore.proxmox.com/pve-devel/20250404133204.239783-6-f.ebner@proxmox.com/

Older Versions
--------------

rfc-v1: https://lore.proxmox.com/pve-devel/20250328171209.503132-1-m.carrara@proxmox.com/

Summary of Changes
------------------

Max Carrara (2):
  example: sshfs plugin: add custom storage plugin for SSHFS
  example: sshfs plugin: package SSHFSPlugin.pm

 example/sshfs-plugin/Makefile                 |  71 ++++
 example/sshfs-plugin/debian/changelog         |   5 +
 example/sshfs-plugin/debian/control           |  22 +
 example/sshfs-plugin/debian/copyright         |  21 +
 example/sshfs-plugin/debian/rules             |  26 ++
 example/sshfs-plugin/debian/source/format     |   1 +
 example/sshfs-plugin/debian/triggers          |   1 +
 .../lib/PVE/Storage/Custom/SSHFSPlugin.pm     | 398 ++++++++++++++++++
 8 files changed, 545 insertions(+)
 create mode 100644 example/sshfs-plugin/Makefile
 create mode 100644 example/sshfs-plugin/debian/changelog
 create mode 100644 example/sshfs-plugin/debian/control
 create mode 100644 example/sshfs-plugin/debian/copyright
 create mode 100755 example/sshfs-plugin/debian/rules
 create mode 100644 example/sshfs-plugin/debian/source/format
 create mode 100644 example/sshfs-plugin/debian/triggers
 create mode 100644 example/sshfs-plugin/lib/PVE/Storage/Custom/SSHFSPlugin.pm

-- 
2.39.5





More information about the pve-devel mailing list