Last modified: June 06, 2026

This article is written in: πŸ‡ΊπŸ‡Έ

Mounting and Unmounting

In Linux, mounting is the process of making a filesystem available somewhere inside the main directory tree.

This can feel unusual if you come from Windows. In Windows, storage devices usually appear as separate drive letters, such as:

C:\
D:\
E:\

Linux works differently. Linux has one main directory tree that starts at:

/

Storage devices, partitions, USB drives, ISO files, and network shares are attached somewhere inside that tree.

For example, a USB drive might be mounted at:

/mnt/external

or:

/media/user/USB_DRIVE

Once mounted, the device looks like an ordinary directory. You can use commands such as cd, ls, cp, mv, and rm to work with its files.

What Can Be Mounted

Many different things can be mounted in Linux.

Common examples include:

Network filesystems can also be mounted, such as:

NFS        common on Unix/Linux networks
SMB/CIFS   common for Windows file shares

Linux also mounts special pseudo-filesystems that do not represent normal storage devices. These include:

/proc
/sys
/dev
/run

These provide information about processes, hardware, devices, and runtime system state.

Required and Optional Mounts

Some filesystems are required for the system to work.

For example:

/       root filesystem
/proc   process and kernel information
/sys    hardware and kernel information
/dev    device files

These are usually mounted automatically during boot.

Other filesystems are optional. These include USB drives, extra partitions, external disks, ISO images, and network shares.

Optional filesystems may be mounted manually by the user or automatically by the desktop environment.

Mounting on Desktop Linux

On desktop distributions such as Ubuntu, Fedora, or Linux Mint, removable devices are often mounted automatically.

For example, when you plug in a USB drive, the file manager may automatically mount it under something like:

/media/username/USB_NAME

This is convenient for normal desktop use.

Manual mounting is still useful when:

Understanding Mounting

Mounting attaches a filesystem to a directory.

That directory is called a mount point.

Before mounting, the directory is just an ordinary directory. After mounting, the contents of the mounted filesystem appear there.

Linux Directory Tree Before Mounting:

/
β”œβ”€β”€ bin
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”‚   └── user
β”œβ”€β”€ mnt
β”œβ”€β”€ usr
└── var

Now suppose a USB drive partition is available as:

/dev/sdb1

and we mount it at:

/mnt/external

After mounting, the tree may look like this:

Linux Directory Tree After Mounting /dev/sdb1 at /mnt/external:

/
β”œβ”€β”€ bin
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”‚   └── user
β”œβ”€β”€ mnt
β”‚   └── external  <-- Mounted device /dev/sdb1
β”‚       β”œβ”€β”€ documents
β”‚       β”œβ”€β”€ photos
β”‚       └── videos
β”œβ”€β”€ usr
└── var

The files are physically stored on /dev/sdb1, but they are accessed through /mnt/external.

A simple way to remember this is:

Device or filesystem + mount point = accessible files

Important Mounting Idea

Mounting does not copy files into the mount point.

It simply makes the filesystem visible at that location.

For example:

sudo mount /dev/sdb1 /mnt/external

does not copy the USB drive into /mnt/external.

It attaches the filesystem on /dev/sdb1 so that its contents can be accessed through /mnt/external.

Mount Points

A mount point is a directory where a filesystem is attached.

Common mount point locations include:

/mnt        traditional temporary mount location
/media      common location for removable media
/backup     custom mount point for backup drives
/data       custom mount point for data disks

For example:

/mnt/external
/mnt/iso
/media/usb
/data
/backup

A mount point should usually be empty before mounting.

If the directory already contains files, those files are not deleted, but they become hidden while another filesystem is mounted on top of that directory.

Example:

Before mounting:
/mnt/external contains oldfile.txt

After mounting /dev/sdb1 at /mnt/external:
/mnt/external shows the USB drive contents

After unmounting:
/mnt/external shows oldfile.txt again

This can confuse beginners, so it is best to use an empty directory as the mount point.

Device Names

Linux represents storage devices using files under:

/dev

Examples:

/dev/sda      first disk
/dev/sda1     first partition on first disk
/dev/sdb      second disk
/dev/sdb1     first partition on second disk
/dev/nvme0n1  NVMe disk
/dev/nvme0n1p1 first partition on NVMe disk

