feat(nfs): add initial NFS server implementation with configuration and usage instructions

This commit is contained in:
2026-03-29 13:40:09 +02:00
parent 330a3348b9
commit 0778d7a6fa
6 changed files with 75 additions and 0 deletions

5
nfs/CHANGELOG.md Normal file
View File

@@ -0,0 +1,5 @@
# Changelog
## 1.0.0 - 2026-03-29
- Initial release

5
nfs/Dockerfile Normal file
View File

@@ -0,0 +1,5 @@
FROM alpine:3.19
RUN apk add --no-cache nfs-utils
COPY run.sh /
RUN chmod +x /run.sh
CMD ["/run.sh"]

24
nfs/README.md Normal file
View File

@@ -0,0 +1,24 @@
# Home Assistant Add-on: NFS Server
This add-on exposes the Home Assistant media folder via NFS.
## Configuration
The following configuration options are available:
- `allowed_network`: The network allowed to access the NFS share (e.g., `192.168.1.0/24`). Defaults to `0.0.0.0/0` (everyone). It is highly recommended to restrict this to your local network.
## How to use
1. Start the add-on.
2. On your client machine, mount the NFS share. The NFS share will be the IP of your Home Assistant instance, and the exported path is `/media`.
Example on a Linux client:
```bash
mkdir /mnt/hass-media
mount -t nfs <home-assistant-ip>:/media /mnt/hass-media
```
## Notes
This addon requires `host_network` and `SYS_ADMIN` privileges to run.

11
nfs/config.yaml Normal file
View File

@@ -0,0 +1,11 @@
name: NFS Server
version: "1.0.0"
slug: nfs_server
description: Expose Home Assistant media folder via NFS.
arch: [aarch64, amd64, armv7, i386, x86_64]
privileged: [SYS_ADMIN]
apparmor: false
host_network: true
map:
- media:rw
ports: {}

8
nfs/options_schema.json Normal file
View File

@@ -0,0 +1,8 @@
[
{
"name": "allowed_network",
"type": "string",
"description": "The network allowed to access the NFS share (e.g., 192.168.1.0/24)",
"default": "0.0.0.0/0"
}
]

22
nfs/run.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bashio
# Read config
NETWORK=$(bashio::config 'allowed_network')
# Setup exports
bashio::log.info "Exporting /media folder to ${NETWORK}..."
echo "/media ${NETWORK}(rw,sync,no_subtree_check,no_root_squash)" > /etc/exports
cat /etc/exports
# Start NFS services
bashio::log.info "Starting NFS services..."
rpcbind
exportfs -ra
# Start rpc.statd for file locking
rpc.statd &
# Start the NFS server kernel threads
rpc.nfsd
# Start rpc.mountd in the foreground to keep the container running
exec rpc.mountd --no-udp -F