# 🧷 Mounting an External USB Hard Drive on Debian

# 🧷 Mounting an External USB Hard Drive on Debian

## 📋 Overview

<span style="white-space: pre-wrap;">This guide outlines how to properly identify, mount, and persistently configure an external USB hard drive on a Debian-based system. It is particularly useful for setups involving backup containers like </span>`<span class="editor-theme-code">urbackup</span>`<span style="white-space: pre-wrap;"> or media/file storage solutions.</span>

---

## 🔍 Step 1: Identify the USB Drive

```
lsblk
```

<span style="white-space: pre-wrap;">Look for a device (e.g., </span>`<span class="editor-theme-code">/dev/sdb1</span>`) with the expected size and no mount point.

```
sudo blkid /dev/sdb1
```

This confirms the filesystem type and gets the UUID (used for persistent mounting).

---

## 💾 Step 2: Install Required NTFS Support

If the drive is formatted as NTFS (common for Windows drives), install the NTFS driver:

```
sudo apt update
sudo apt install ntfs-3g
```

**Note:**<span style="white-space: pre-wrap;"> Do </span><u>not</u><span style="white-space: pre-wrap;"> install </span>`<span class="editor-theme-code">fuse</span>`<span style="white-space: pre-wrap;"> on Debian 12 (Bookworm); it conflicts with </span>`<span class="editor-theme-code">fuse3</span>`.

---

## 📁 Step 3: Create a Mount Point

```
sudo mkdir -p /mnt/usbbackup
```

---

## 📝 Step 4: Configure /etc/fstab

Edit the fstab file to auto-mount the drive at boot:

```
sudo nano /etc/fstab
```

<span style="white-space: pre-wrap;">Add this line (replace UUID with yours from </span>`<span class="editor-theme-code">blkid</span>`):

```
UUID=5E74F4D874F4B43D  /mnt/usbbackup  ntfs-3g  defaults,noatime,nofail,uid=1001,gid=1001,umask=0022,allow_other  0  2
```

<table id="bkmrk-optiondescriptionntf"><colgroup><col></col><col></col></colgroup><tbody><tr><th>Option

</th><th>Description

</th></tr><tr><td>`<span class="editor-theme-code">ntfs-3g</span>`

</td><td>NTFS filesystem driver with write support

</td></tr><tr><td>`<span class="editor-theme-code">noatime</span>`

</td><td>Improves performance by disabling access-time updates

</td></tr><tr><td>`<span class="editor-theme-code">nofail</span>`

</td><td>Allows boot to continue if the drive is missing

</td></tr><tr><td>`<span class="editor-theme-code">uid/gid</span>`

</td><td>Sets ownership for consistent Docker access

</td></tr><tr><td>`<span class="editor-theme-code">umask=0022</span>`

</td><td><span style="white-space: pre-wrap;">Applies </span>

`<span class="editor-theme-code">rwxr-xr-x</span>`

<span style="white-space: pre-wrap;"> permissions</span>

</td></tr><tr><td>`<span class="editor-theme-code">allow_other</span>`

</td><td>Permits non-root users to access the mount

</td></tr></tbody></table>

---

## 🧪 Step 5: Mount and Verify

```
sudo systemctl daemon-reexec
sudo mount -a
```

Check if it mounted successfully:

```
df -h | grep usbbackup
```

Confirm correct permissions:

```
ls -ld /mnt/usbbackup
```

---

## ✅ Example Output

```
/dev/sdb1 on /mnt/usbbackup type fuseblk (rw,nosuid,nodev,noatime,allow_other,blksize=4096)
```

---

## 🛠️ Troubleshooting

- **Wrong filesystem type?**  
    <span style="white-space: pre-wrap;">Make sure you used </span>`<span class="editor-theme-code">ntfs-3g</span>`<span style="white-space: pre-wrap;"> and not </span>`<span class="editor-theme-code">ext4</span>`<span style="white-space: pre-wrap;"> in your fstab line.</span>
- **"Bad superblock" or mount error?**  
    <span style="white-space: pre-wrap;">Use </span>`<span class="editor-theme-code">dmesg | tail -30</span>`<span style="white-space: pre-wrap;"> to check for detailed kernel messages.</span>
- **Permissions issue in Docker?**  
    Ensure the Docker container’s UID/GID matches the mount options.

---

## 📦 Related

- <span style="white-space: pre-wrap;">To mount an </span>`<span class="editor-theme-code">ext4</span>`<span style="white-space: pre-wrap;"> drive, change </span>`<span class="editor-theme-code">ntfs-3g</span>`<span style="white-space: pre-wrap;"> to </span>`<span class="editor-theme-code">ext4</span>`<span style="white-space: pre-wrap;"> and remove </span>`<span class="editor-theme-code">uid/gid/umask</span>`<span style="white-space: pre-wrap;"> options.</span>
- To temporarily mount a USB without fstab:  
    ```
    sudo mount -t ntfs-3g /dev/sdb1 /mnt/usbbackup
    ```