A USB drive might appear as:

/dev/sdb

and its first partition might appear as:

/dev/sdb1

However, device names can change after rebooting or reconnecting hardware. For persistent configuration, it is usually better to use a UUID instead of a device name.

Checking Which Devices Exist

Before mounting a device, first check whether Linux can see it.

Useful commands include:

lsblk
sudo fdisk -l
blkid

The lsblk command is often the easiest for beginners.

Example:

lsblk

Example output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 256.0G  0 disk
β”œβ”€sda1   8:1    0   512M  0 part /boot
└─sda2   8:2    0 255.5G  0 part /
sdb      8:16   1  32.0G  0 disk
└─sdb1   8:17   1  32.0G  0 part

This shows that /dev/sdb1 exists but is not currently mounted.

The fdisk -l command gives more detailed partition information:

sudo fdisk -l

Example output:

Disk /dev/sdb: 32 GB
Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1        2048  62521343  62519296 29.8G 83 Linux

This means:

/dev/sdb   is the disk
/dev/sdb1  is a partition on that disk
29.8G      is the partition size
Linux      is the partition type

The partition is usually what you mount, not the whole disk.

So you usually mount:

/dev/sdb1

not:

/dev/sdb

The mount Command

The mount command attaches a filesystem to a mount point.

Basic syntax:

mount [OPTIONS] DEVICE MOUNT_POINT

Example:

sudo mount /dev/sdb1 /mnt/external

This means:

Mount the filesystem on /dev/sdb1 at /mnt/external.

The general workflow is:

Find the device
      |
      v
Create a mount point
      |
      v
Mount the device
      |
      v
Access files through the mount point

Basic Manual Mount Example

Suppose a USB drive partition is available as:

/dev/sdb1

and you want to access it at:

/mnt/external

First, create the mount point:

sudo mkdir -p /mnt/external

Then mount the device:

sudo mount /dev/sdb1 /mnt/external

Now list the files:

ls /mnt/external

You can also move into the mounted filesystem:

cd /mnt/external

Verifying Mounted Filesystems

To see mounted filesystems, you can run:

mount

However, the output can be long.

A cleaner command is:

findmnt

To check one mount point:

findmnt /mnt/external

Example output:

TARGET        SOURCE    FSTYPE OPTIONS
/mnt/external /dev/sdb1 ext4   rw,relatime

This means:

Description
TARGET Where it is mounted
SOURCE Device being mounted
FSTYPE Filesystem type
OPTIONS Mount options

You can also use:

df -h

This shows mounted filesystems and available space in a human-readable format.

Understanding Mount Output

A mount entry might look like this:

/dev/sdb1 on /mnt/external type ext4 (rw,relatime)

Breaking it down:

/dev/sdb1        device
/mnt/external    mount point
ext4             filesystem type
rw               read-write
relatime         access-time update behavior

The rw option means the filesystem is mounted read-write.

A read-only mount would show:

ro

Filesystem Types

A filesystem type describes how data is organized on the device.

Common filesystem types include:

Filesystem Description
ext4 Common Linux filesystem
xfs Common on servers
btrfs Modern Linux filesystem with advanced features
vfat FAT32, common for USB drives
exfat Common for large USB drives and SD cards
ntfs Common Windows filesystem
iso9660 CD/DVD ISO filesystem
nfs Network File System
cifs Windows/Samba network share

Usually Linux can detect the filesystem automatically.

If needed, you can specify it manually with -t.

Example:

sudo mount -t ext4 /dev/sdb1 /mnt/external

For an NTFS drive:

sudo mount -t ntfs3 /dev/sdb1 /mnt/external

On some systems, especially older ones, NTFS support may use ntfs-3g:

sudo mount -t ntfs-3g /dev/sdb1 /mnt/external

If you get an error about an unknown filesystem type, you may need to install support for that filesystem.

Mount Options

Mount options control how the filesystem is mounted.

Options are passed with -o.

Example:

sudo mount -o ro /dev/sdb1 /mnt/external

This mounts the filesystem as read-only.

Common options include:

