Ultra Lightweight NAS
Storage servers are needed every where and usually several. Usually there is absolutely no need for any GUI or other stuff bloating the server. The best is a plain NFS Server - it's fast and romust.
Actually, it's only a minimal OS and a NFS server running on it. The OS will run on 4 G, but we stick to 8 G (Alpine 2/4 G) for safety and larger cash. A practical Networked Storage is only a small appliance and some ZFS drives, usually Z1 RAID.
The component we will us is a Debian/Ubuntu VM/CT and ZFS for storage, NFS for fast networking (CIFS are too slow) and autofs on the Client for mounting when needed. For the smallest footprint, use Alpine.
AutoFS is not needed but convenient and have some benefits.
NFS Server installation on Debian or Ubuntu
NFS Server installation on Alpine 👌
Alpine is tiny but powerful. It's pure Linux (not bloated by GNU). It's the perfect OS for a Super Lightweight Storage Server, but requires more skills.
Login with default password root
and run setup-alpine
.
Install and activate the NFS Server on Alpine
QEMU-Guest-Agent on Alpine
- Activate the community repository if not activated at setup
needed to install the QEMU-Guest-Agent- install by
nano /etc/apk/repositories
- remove the # in front of the community repository line
- install by
- add the QGA by
doas apk add qemu-guest-agent
- activate the QGA by
doas rc-update add qemu-guest-agent
- start the QGA by
doas rc-service qemu-guest-agent start
Setup of the directories to export
sudo mkdir -p /exports/{backup,documents,films,music,photos}
doas mkdir /exports
cd /exports
doas mkdir backups documents films music photos
Create the configuration of the NFS Server
First, move the configuration file to a copy (sudo on deb — doas on Alpine)
Create a new configuration file
sudo nano /etc/exports
Setup Users on the Server
Create your users by adduser <user name>
and give them a password when you are prompted for one, the rest are optional. This way, you do not need to set privileges to 777.
Ad hoc mounting
For stuff, you rarely use or will use only once, you can do all mounting without the AutoFS. Let’s mount one of the shares from the server:
sudo mount 10.10.40.139:/exports/backup-old /mnt/nfs/backup-old
Run df -h
to see that the export is mounted and accessible, and list the content of the directory byls -l /mnt/nfs/backup-old
.
When we’re finished with a mount, we can unmount it with the umount
command:
sudo umount /mnt/nfs/backup/old
On-demand mounting with AutoFS
The settings will be in /etc
or /etc/autofs
.
sudo apt-get update && sudo apt-get -y install nfs-common autofs
Check that it works by showmount
that you can see your exported directories
showmount --exports 10.10.40.139
Create a directory for the exported directories anywhere you like. With many NFS servers, use the last octet of the server IP to keep them separated, e.g., 139. With ghost, they will disappear after a timeout of 60 seconds to avoid messy file locking.
mkdir -p /srv/nfs/139/
nano /etc/auto.master
/srv/nfs/139/ /etc/auto.nfs --ghost --timeout=60
Create the settings for the exported directories, rw is for read and write.
nano /etc/auto.nfs
backup -fstype=nfs4,rw 10.10.40.139:/exports/backup
documents -fstype=nfs4,rw 10.10.40.139:/exports/documents
films -fstype=nfs4,rw 10.10.40.139:/exports/films
music -fstype=nfs4,rw 10.10.40.139:/exports/music
photos -fstype=nfs4,rw 10.10.40.139:/exports/photos
sudo systemctl restart autofs
NFS Configuration options for Server and Client side
rw
: Grants the client both read and write access to the directory.ro
: the directory may only be mounted as read onlysync
: Forces NFS to write changes to disk before replying.
This results in a more stable and consistent environment since the reply reflects the actual state of the remote volume.
The negative is that it also reduces the speed of file operations.async
– ignores synchronization checks in favor of increased speedno_subtree_check
: Prevents subtree checking.
It's a process where the host must check whether the file is still available in the exported tree for every request.
Can cause problems if a file is renamed while the client has it opened.
In almost all cases, it is better to disable subtree checking.subtree_check
– specifies that, in the case of a directory is exported instead of an entire file system, the host should verify the location of files and directories on the host file system
NFS Configuration options for Server
no_root_squash
: By default, NFS translates requests from a remote root user into a non-privileged user on the server.
It was intended for security by preventing a client root account from using the file system of the host as root. no_root_squash
disables this behavior for some shares.
It's an extremely dangerous option that allows remote root users
the same privilege as the root user of the host machine!
Script
You can download a basic script from my GitHub repository
GUI for the NAS
Previously I used Cockpit for my Lightweight NAS. Here I recommend not to use a GUI, and if you like one use file browser. See this post how to implement file browser on an Alpine NAS.
References
Autofs [1] Network File System [2] Proxmox [3]
See also this altenative solution. A Lightweight NAS