From: Max Carrara <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v1 pve-storage 0/2] SSHFS Example Storage Plugin
Date: Wed, 16 Apr 2025 14:47:33 +0200 [thread overview]
Message-ID: <20250416124735.320256-1-m.carrara@proxmox.com> (raw)
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
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next reply other threads:[~2025-04-16 12:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 12:47 Max Carrara [this message]
2025-04-16 12:47 ` [pve-devel] [PATCH v1 pve-storage 1/2] example: sshfs plugin: add custom storage plugin for SSHFS Max Carrara
2025-04-18 12:18 ` Max Carrara
2025-04-16 12:47 ` [pve-devel] [PATCH v1 pve-storage 2/2] example: sshfs plugin: package SSHFSPlugin.pm Max Carrara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250416124735.320256-1-m.carrara@proxmox.com \
--to=m.carrara@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal