cifs-utils package, creating a dedicated directory, and configuring /etc/fstab to ensure the network volume is automatically mounted at boot. By setting appropriate permissions and using the guest or specific user credentials, you allow multiple users or services to access the media files seamlessly through the shared path.
Understanding the Network Storage Architecture
A WD Home Drive operates as a network-attached storage (NAS) device accessible via the SMB/CIFS protocol over your local area network. Unlike a USB hard drive that appears as a physical block device like /dev/sdb1, a network drive exists only when connected to the network stack. Attempting to format or partition it directly from the Linux command line will fail because there is no local filesystem structure exposed to the kernel without first establishing a network connection.
The goal is to create a local mount point on your Ubuntu server that acts as a gateway to this remote storage. When you save a file to this local directory, the operating system transparently sends the data over the network to the WD drive. This approach ensures that your Ubuntu 20.04 server can manage the photos just as if they were stored locally, while retaining the benefits of centralized network storage.
Prerequisites and Initial Setup
Before configuring the mount, ensure your server has network connectivity to the WD Home Drive. You should know the IP address of the WD drive and the name of the specific share containing your photos. If you have not yet established basic connectivity to your Ubuntu server, refer to our guide on Unable to SSH into Ubuntu Server: Log in Locally First to ensure you can access the terminal effectively.
You will need administrative privileges to install software and modify system configuration files. Open your terminal and update your package lists to ensure you have the latest versions of the required tools:
sudo apt update
sudo apt upgrade -y
Next, install the necessary utilities for mounting CIFS shares. The cifs-utils package provides the mount.cifs command-line tool required by Linux to communicate with Windows-style network shares:
sudo apt install cifs-utils -y
Creating the Mount Point and Permissions
Choose a location on your Ubuntu server where the photos will be accessible. A common convention is to use /mnt/wd_photos. Create this directory using the following command:
sudo mkdir -p /mnt/wd_photos
For a PUBLIC shared folder, you typically want all users on the system to be able to read and write to this directory. Set the ownership to the root user initially, but adjust permissions so that others can access it. For example, to allow full access to everyone:
sudo chmod 777 /mnt/wd_photos
Alternatively, if you have a specific group for media management, change the group ownership instead of using world-writable permissions, which is generally less secure for production environments.
Configuring the fstab Entry
The most robust way to handle network mounts is through /etc/fstab. This file tells the system how to mount drives during the boot process. Editing this file incorrectly can prevent your system from booting, so proceed with caution.
Open the fstab file with a text editor:
sudo nano /etc/fstab
Add a new line at the end of the file. The syntax for a CIFS mount is:
//WD_IP_ADDRESS/SHARE_NAME /mnt/wd_photos cifs credentials=/etc/samba/credentials,iocharset=utf8,file_mode=0777,dir_mode=0777,nofail,x-systemd.automount 0 0
Replace WD_IP_ADDRESS with the actual IP of your WD Home Drive and SHARE_NAME with the name of the public folder. The nofail option ensures the system continues to boot even if the network drive is temporarily unavailable. The x-systemd.automount option improves performance by only connecting when the directory is accessed.
If the WD Home Drive requires authentication, create a credentials file:
sudo nano /etc/samba/credentials
Inside this file, add your username and password:
username=your_username
password=your_password
Secure this file so only root can read it:
sudo chmod 600 /etc/samba/credentials
If the share is truly public and allows guest access, you can omit the credentials parameter and instead use guest in the options list. However, many WD drives require at least a generic username for security reasons.
Testing and Verifying the Connection
Once the entry is saved in /etc/fstab, test the configuration without rebooting. Run the following command to attempt mounting all filesystems listed in fstab:
sudo mount -a
If there are no error messages, the mount was successful. Verify that the drive is mounted by checking the disk usage:
df -h | grep wd_photos
You should see the WD Home Drive listed with its available space. Now, try creating a test file in the directory:
touch /mnt/wd_photos/test_photo.jpg
If the file is created successfully, your setup is complete. You can now move your existing photo library to this directory. Ensure that any applications or services accessing these photos are configured to look at /mnt/wd_photos rather than their previous local paths.
Troubleshooting Common Issues
If the mount fails, check the system logs for detailed error messages:
sudo dmesg | tail -n 20
Common issues include incorrect IP addresses, firewall restrictions blocking port 445 (SMB), or mismatched SMB protocol versions. Older WD drives may require specifying the version in the fstab options, such as vers=1.0 or vers=2.0.
Additionally, ensure that your network interface is stable. If your server loses connection randomly, refer to resources on Ubuntu Linux Server Randomly Loses Connection to diagnose underlying network instability that might affect persistent mounts.
Frequently Asked Questions
Can I use NFS instead of CIFS for better performance?
NFS (Network File System) generally offers better performance for Linux-to-Linux sharing, but WD Home Drives typically only support SMB/CIFS out of the box. Unless you have installed third-party firmware on the WD drive that enables NFS, CIFS is the standard and most reliable choice for this hardware.
What happens if the WD Home Drive is turned off?
With the nofail option in /fstab, your Ubuntu server will boot normally even if the drive is offline. However, attempts to access the /mnt/wd_photos directory will result in an error until the drive is powered back on and connected to the network.
How do I change the permissions after mounting?
Permissions set in /etc/fstab using file_mode and dir_mode apply to all newly created files. To change permissions of existing files, use the standard chmod and chown commands on the local mount point, which will propagate changes to the network share.
Is it safe to store sensitive photos on this setup?
SMB traffic is not encrypted by default, meaning data travels across your network in plaintext. For sensitive photos, consider enabling encryption on the WD drive if supported, or use a VPN tunnel between the server and the NAS to encrypt the connection.
Why does my mount disappear after a reboot?
This usually indicates a typo in the /etc/fstab file or a failure in the network connection during boot. Check the syntax carefully, ensure the IP address is static, and verify that the network service starts before the mount attempt by using the x-systemd.automount directive.