Option Description
ro Read-only
rw Read-write
noexec Do not allow execution of programs from the filesystem
nosuid Ignore set-user-ID and set-group-ID bits
nodev Do not interpret device files
uid=1000 Set file owner for filesystems without Unix ownership
gid=1000 Set group owner
defaults Use default options

Examples:

sudo mount -o ro /dev/sdb1 /mnt/external
sudo mount -o noexec,nosuid,nodev /dev/sdb1 /mnt/external

Read-only mounting is useful when you want to inspect a disk without accidentally changing it.

Unmounting

Unmounting detaches a mounted filesystem from the directory tree.

The command is:

umount

Notice the spelling:

umount

not:

unmount

To unmount a filesystem, use either the mount point or the device.

Example using the mount point:

sudo umount /mnt/external

Example using the device:

sudo umount /dev/sdb1

After unmounting, the files from the device are no longer visible at the mount point.

Why Unmounting Matters

You should unmount removable storage before physically removing it.

Linux often caches writes. This means that when you copy a file to a USB drive, the command may finish before all data has actually been written to the physical device.

Unmounting makes sure pending writes are completed.

The safe workflow is:

Copy files
    |
    v
Unmount the device
    |
    v
Wait for command to finish
    |
    v
Physically remove the device

If you unplug a device without unmounting it, you may cause:

The sync Command

The sync command asks Linux to flush cached writes to storage.

sync

This can be useful before unmounting removable media.

However, sync is not a replacement for umount.

A safer sequence is:

sync
sudo umount /mnt/external

Handling β€œTarget Is Busy”

Sometimes unmounting fails with an error like:

umount: /mnt/external: target is busy

This means something is still using the mounted filesystem.

Common causes include:

For example, if your terminal is currently in:

/mnt/external

then unmounting may fail.

Move out of the directory:

cd ~

Then try again:

sudo umount /mnt/external

Finding Processes Using a Mount

To see which processes are using a mount point, use lsof:

sudo lsof +f -- /mnt/external

Example output:

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
bash     1234 user  cwd    DIR   8,17     4096    2 /mnt/external

This means a Bash process with PID 1234 has its current working directory inside /mnt/external.

The most important fields are:

Field Description
COMMAND Process name
PID Process ID
USER User running the process
FD File descriptor
NAME File or directory being used

Another useful command is:

sudo fuser -vm /mnt/external

To close the issue, first try to close the application or move the terminal out of the directory.

If needed, terminate the process:

sudo kill 1234

Use kill carefully. Terminating a process that is writing data may cause data loss.

Lazy and Forced Unmounts

The umount command has advanced options.

Lazy unmount:

sudo umount -l /mnt/external

The -l option detaches the filesystem now and cleans it up after it is no longer busy.

Forced unmount:

sudo umount -f /mnt/external

The -f option forces the unmount.

Forced unmounts should be used carefully, especially for local disks, because they can risk data corruption.

A good rule is:

Mounting with a Specific Filesystem Type

Sometimes Linux does not automatically detect the filesystem type, or you want to be explicit.

Example for ext4:

sudo mount -t ext4 /dev/sdb1 /mnt/external

Example for NTFS:

sudo mount -t ntfs3 /dev/sdb1 /mnt/external

Example for FAT32:

sudo mount -t vfat /dev/sdb1 /mnt/external

Example for exFAT:

sudo mount -t exfat /dev/sdb1 /mnt/external

If mounting fails, check the filesystem type with:

lsblk -f

or:

sudo blkid /dev/sdb1

Example:

/dev/sdb1: UUID="ABCD-1234" TYPE="exfat" LABEL="MYUSB"

Mounting ISO Images

An ISO image is a file that contains the contents of a CD, DVD, or installation image.

For example:

ubuntu.iso

You can mount an ISO file without burning it to a disc.

First create a mount point:

sudo mkdir -p /mnt/iso

Then mount the ISO:

sudo mount -o loop ubuntu.iso /mnt/iso

The loop option lets Linux treat a regular file as if it were a block device.

After mounting, view the files:

ls /mnt/iso

When finished, unmount it:

sudo umount /mnt/iso

The workflow looks like this:

