How to Mount a Drive in Linux: USB, Disk, NFS, and More

5 min read
Beginner Linux Storage Mount Disk How To

Quick Answer: List drives: lsblk. Create mount point: sudo mkdir /mnt/mydrive. Mount: sudo mount /dev/sdb1 /mnt/mydrive. Unmount: sudo umount /mnt/mydrive. Make permanent: add entry to /etc/fstab.


Find Your Drive

# List all block devices
lsblk

# Output example:
# NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
# sda      8:0    0   500G  0 disk
# ├─sda1   8:1    0   512M  0 part /boot
# └─sda2   8:2    0 499.5G  0 part /
# sdb      8:16   1    32G  0 disk
# └─sdb1   8:17   1    32G  0 part          ← USB drive, not mounted

# More detail (filesystem types)
lsblk -f

# List with sizes
fdisk -l

# Show mounted filesystems
df -h

# Show all partitions
cat /proc/partitions

Mount a Drive (Temporary)

# Create a mount point
sudo mkdir -p /mnt/mydrive

# Mount
sudo mount /dev/sdb1 /mnt/mydrive

# Access files
ls /mnt/mydrive

# Mount read-only
sudo mount -o ro /dev/sdb1 /mnt/mydrive

# Mount with specific filesystem type
sudo mount -t ntfs-3g /dev/sdb1 /mnt/mydrive
sudo mount -t vfat /dev/sdb1 /mnt/mydrive    # FAT32
sudo mount -t ext4 /dev/sdb1 /mnt/mydrive

Temporary mounts are lost on reboot.


Unmount

# Unmount
sudo umount /mnt/mydrive

# Force unmount (if busy)
sudo umount -f /mnt/mydrive

# Lazy unmount (detaches immediately, cleans up when safe)
sudo umount -l /mnt/mydrive

# Find what's using the mount (if "target is busy")
lsof +f -- /mnt/mydrive
# or
fuser -mv /mnt/mydrive

Permanent Mount (fstab)

Find UUID

# Get UUID of the partition
sudo blkid /dev/sdb1
# /dev/sdb1: UUID="a1b2c3d4-e5f6-..." TYPE="ext4"

# Or list all
sudo blkid

Edit fstab

sudo nano /etc/fstab

Add a line:

# Format: <device/UUID>  <mount point>  <type>  <options>  <dump>  <pass>
UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890  /mnt/mydrive  ext4  defaults  0  2

Common fstab Entries

# Ext4 drive
UUID=xxxx  /mnt/data       ext4   defaults                    0  2

# NTFS drive (Windows)
UUID=xxxx  /mnt/windows    ntfs   defaults,uid=1000,gid=1000  0  0

# FAT32 USB
UUID=xxxx  /mnt/usb        vfat   defaults,uid=1000,gid=1000  0  0

# NFS share
192.168.1.10:/share  /mnt/nfs  nfs  defaults,_netdev  0  0

# tmpfs (RAM disk)
tmpfs  /tmp  tmpfs  defaults,size=2G  0  0

# Mount with noatime (better performance)
UUID=xxxx  /mnt/data  ext4  defaults,noatime  0  2

Apply and Test

# Test fstab (mount everything in fstab that isn't mounted)
sudo mount -a

# If no errors, it will persist across reboots

# Verify
df -h | grep mydrive

Warning: A bad fstab entry can prevent your system from booting. Always test with mount -a before rebooting.


Format a Drive

# List drives to find the right one
lsblk

# Create a partition (interactive)
sudo fdisk /dev/sdb
# Then: n (new), p (primary), Enter (defaults), w (write)

# Format as ext4 (Linux)
sudo mkfs.ext4 /dev/sdb1

# Format as XFS
sudo mkfs.xfs /dev/sdb1

# Format as FAT32 (universal compatibility)
sudo mkfs.vfat -F 32 /dev/sdb1

# Format as NTFS (Windows compatible)
sudo mkfs.ntfs /dev/sdb1

# Format as exFAT (large files + cross-platform)
sudo mkfs.exfat /dev/sdb1

# Add a label
sudo e2label /dev/sdb1 "MyData"        # ext4
sudo ntfslabel /dev/sdb1 "MyData"      # NTFS

Filesystem Types

Filesystem Best For Max File Size Notes
ext4 Linux drives 16 TB Default Linux filesystem
XFS Large files, servers 8 EB Good for databases
Btrfs Snapshots, RAID 16 EB Advanced features
NTFS Windows drives 16 TB Read/write on Linux with ntfs-3g
FAT32 USB sticks, boot 4 GB Universal but size-limited
exFAT Large USB drives 16 EB Cross-platform, no 4GB limit

Mount NFS Share

# Install NFS client
sudo apt install nfs-common

# Mount
sudo mkdir -p /mnt/nfs
sudo mount -t nfs 192.168.1.10:/shared /mnt/nfs

# Permanent (fstab)
# Add to /etc/fstab:
192.168.1.10:/shared  /mnt/nfs  nfs  defaults,_netdev  0  0

Mount SMB/CIFS (Windows Share)

# Install CIFS utils
sudo apt install cifs-utils

# Mount
sudo mkdir -p /mnt/share
sudo mount -t cifs //192.168.1.10/shared /mnt/share -o username=sam,password=secret

# Mount with credentials file (more secure)
echo "username=sam" | sudo tee /etc/samba/credentials > /dev/null
echo "password=secret" | sudo tee -a /etc/samba/credentials > /dev/null
sudo chmod 600 /etc/samba/credentials

sudo mount -t cifs //192.168.1.10/shared /mnt/share -o credentials=/etc/samba/credentials

# Permanent (fstab)
//192.168.1.10/shared  /mnt/share  cifs  credentials=/etc/samba/credentials,_netdev  0  0

Mount ISO/Disk Image

# Mount an ISO
sudo mkdir -p /mnt/iso
sudo mount -o loop image.iso /mnt/iso

# Mount a disk image
sudo mount -o loop disk.img /mnt/disk

Swap

# Create swap file
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# Make permanent (add to fstab)
echo "/swapfile  none  swap  sw  0  0" | sudo tee -a /etc/fstab

# Check swap
free -h
swapon --show

# Disable swap
sudo swapoff /swapfile

Troubleshooting

Problem Fix
mount: wrong fs type Specify type: mount -t ntfs, or install driver: apt install ntfs-3g
target is busy Close files/terminals using the mount. Check with lsof +f -- /mnt/path
no such device Drive not detected. Check lsblk and cable
Permission denied on mounted drive Add uid=1000,gid=1000 to mount options
Drive not showing in lsblk Try sudo fdisk -l. Check physical connection
Can't write to NTFS Install ntfs-3g: sudo apt install ntfs-3g
fstab error on boot Boot to recovery mode, fix /etc/fstab
mount: special device does not exist UUID wrong. Re-check with blkid
# Check filesystem for errors
sudo fsck /dev/sdb1           # DON'T run on mounted filesystems

# Check disk health
sudo smartctl -a /dev/sdb     # Needs smartmontools

# Disk usage by directory
du -sh /mnt/mydrive/*

Quick Reference

Command What It Does
lsblk List drives and partitions
lsblk -f List with filesystem types
sudo blkid Show UUIDs
df -h Show mounted filesystem usage
sudo mount /dev/sdb1 /mnt/drive Mount drive
sudo umount /mnt/drive Unmount
sudo mount -a Mount all fstab entries
sudo mkfs.ext4 /dev/sdb1 Format as ext4
sudo fdisk /dev/sdb Partition a drive

Related Guides