Sharing Second Drive Using Samba on Ubuntu 22.04.3: A Step-by-Step Guide

Abstract: Resolve inability to access a second drive on Ubuntu 22.04.3 over the network by configuring Samba sharing with persistent mounting and secure permissions.

Created: 2026-07-28 by
To share a second drive using Samba on Ubuntu 22.04.3, you must install the samba and smbclient packages, mount your additional storage device to a specific directory, and then configure the /etc/samba/smb.conf file with the appropriate path and security settings. After restarting the Samba services, you can access the shared folder from Windows or other Linux clients using the server's IP address. This process ensures that your data is accessible across your local network while maintaining proper permissions and security controls for your Ubuntu system.

Prerequisites and Installation

Before configuring Samba, ensure that your Ubuntu 22.04.3 system has the necessary software installed. You will need administrative privileges to modify system configurations and install new packages. Open your terminal and update your package list to ensure you are installing the latest versions of the required tools.

sudo apt update
sudo apt upgrade

Next, install the Samba suite and the client utilities. The server package provides the daemon and configuration files, while the client utilities allow you to test connections from the command line. Run the following command to install both:

sudo apt install samba smbclient

Once the installation completes, verify that the Samba service is installed correctly by checking its version. This confirms that the binaries are available in your system path. You can do this by running smbd --version. If the command returns a version number, the installation was successful. If you encounter permission errors, ensure you are running the commands with sudo.

Preparing the Second Drive

The next critical step is to prepare the second drive so that it is mounted at boot and accessible by the Samba service. First, identify the device name of your second drive using the lsblk command. Look for the drive that is not your root partition, typically labeled as sdb, sdc, or similar.

lsblk

Create a mount point directory where the drive will be accessible. A common convention is to create a directory under /mnt or /media. For example, you might create a directory named shared_drive:

sudo mkdir -p /mnt/shared_drive

You should now mount the drive manually to test that it works. Use the mount command with the device identifier. If your drive is formatted as ext4, the command would look like this:

sudo mount /dev/sdb1 /mnt/shared_drive

To ensure the drive mounts automatically every time the system boots, you need to add an entry to the /etc/fstab file. Open the file with a text editor like nano or vim:

sudo nano /etc/fstab

Add a line at the end of the file specifying the device, mount point, filesystem type, and options. For an ext4 filesystem, use:

/dev/sdb1 /mnt/shared_drive ext4 defaults 0 2

Save the file and exit the editor. It is highly recommended to check your fstab syntax before rebooting to avoid boot failures. You can do this by running sudo findmnt --verify. If there are no errors, you can proceed to set up the Samba configuration.

Configuring Samba

Samba configuration is stored in the /etc/samba/smb.conf file. Before editing, it is wise to create a backup of the original configuration file. This allows you to restore the default settings if something goes wrong.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

Open the main configuration file for editing:

sudo nano /etc/samba/smb.conf

At the bottom of the file, add a new section defining your share. The section header should be enclosed in square brackets and serve as the share name visible to network clients. Inside the section, specify the path to your mounted drive, whether guests are allowed, and the writable status.

[SharedDrive]
   comment = Shared Second Drive
   path = /mnt/shared_drive
   browseable = yes
   read only = no
   guest ok = no
   create mask = 0775
   directory mask = 0775

In this configuration, guest ok = no ensures that users must authenticate to access the share, which is crucial for security. The create mask and directory mask settings define the permissions for newly created files and directories, allowing group members to read and write.

If you prefer to allow public access without authentication, you can change guest ok to yes and remove user-specific restrictions. However, for most home and small business environments, authenticated access is safer. After saving the changes, validate the configuration file syntax by running:

testparm

This tool checks for common errors in the smb.conf file and displays the effective configuration. If testparm reports no errors, your configuration is syntactically correct.

Setting Up Users and Permissions

Since we configured the share to require authentication, you must create a Samba user. This user does not need to have a shell account on the system, but they must exist in the Samba password database. First, ensure the user exists in the Linux system:

sudo adduser sambashareuser

Then, add this user to the Samba database. You will be prompted to enter a new Samba password:

sudo smbpasswd -a sambashareuser

Ensure that the Linux user has read and write permissions to the mounted directory. You can change the ownership of the mount point to the Samba user:

sudo chown -R sambashareuser:sambashareuser /mnt/shared_drive

Additionally, adjust the permissions to ensure the user can write to the drive:

sudo chmod -R 775 /mnt/shared_drive

Finally, restart the Samba services to apply all changes:

sudo systemctl restart smbd
sudo systemctl restart nmbd

You can verify that the services are running by checking their status:

sudo systemctl status smbd

For more detailed troubleshooting regarding access issues, refer to our guide on Troubleshooting Samba Share Access Issues on Ubuntu 22 LTS and Windows 10. Additionally, if you plan to manage multiple shares, understanding Resolving Samba Permissions Inconsistency Across Multiple Systems is essential for maintaining consistent access rights.

Connecting from Client Devices

Once the server is configured and running, you can connect from other devices on your network. On a Windows machine, open File Explorer and enter the UNC path to the share in the address bar: \\IP_ADDRESS_OF_UBUNTU\SharedDrive. Replace IP_ADDRESS_OF_UBUNTU with the actual IP address of your Ubuntu server.

You will be prompted for the username and password you created earlier. Enter these credentials to gain access to the shared drive. On Linux clients, you can mount the share using the cifs-utils package and the mount command with the vers=3.0 option for better compatibility.

If you experience connectivity issues, ensure that the firewall on the Ubuntu server allows SMB traffic. By default, Ubuntu uses ufw (Uncomplicated Firewall). To allow Samba traffic, run:

sudo ufw allow samba

This command opens the necessary ports for Samba communication. After applying the firewall rule, try connecting again. If problems persist, check the Samba logs located in /var/log/samba/ for detailed error messages.

Frequently Asked Questions

Why can't I see the Samba share on my Windows network?

Windows often relies on NetBIOS name resolution, which may not work reliably on modern networks. Instead of browsing the network neighborhood, directly enter the UNC path using the server's IP address in the File Explorer address bar. Ensure that the nmbd service is running on the Ubuntu server and that your Windows machine is on the same subnet.

How do I change the Samba password for a user?

You can change the Samba password at any time by running the command sudo smbpasswd username, replacing username with the actual Samba user name. This command will prompt you to enter the new password twice. Note that this only changes the Samba password; it does not affect the Linux system password unless you also update it separately.

Can I share the drive with read-only access?

Yes, you can restrict write access by changing the read only directive in the smb.conf file to yes. Alternatively, you can keep read only = no but set write list to specific users who are allowed to modify files, while others will have read-only access. This provides granular control over permissions.

What should I do if the drive unmounts after a reboot?

If the drive fails to mount automatically, check the /etc/fstab file for syntax errors. Use the findmnt --verify command to validate the entries. Also, ensure that the device identifier (like /dev/sdb1) has not changed. Using UUIDs in fstab is more reliable than device names because UUIDs remain constant even if disk ordering changes.

Is it safe to enable guest access on my Samba share?

Enabling guest access allows anyone on the network to read or write to the share without a password, which poses significant security risks. It is generally recommended to disable guest access (guest ok = no) and require authentication for all users. If you must use guest access, ensure the directory permissions are restricted to prevent accidental deletion or modification of important files.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More