ubuntu.iso file
      |
      v
loop device
      |
      v
mounted at /mnt/iso
      |
      v
contents become accessible

Mounting Network Shares

Network shares can also be mounted.

Two common types are:

NFS      common between Linux/Unix systems
CIFS     used for Windows/Samba shares

Example NFS mount:

sudo mount -t nfs server:/export/data /mnt/data

Example CIFS mount:

sudo mount -t cifs //server/share /mnt/share -o username=myuser

Network mounts are common for shared storage, home directories, backups, and file servers.

For persistent network mounts, /etc/fstab or systemd mount units are often used.

Persistent Mounts with /etc/fstab

Manual mounts disappear after reboot.

To mount a filesystem automatically at boot, configure it in:

/etc/fstab

The file contains one filesystem per line.

Example:

/dev/sdb1   /mnt/external   ext4    defaults    0   2

The fields are:

Field Value
Device /dev/sdb1
Mount point /mnt/external
Filesystem ext4
Options defaults
Dump 0
fsck pass 2

The last two fields are older but still important:

0   do not use dump backup
2   check this filesystem after the root filesystem

The root filesystem usually has pass value 1.

Other local Linux filesystems often use 2.

Filesystems that should not be checked at boot often use 0.

Prefer UUIDs in /etc/fstab

Device names such as /dev/sdb1 can change.

For example, today a USB drive may be:

/dev/sdb1

but after reboot it may become:

/dev/sdc1

To avoid this problem, use a UUID.

Find the UUID:

sudo blkid /dev/sdb1

Example:

/dev/sdb1: UUID="1234-ABCD" TYPE="ext4"

Then use the UUID in /etc/fstab:

UUID=1234-ABCD   /mnt/external   ext4   defaults   0   2

This is more reliable than using /dev/sdb1.

Testing /etc/fstab

After editing /etc/fstab, do not reboot immediately.

First test it with:

sudo mount -a

This attempts to mount everything listed in /etc/fstab.

If there is an error, fix it before rebooting.

A bad /etc/fstab entry can cause boot problems, especially if it refers to an unavailable device without safe options.

For removable or optional drives, consider options such as:

nofail
x-systemd.automount

Example:

UUID=1234-ABCD   /mnt/external   ext4   defaults,nofail   0   2

The nofail option allows the system to continue booting even if the device is not present.

Visualizing the Mounting Process

Before mounting:

/
β”œβ”€β”€ bin
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”‚   └── user
β”œβ”€β”€ mnt
β”œβ”€β”€ usr
└── var

After mounting /dev/sdb1 at /mnt/external:

/
β”œβ”€β”€ bin
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”‚   └── user
β”œβ”€β”€ mnt
β”‚   └── external
β”‚       β”œβ”€β”€ data
β”‚       └── projects
β”œβ”€β”€ usr
└── var

The mounted filesystem becomes part of the normal directory tree.

You do not access it through a separate drive letter. You access it through the mount point.

Typical Mounting Workflow

A safe manual mounting workflow looks like this:

  1. Connect the device
  2. Identify the device name
  3. Check the filesystem type
  4. Create a mount point
  5. Mount the filesystem
  6. Access the files
  7. Unmount when finished
  8. Remove the device

Commands:

lsblk -f
sudo mkdir -p /mnt/external
sudo mount /dev/sdb1 /mnt/external
ls /mnt/external
sudo umount /mnt/external

Data Integrity

Always unmount removable filesystems before unplugging them.

This matters because Linux may delay writes for performance.

For example, copying a file may appear to finish quickly, but some data may still be waiting in memory.

Unmounting ensures that:

This reduces the chance of corruption or data loss.

Automounting

Many desktop systems already automount removable drives.

For servers or custom setups, there are several ways to automate mounting:

For most users, /etc/fstab is the best starting point.

For advanced users, udev can run actions when hardware appears or disappears.

Automating Mounting with udev

udev manages device events in Linux.

It can detect when a USB drive is connected and run a command or script.

However, using udev directly for mounting can be tricky. Long commands with shell features such as && may not work as expected unless run through a script or shell.

A cleaner approach is to have a udev rule call a script.

First, identify the device UUID:

