# How to Mount and Unmount a Hard Drive in Ubuntu Linux
This guide walks you through identifying, fixing, mounting, and unmounting a hard drive or USB with an NTFS file system on Ubuntu.
---
## Prerequisites
- A connected external or internal hard drive (e.g., `/dev/sdb2`)
- Admin (sudo) access on Ubuntu
- NTFS-formatted drive (common for Windows drives)
---
### Step 1: Identify the Drive
Open a terminal and list connected drives:
```bash
sudo fdisk -l
```
Look for the correct partition (e.g., /dev/sdb2) based on size and type.
### Step 2: Check Drive Info
Use `blkid` to confirm the filesystem and UUID:
```bash
sudo blkid /dev/sdb2
```
You should see something like:
```bash
/dev/sdb2: UUID="YOUR UUID WILL APPEAR HERE" TYPE="ntfs" ...
```
### 🛠Step 3: Fix Errors (Optional but Recommended)
Run `ntfsfix` to repair common NTFS issues:
```bash
sudo ntfsfix /dev/sdb2
```
You should see output like:
```bash
Mounting volume... OK
Processing of $MFT and $MFTMirr completed successfully.
NTFS partition /dev/sdb2 was processed successfully.
```
### Step 4: Create a Mount Point
Choose where to mount the drive:
```bash
sudo mkdir -p /mnt/sdb2
```
### 📥 Step 5: Mount the Drive
Mount it using the NTFS file system:
```bash
sudo mount -t ntfs /dev/sdb2 /mnt/sdb2
```
Check if it's working:
```bash
ls /mnt/sdb2
```
### (Optional) Auto-Mount the Drive at Boot
#### Get UUID:
```bash
sudo blkid /dev/sdb2
```
### Edit fstab:
```bash
sudo nano /etc/fstab
```
Add this line(replace UUID iwth your actual one):
```fstab
UUID="YOUR UUID NUMBER HERE" /mnt/sdb2 ntfs defaults 0 0
```
Save and exit. This mounts the drive automatically at boot.
### Step 6: Unmount the Drive
When you're done:
```bash
sudo umount /mnt/sdb2
```
#### NB: You can’t unmount a drive while you're inside it `(cd /mnt/sdb2)`. Always cd away from the mount point before unmounting.
#### Notes
1. For FAT32 drives, use `-t vfat` instead of `-t ntfs`
2. For ext4 Linux partitions, omit the `-t` flag or use `-t ext4`
3. You can view mounted drives with `lsblk` or `df -h
Mounting and unmounting drives in Ubuntu is straightforward once you're familiar with the tools. This process helps you access and back up data from external or Windows drives on your Linux machine. Thank you!