Linux - Mount & Unmount in Linux
In Linux, devices like hard drives, USBs, CDs, and network storage don’t automatically appear as drive letters (like C:, D: in Windows).
Instead, Linux uses a single directory tree starting from /, and you attach storage devices into this tree using mounting.
Mounting and unmounting are essential for accessing storage devices safely.
What is Mounting? (mount)
Mounting means attaching a storage device to a directory in the Linux filesystem so that you can access its files.
-
When you “mount” a device, Linux connects it to a mount point (a directory where the device’s contents will appear).
-
Before mounting, the device's files are not accessible.
Example mount command:
sudo mount /dev/sdb1 /mnt
-
/dev/sdb1→ the device (USB partition) -
/mnt→ mount point directory
After mounting, whatever is stored in /dev/sdb1 becomes visible under /mnt.
Common Mount Points
| Device | Typical Mount Location |
|---|---|
| USB drive | /media/username/usbdrive or /mnt/usb |
| Additional HDD/SSD | /mnt/data |
| CD/DVD | /media/cdrom |
| Network share | /mnt/share |
What is Unmounting? (umount)
Unmounting means safely detaching a storage device from the Linux filesystem tree.
You must unmount a device before removing it physically to avoid:
-
Data loss
-
File corruption
-
Incomplete write operations
Example umount command:
sudo umount /mnt
OR unmount by device name:
sudo umount /dev/sdb1
Why Unmounting Is Important
When files are being written, Linux uses buffers and caches.
If you remove a USB drive without unmounting:
-
Files may not be fully written
-
The filesystem may become corrupted
-
The device may need repair (e.g., fsck)
Checking Mounted Devices
1. Show all mounted devices:
mount
2. Modern and cleaner output:
lsblk
3. View mounted filesystems:
df -h
Mounting with Filesystem Type
Sometimes Linux needs you to specify the filesystem:
sudo mount -t ext4 /dev/sda1 /mnt/data
Common filesystems:
-
ext4(Linux default) -
vfat/fat32(Windows USB) -
ntfs(Windows drives) -
iso9660(CD/DVD)
Auto-Mounting Using /etc/fstab
To mount a device automatically at boot:
Edit:
sudo nano /etc/fstab
Example entry:
/dev/sda1 /mnt/data ext4 defaults 0 2
Forcing Unmount (If device is busy)
If you try to unmount a disk in use:
umount: /mnt: target is busy
You can check what is using it:
lsof | grep /mnt
Force unmount:
sudo umount -f /mnt
Lazy unmount (detach when no longer in use):
sudo umount -l /mnt
In Summary
| Action | Meaning |
|---|---|
| mount | Attach a device to a directory to access it |
| umount | Safely detach the device |
| Required Before Removing USB? | YES |
| Needs a mount point? | YES |