Build One Private Share That Depends on the Right Drive
A Raspberry Pi NAS becomes useful when an authorized client can work with files, the same volume returns after reboot, and missing storage cannot silently redirect writes onto the boot card. This walkthrough builds a private Projects share using Raspberry Pi OS Lite, an existing ext4 test volume and Samba. It includes the mount entry, share configuration, service dependency and client acceptance checks that turn those intentions into a defined setup. Start with disposable files and an independent backup; no formatting command is needed for this route. Follow the exact system and storage documentation when your hardware or installed service differs. The goal is a small understandable local file service whose normal operation and missing-drive behavior can both be checked before important data is entrusted to it.
A: No. Shared storage needs a deliberate independent-copy and restoration strategy.
A: Inspect its format and contents first, and verify independent copies before any operation that could erase or alter access.
A: Check the authenticated account, Samba settings, and underlying filesystem permissions together.
A: Use your actual intended account; example names do not create users or establish ownership.
A: Investigate local name resolution rather than assuming the storage service is broken.
A: An absent external volume can leave a directory that no longer refers to the intended storage.
A: No. They share the same physical failure risk.
A: Keep the beginner NAS local and design remote access separately using an appropriately secured supported method.
A: Correct access, rejected unauthorized use, stable mounting after restart, and a verified restoration.
A: Use the current Raspberry Pi setup documentation, the installed operating system's guidance, and Samba's smb.conf manual.
Choose a Small, Defined NAS Configuration
This walkthrough uses a Raspberry Pi 4 or 5, its supported supply, Raspberry Pi OS Lite, Ethernet, and an identified external USB data volume already formatted as ext4. Use a powered enclosure or supported powered USB arrangement when the drive requires it. The boot medium stays separate from shared data. Begin with disposable test files and independent backups; this article deliberately includes no partitioning or formatting command. If your drive is not the intended ext4 test volume, resolve that preparation through the current storage documentation before continuing.
The example hostname is workshop-nas, the Linux and Samba user is maker, and the published share is Projects. Install the operating system with your chosen account using Raspberry Pi Imager; substitute your own username consistently if it differs. Keep the server on a trusted private home network. Do not forward SMB ports through the router or turn this first exercise into an internet-accessible file service. The completed test should establish authorized file access, persistent mounting and a deliberate failure when the external volume is absent.
Install Samba and Record the Baseline
Connect to your Pi using its supported local or SSH administration route, verify its identity, and apply operating-system updates. The commands below assume a Debian-based Raspberry Pi OS installation using systemd and the ordinary smbd service; check those names on your installation before changing files. Confirm the maker account exists and keep an administrative session available while configuring the share. Install Samba through the package manager and preserve its original configuration. A successful package installation establishes software availability, not permission to use an arbitrary disk.
sudo apt update
sudo apt full-upgrade
sudo apt install samba
id maker
sudo cp -a /etc/samba/smb.conf /etc/samba/smb.conf.before-projects
lsblk -o NAME,SIZE,MODEL,FSTYPE,UUID,MOUNTPOINTS
Mount the Identified Volume at a Stable Location
Match the data volume’s model, size, filesystem and physical connection to the intended device. Record its filesystem UUID from lsblk; do not choose it merely because it is called sda1 today. Check that this volume is not already mounted elsewhere. Create the empty mount directory, back up fstab, and use sudo nano /etc/fstab to add the example line with the actual UUID. The placeholder below must be replaced; copying it unchanged cannot identify your disk.
sudo mkdir -p /srv/nas
sudo cp -a /etc/fstab /etc/fstab.before-nas
sudo nano /etc/fstab
UUID=REPLACE_WITH_DATA_VOLUME_UUID /srv/nas ext4 defaults,nofail,x-systemd.device-timeout=10s 0 2
The nofail option lets boot continue when this nonessential data volume cannot mount; it does not make missing storage safe for sharing by itself. The service guard later supplies that boundary. After saving the file, reload systemd’s configuration, mount this specific path and inspect the result. Continue only when findmnt shows the intended external ext4 filesystem mounted at /srv/nas. If it reports an error, fix the identity, filesystem or configuration rather than creating a share on the boot storage.
sudo systemctl daemon-reload
sudo mount /srv/nas
findmnt --mountpoint /srv/nas -o SOURCE,FSTYPE,TARGET
Create One Private Folder and a Real Share Definition
Create Projects only after the mount check succeeds. The install command below makes a directory owned by maker with access restricted to that account. Confirm the account and group names with id before using them; if your account differs, replace both. Do not recursively change ownership of an unrelated existing drive or make it world-writable to solve an access problem. Filesystem permissions and Samba authorization are separate layers that both need to permit the intended operation.
mountpoint -q /srv/nas
sudo install -d -o maker -g maker -m 0700 /srv/nas/projects
sudo smbpasswd -a maker
sudo nano /etc/samba/smb.conf
The first command must succeed before the directory command is run. Set a Samba password when prompted, then add this complete share section to the configuration without deleting unrelated global settings. The path is a Linux location; Projects is the name clients see. A username in valid users must resolve to the intended local account, and the account must also have filesystem access. Preserve the configuration backup until the entire acceptance test passes.
[Projects]
path = /srv/nas/projects
valid users = maker
guest ok = no
read only = no
create mask = 0600
directory mask = 0700
Run sudo testparm -s and correct any reported syntax problem before proceeding. Review other published shares as well as the new section; this example does not authorize sharing the operating-system root or every home directory. The masks suit this one-writer example and should not be copied unchanged into a collaborative group design. Do not enable obsolete SMB protocol versions to accommodate an old client without separately resolving that compatibility and security issue. Samba’s smb.conf manual defines these settings.
Require the External Mount Before Samba Starts
A missing drive can leave an ordinary directory at its mount path. Prevent Samba from silently serving that directory by adding a service drop-in with sudo systemctl edit smbd.service. Save the following content through the editor, then reload systemd and restart the service. The mount unit name srv-nas.mount corresponds specifically to /srv/nas; another path needs its own correctly escaped unit name. This setup intentionally constrains the whole smbd service, so other shares on this example server also stop when this required mount is unavailable.
[Unit]
RequiresMountsFor=/srv/nas
BindsTo=srv-nas.mount
After=srv-nas.mount
[Service]
ExecStartPre=/usr/bin/mountpoint -q /srv/nas
sudo systemctl daemon-reload
sudo systemctl restart smbd.service
systemctl status smbd.service --no-pager
Connect From a Client With Explicit Credentials
Find the Pi’s current address in the router and, if useful, reserve it through the router’s DHCP feature. On Windows, enter the path shown below in File Explorer, using the actual hostname or address if local name resolution differs. On macOS, use Finder’s Connect to Server with the SMB address. Log in as maker using the Samba password you set, rather than an unrelated Microsoft or Apple account. The hostname and share name are distinct parts of the connection.
Windows: \\workshop-nas\Projects
macOS: smb://workshop-nas/Projects
Create a disposable text file, reopen it, rename it, then delete it to prove the writer’s intended operations. Inspect the server-side result if permission behavior is unexpected. A cached client session can preserve an earlier login, so disconnect and clear or change saved credentials through the client’s supported interface before testing another identity. Confirm that an unauthorized login cannot open the share. Do not interpret a successful connection under saved credentials as a successful wrong-password rejection test.
Reboot With the Data Drive Present
Restart through sudo reboot, reconnect to the Pi, and inspect both the mount and smbd status before opening Projects again. The same external filesystem should be mounted at /srv/nas and the service should be active. Open the original test files, make one new file, and confirm the share still uses the intended volume. If mounting failed, the correct outcome is a failed or inactive file service, not a convenient empty share. Diagnose that condition through findmnt, the fstab entry and the service log rather than bypassing the mount check.
Test Missing Storage With a Controlled Cold Boot
Use only disposable data for this test. Close client files, perform a normal shutdown, disconnect the data drive while the Pi is off, and boot without it. The operating system should remain administrable under this fstab design while Samba is unavailable because its required data mount cannot be established. Check the following observations from the Pi. A failed mount dependency and an unavailable share are expected evidence of the intended boundary.
findmnt --mountpoint /srv/nas
systemctl is-active smbd.service
journalctl -u smbd.service -b --no-pager
Confirm from the client that it cannot create files through Projects in this condition. Inspect the unmounted /srv/nas directory without creating a projects subdirectory there. The test should not leave new shared data on the boot medium. If the service still publishes a writable folder, stop it and investigate the installed unit and drop-in before returning the NAS to use. Do not solve the failure by removing the dependency or the mountpoint check.
Shut down again before reconnecting the data drive, then boot and repeat the ordinary mount and access checks. This cold-boot exercise does not establish safe surprise removal during writes. An enclosure can disconnect or fail while Linux is still handling I/O, and service dependencies cannot make that data loss disappear. Keep cables secure, monitor storage problems and use normal shutdown before changing the hardware. The systemd unit manual explains the roles of RequiresMountsFor, BindsTo and ordering dependencies.
Back Up a Recognizable Project and Restore It
A NAS is not its own independent backup. Copy a small project containing a document, photograph and source file to a separately controlled destination using a supported backup process. Decide whether you need version history and how failures will become visible. A second directory on the same drive does not protect against that drive’s failure. Keep backup permissions separate enough that an ordinary mistaken edit need not overwrite every recoverable copy immediately.
Restore the sample into a different test directory and compare it with its source. If deletion recovery is part of the plan, remove a disposable source file and verify that the chosen history can restore it. Record the account name, mount UUID, share section and service drop-in with the recovery instructions, while protecting passwords appropriately. A new operating-system installation will need that configuration as well as the data. Repeat recovery checks after changing the backup system.
Troubleshoot by the Failed Layer
If the Pi cannot be reached at all, begin with its power and network rather than editing Samba. If an address works but the hostname does not, investigate local name resolution. If the share is visible but access is denied, check the active client identity, Samba account and directory permissions. If it disappears after reboot, inspect the actual mount and unit dependencies. Logs, mount identity and a small reproducible file operation provide better evidence than repeatedly reinstalling packages.
Keep the Working Configuration Understandable
Maintain operating-system updates, suitable free space, storage health observations and backup results at intervals appropriate to the system. Investigate resets or disconnects during larger copies; drive power, cabling and enclosure behavior can matter as much as network speed. Keep configuration backups current after a deliberate change. The instructions here describe a defined Linux configuration reviewed against Raspberry Pi’s storage documentation, Samba’s manual and systemd’s dependency model; they are not a claim of physical testing on every Pi, drive or operating-system release.
The finished first NAS should have one private share, a confirmed external mount, a service that refuses the missing-drive boot, and an independently demonstrated restore. Expand only after those outcomes are repeatable. Additional users require a separate permission design, and remote access requires its own secure architecture. A clear small setup is easier to recover than a collection of unexplained options. Preserve the known-good files and observations before adding the next feature.