sudo blkid /dev/sdX1

Example:

/dev/sdX1: UUID="1234-ABCD" TYPE="ext4"

Create a script:

sudo nano /usr/local/sbin/mount-my-usb.sh

Example script:

#!/bin/sh
mkdir -p /media/my_usb
mount UUID=1234-ABCD /media/my_usb

Make it executable:

sudo chmod +x /usr/local/sbin/mount-my-usb.sh

Then create a udev rule:

sudo nano /etc/udev/rules.d/99-usb-mount.rules

Example rule:

ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_UUID}=="1234-ABCD", RUN+="/usr/local/sbin/mount-my-usb.sh"

Reload rules:

sudo udevadm control --reload-rules
sudo udevadm trigger

Then unplug and reconnect the device to test.

For many real systems, systemd automounts or desktop automounting are easier and more reliable than custom udev mounting rules.

Troubleshooting Mounting Problems

Problem: Permission Denied

Example:

mount: permission denied

Possible causes:

Try:

sudo mount /dev/sdb1 /mnt/external

If the mount succeeds but your user cannot write to the mounted filesystem, check ownership and permissions.

For Linux filesystems such as ext4, use:

ls -ld /mnt/external

For FAT, exFAT, or NTFS filesystems, ownership may need to be controlled with mount options such as uid and gid.

Example:

sudo mount -o uid=1000,gid=1000 /dev/sdb1 /mnt/external

Problem: Unknown Filesystem Type

Example:

mount: unknown filesystem type 'exfat'

Possible causes:

Check the type:

lsblk -f

or:

sudo blkid /dev/sdb1

Then install the needed support package if necessary.

For example, NTFS or exFAT support may require additional packages on some systems.

Problem: Target Is Busy

Example:

umount: /mnt/external: target is busy

Find processes using it:

sudo lsof +f -- /mnt/external

or:

sudo fuser -vm /mnt/external

Then close the program, move out of the directory, or stop the process.

Common fix:

cd ~
sudo umount /mnt/external

Problem: Device Not Found

Example:

mount: /dev/sdb1 does not exist

Check devices:

lsblk

Possible causes:

Check recent kernel messages:

dmesg | tail

Problem: Bad /etc/fstab Entry

If mount -a fails, inspect /etc/fstab.

Common mistakes include:

Create the mount point if missing:

sudo mkdir -p /mnt/external

Then test again:

sudo mount -a

Challenges

  1. Plug a USB drive into your system and use lsblk and fdisk -l to identify the device name and partition details. Discuss how device names are assigned and explain the difference between physical devices and partitions.
  2. Create a new directory under /mnt or /media, and mount your USB drive to this directory using the mount command. Describe the purpose of mount points and how they provide access to external storage devices on Linux.
  3. Navigate to the mount point of the USB drive and perform basic file operationsβ€”create, read, edit, and delete a file. Discuss how mounting makes files accessible and how permissions might affect file access on mounted devices.
  4. What happens if you mount a USB drive onto an existing non-empty directory? Is this allowed, and if so, what happens to the directory’s original contents?
  5. Create a virtual disk file in your home directory using the dd command, specifying its size and location. Discuss how virtual disk files can simulate actual disks and their potential uses in testing and development.
  6. Format the virtual disk file with an ext4 filesystem using mkfs.ext4. Explain the significance of different filesystem types and why choosing an appropriate filesystem is important for specific use cases.
  7. Mount the formatted virtual disk file to a directory under /mnt, just as you would a physical device. Discuss the concept of loopback devices and how they allow files to be mounted as if they were physical disks.
  8. Investigate the differences between temporary and persistent mounting by adding an entry for your USB drive or virtual disk in /etc/fstab. Explain how persistent mounts work and the benefits of configuring automatic mounts for commonly used devices.
  9. Explore permissions on the mounted USB drive by changing the ownership and permissions of files on it. Discuss how Linux handles permissions for different users on mounted devices and the implications for shared drives.
  10. Create a script that automatically mounts and unmounts the USB drive upon insertion and removal, utilizing udev rules for automation. Explain how udev helps manage device events in Linux and the advantages of automated mounting for frequently used external devices.