LINUX, FOSS AND LIBRARY TECHNOLOGY ENTHUSIAST

Wednesday, August 20, 2025

How to Mount an External Drive on Debian/Ubuntu and Share It with Samba

0 comments
Using an external hard disk with your Linux machine is a simple way to expand storage, set up backups, or create a shared media drive. If you’re running a home server or want to make the disk accessible to other devices (Windows, Linux, macOS, or even smart TVs), combining Linux mounting with Samba file sharing is a reliable solution.

In this post, I’ll Walk you through the complete process of:

Mounting an external HDD on Linux (Debian-based system).

Setting up Samba to share the disk across your network.

Identify the External HDD

First, connect your external hard disk to the Linux machine. Then check the available disks:

lsblk

Look for your external HDD (e.g., /dev/sdb1).

Create a Mount Point

We need a directory where the HDD will be mounted. For example:

sudo mkdir -p /mnt/pibox_storage

'pibox_storage' is the name I have given to my external drive

Mount the HDD on Boot

To make sure the HDD mounts automatically after reboot:

Find its UUID:

sudo blkid

Example output:

/dev/sdb1: UUID="1234-ABCD" TYPE="ext4"

Edit /etc/fstab:

sudo nano /etc/fstab

Add a line (replace UUID accordingly):

For EXT4:

UUID=xxxx-xxxx-xxxx /mnt/pibox_storage ext4 defaults,nofail,x-systemd.device-timeout=10 0 2

For NTFS:

UUID=xxxx-xxxx-xxxx /mnt/pibox_storage ntfs-3g defaults,nofail,x-systemd.device-timeout=10 0 2

Save and run:

This ensures:

  • nofail → the system still boots if the USB drive is unplugged.
  • x-systemd.device-timeout=10 → boot won't pause for a long time waiting for the drive.

After editing, run:

sudo systemctl daemon-reload
sudo mount -a

Install and Configure Samba

Now let’s set up Samba so that the external HDD can be shared across your local network.

Install Samba:

sudo apt update && sudo apt upgrade -y
sudo apt install samba samba-common-bin -y

Edit the Samba configuration file:

sudo nano /etc/samba/smb.conf

Add at the bottom:

[pibox_storage]
path = /mnt/pibox_storage
browseable = yes
read only = no
writeable = yes
guest ok = yes
force user = yourusername
create mask = 0664
directory mask = 0775

Restart Samba:

sudo systemctl restart smbd

Create a Samba user (replace yourusername with your Linux username):

sudo smbpasswd -a yourusername

Restart Samba again:

sudo systemctl restart smbd

Set proper permissions for the HDD:

sudo chmod -R 0777 /mnt/pibox_storage
sudo chown -R $USER:$USER /mnt/pibox_storage

Access the Drive from Other Devices

On Windows, open \\192.168.29.2\pibox_storage in File Explorer.

On Linux, use:

smb://192.168.29.2/pibox_storage

On macOS, go to Finder → Connect to Server → enter:

smb://192.168.29.2/pibox_storage

With this setup, your external HDD is permanently mounted on Linux and shared via Samba across your home or office network. You can now use it for:

  • Media storage (movies, music, photos)
  • Backups from multiple machines
  • Centralized file sharing for collaboration

This method effectively transforms any Linux machine + external HDD into a mini NAS (Network Attached Storage).

NB: If the HDD is not formatted with EXT4 do it first the mount

To format it (EXT4 filesystem)

sudo mkfs.ext4 -L DATA /dev/sdb1

No comments:

Post a Comment