How to Add an HDD to Ubuntu – A Step‑by‑Step Guide
Prologue – Meet Pavel
Pavel just bought a second hard‑drive (HDD) to store movies, backups, and a few old projects. The machine already runs Ubuntu 24.04 LTS, and Pavel wants the new disk to appear automatically every time the computer boots.
Instead of “copy‑and‑paste this table of commands”, we’ll walk through Pavel’s adventure, explaining why each command matters, what the different mount points (/mnt vs /media) mean, and how the two “secret” files—/etc/fstab and /etc/mtab—keep the system honest.
1. The New Disk Arrives
Pavel plugs the HDD into the spare SATA port, powers on the PC, and opens a terminal. The first question is:
“Which device name did the kernel give to my new drive?”
Linux represents every block device (hard‑drive, USB stick, SSD) as a file under /dev. The names can be /dev/sda, /dev/sdb, … for the whole disk, and /dev/sda1, /dev/sda2, … for its partitions.
1.1 List the devices
sudo lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINT
What Alex sees:
NAME SIZE FSTYPE LABEL MOUNTPOINT
sda 500G ext4 /
├─sda1 500G ext4 /
sdb 200G ntfs MyHDD
The new drive shows up as /dev/sdb with a single NTFS partition /dev/sdb1 (label “MyHDD”).
Why lsblk? It reads the kernel’s view of block devices, so you see exactly what the system knows right now.2. A Better Way to Identify the Disk: UUID
Device names (/dev/sdb1) are fragile. If you later plug in a USB stick, the kernel might rename the HDD to /dev/sdc. To avoid this, we use the Universally Unique Identifier (UUID) that each filesystem writes on creation. UUIDs never change unless you re‑format.
2.1 Ask the system for UUIDs
sudo blkid /dev/sdb1
Result (example):
/dev/sdb1: UUID="3C5E-1A2B" TYPE="ntfs" PARTUUID="d4e5f6g7-01"
Pavel copies the UUID 3C5E-1A2B – that will be the key in the fstab file.
Tip: If you have many disks, just run sudo blkid without arguments; the output will list every block device and its UUID.3. Where Should the Disk Appear? /mnt vs /media
Linux does not have a single “magic” place for external storage. It has conventions:
| Directory | Typical use | Who creates it? | Example |
|---|---|---|---|
/mnt |
Manual mount points for system administrators. Think “I’m putting something here on purpose.” | You (the admin) | /mnt/backup |
/media |
Automount points used by the desktop environment (GNOME, KDE) for removable media (USB sticks, CDs, external HDDs). | System / udev | /media/alex/MyHDD |
Why Pavel chooses /mnt
Alex wants a stable, predictable path that never changes when the desktop auto‑mounts the same drive elsewhere. /mnt is perfect for “permanent” storage that the user explicitly configures.
4. Preparing the Mount Point
A mount point is simply an empty directory where the filesystem will be attached.
sudo mkdir -p /mnt/myhdd
-pcreates any missing parent directories (not needed here, but harmless).- The directory must be empty; otherwise, the mount will hide its contents.
Check:ls -la /mnt/myhddshould show only.and...
5. Backing Up the Map (/etc/fstab)
/etc/fstab is the permanent roadmap that tells the kernel how to mount filesystems at boot time. A typo can prevent the system from booting, so Pavel makes a safety copy.
sudo cp /etc/fstab /etc/fstab.bak
Now the original file is safely stored as fstab.bak. If something goes wrong, Alex can restore it with:
sudo cp /etc/fstab.bak /etc/fstab
6. Writing the New Entry
Open the file with a comfortable editor. Pavel prefers vim because it’s simple.
sudo vim /etc/fstab
At the bottom of the file Pavel adds a line (the exact order of columns matters):
UUID=3C5E-1A2B /mnt/myhdd ntfs defaults,uid=1000,gid=1000,dmask=027,fmask=137 0 0
Breaking down the fields
| Column | Meaning | Alex’s choice |
|---|---|---|
| UUID | Unique identifier of the partition | UUID=3C5E-1A2B |
| Mount point | Where the filesystem appears | /mnt/myhdd |
| Filesystem type | ext4, ntfs, xfs, … |
ntfs (because the disk is formatted for Windows) |
| Mount options | A comma‑separated list. defaults gives read‑write, auto, suid, dev, exec, sync, async, and noatime. For NTFS we also set ownership (uid, gid) and permissions masks (dmask for directories, fmask for files). |
defaults, |
| dump | Used by the legacy dump backup utility; 0 disables it. |
0 |
| fsck order | When to run filesystem checks at boot. 0 = never (NTFS cannot be checked by fsck). |
0 |
Why not use /dev/sdb1? Because if the kernel ever decides to rename the device, the entry would break. UUIDs stay constant.When done, Pavel presses ESC, to exit the Edit mode, then :wq and Enter to write the file and exit.
7. Testing the New Roadmap
Before rebooting, Pavel can ask the system to mount everything listed in fstab that isn’t already mounted.
sudo mount -a
If the command returns silently, the entry is syntactically correct. To be sure, Pavel checks:
df -h | grep myhdd
Result:
/dev/sdb1 200G 12G 188G 6% /mnt/myhdd
Success! The HDD is now reachable at /mnt/myhdd.
Troubleshooting tip: Ifmount -aprints an error, re‑openfstaband double‑check spelling, spaces, and the UUID.
8. The Live View: /etc/mtab
While fstab is a static configuration file, Linux also maintains a dynamic view of what is currently mounted: /etc/mtab. Historically, this was a plain text file that the mount command updated, but modern systems often make it a symlink to /proc/self/mounts, which the kernel populates on the fly.
8.1 Peek at the current mounts
cat /etc/mtab | grep myhdd
Output (example):
/dev/sdb1 /mnt/myhdd ntfs rw,relatime,uid=1000,gid=1000,dmask=027,fmask=137 0 0
- The device name (
/dev/sdb1) appears here, even thoughfstabused the UUID. - The options match those we wrote in
fstab. - This file changes instantly when you mount or unmount something; it is not meant to be edited manually.
Takeaway:fstabtells the system what to mount;mtabtells you what is currently mounted.
9. Making the HDD Friendly for Everyone
Pavel’s HDD is NTFS, a Windows filesystem. By default, only the user with UID 1000 (Pavel) can write there because of the uid=1000,gid=1000 options. If Pavel wants all local users to read/write, they could change the options:
defaults,uid=0,gid=0,umask=000
or, for a more controlled approach, create a group (e.g., hddusers) and set gid=1001 and appropriate dmask/fmask. This is an optional refinement that can be added later.
10. The Grand Finale – Reboot Confirmation
A final test is to reboot the machine and see if the drive mounts automatically.
sudo reboot
After the system comes back up, Alex runs:
mount | grep myhdd
and sees the same line as before, confirming the fstab entry worked.
Epilogue – Recap of the Journey
| Step | What Alex did | Why it matters |
|---|---|---|
| 1. Identify the device | lsblk, blkid |
Know the exact partition and its UUID |
| 2. Choose a mount point | mkdir /mnt/myhdd |
Provides a stable, admin‑controlled path |
3. Back up fstab |
cp /etc/fstab /etc/fstab.bak |
Prevents boot‑failure disasters |
4. Edit fstab |
Add a line using the UUID | Makes the mount persistent across reboots |
5. Test with mount -a |
Verify syntax | Catch errors before reboot |
6. Confirm with df / mtab |
See that it’s really mounted | Guarantees the system sees it |
| 7. Reboot | sudo reboot |
Final proof of a successful permanent mount |
Bonus: Quick Reference Cheat‑Sheet (for Pavel’s future self)
# 1. Find UUID
sudo blkid /dev/sdb1
# 2. Create mount point
sudo mkdir -p /mnt/myhdd
# 3. Backup fstab
sudo cp /etc/fstab /etc/fstab.bak
# 4. Add entry (use your own UUID and options)
# Open with your favourite editor
sudo nano /etc/fstab
# Append:
# UUID=YOUR_UUID /mnt/myhdd ntfs defaults,uid=1000,gid=1000,dmask=027,fmask=137 0 0
# 5. Test
sudo mount -a
df -h | grep myhdd
# 6. Check live mounts
cat /etc/mtab | grep myhdd # or: grep myhdd /proc/self/mounts
# 7. Reboot to confirm
sudo reboot
And that’s the story of how Pavel turned an unused HDD into a reliable, lways‑available storage vault on Ubuntu.
May your own drives mount smoothly, and may your fstab always be backed up!