All writing
Linux26 Aug 20252 min read

Mount and Share an external disk drive in Linux Ubuntu

Let's see how to mount and share an external disk drive in Linux Ubuntu, so we can use it as a NAS

Replace /dev/sdX1 with your device (e.g., /dev/sdb1).

  1. Plug in the disk.

    • Just connect the drive via USB. Linux will expose it as a block device under /dev (e.g., /dev/sdb). “Block” means data is read/written in fixed‑size blocks.

  2. Run the following command to see the disks & filesystems.

sudo lsblk -f
  1. Run the following command to create a mount point.

sudo mkdir -p /mnt/external
  1. You can also add support for NTFS and exFAT by running the following commands

sudo apt update && sudo apt install -y ntfs-3g exfat-fuse exfatprogs
  1. Now, let's mount the disk to the mounting point that we created in step 3

    • If your partition is in ext4 format:

sudo mount /dev/sdX1 /mnt/external
  • If your partition is in ntfs format:

sudo mount -t ntfs-3g -o uid=$(id -u),gid=$(id -g) /dev/sdX1 /mnt/external
  • If your partition is in exfat format:

udo mount -t exfat -o uid=$(id -u),gid=$(id -g) /dev/sdX1 /mnt/external
  1. Verify the mount with diskfree command

df -h | grep /mnt/external
  1. Now we need to auto-mount the external disks so we don't have to mount the disk every time. In order to do that, let's get the UUID first with the following command

sudo blkid /dev/sdX1 
  1. Open the /etc/fstab with Nano and add a line at the bottom, replace the UUID we got from step 7

sudo nano /etc/fstab
  • If your partition is in ext4 format:

UUID=YOUR-UUID /mnt/external ext4 defaults 0 2
  • If your partition is in ntfs format:

UUID=YOUR-UUID /mnt/external ntfs-3g defaults,uid=1000,gid=1000,umask=022 0 0
  • If your partition is in exfat format:

UUID=YOUR-UUID /mnt/external exfat defaults,uid=1000,gid=1000,umask=022 0 0
  1. Let's mount all filesystems mentioned in fstab to ensure our configuration is correct. You should see no error after running the following command.

sudo mount -a

Share the Disk over the Network (Samba)

  1. We need to install Samba first. Samba implements Microsoft’s SMB/CIFS protocol

sudo apt install -y samba
  1. Ensure you own the mount path

sudo chown -R $USER:$USER /mnt/external
  1. Create a share

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
printf "\n[external]\n path = /mnt/external\n browseable = yes\n read only = no\n create mask = 0644\n directory mask = 0755\n" | sudo tee -a /etc/samba/smb.conf
  1. Add a Samba password for your user

sudo smbpasswd -a $USER
  1. Restart service & open firewall

sudo systemctl restart smbd
sudo ufw allow 'Samba' # if UFW is enabled

Discussion · 00 Open

No comments on this one yet.

Leave a comment

Posting needs an account, and I approve each comment before it appears.