Linux Mount Basics
What is Mounting?
Mounting is a fundamental process in Linux that allows you to attach a filesystem to a specific directory in the system's file hierarchy. It enables access to various storage devices, partitions, and file systems by connecting them to a designated mount point.
Key Concepts of Mounting
Filesystem Hierarchy
In Linux, everything is treated as a file, including devices and storage media. The mounting process integrates these resources into the single directory tree.
graph TD
A[Root Directory /] --> B[/home]
A --> C[/dev]
A --> D[/mnt]
A --> E[/media]
Mount Point Types
Mount Point |
Description |
Common Use |
/ |
Root directory |
System files |
/home |
User home directories |
Personal files |
/mnt |
Temporary mount points |
Manual mounting |
/media |
Removable media |
USB drives, CDs |
Basic Mounting Commands
mount Command
The primary command for mounting filesystems in Linux:
## Basic mount syntax
mount [options] device mountpoint
## Example: Mount a USB drive
mount /dev/sdb1 /mnt/usb
Common Mounting Options
-t
: Specify filesystem type
-o
: Set mount options like read-only
## Mount with read-only permission
mount -o ro /dev/sda1 /mnt/backup
Understanding /etc/fstab
The /etc/fstab
file defines how filesystems are mounted automatically during system boot.
## /etc/fstab format
## <device> <mountpoint> <type> <options> <dump> <pass>
/dev/sda1 / ext4 defaults 0 1
Practical Example with LabEx
At LabEx, we recommend practicing mount operations in a controlled environment to understand the nuances of filesystem management.
Key Takeaways
- Mounting connects storage devices to the Linux directory structure
/mnt
and /media
are typical mount point directories
mount
and umount
commands manage filesystem attachment
/etc/fstab
automates mounting during system startup