The mount command in Linux lets you attach storage devices or filesystems (USB drives, hard disks, ISO files) to your system so you can access their contents.
๐ What is mount?
In Linux, devices arenโt accessed directlyโtheyโre mounted to a directory (called a mount point).
๐ Example: a USB drive might be mounted to /mnt/usb
โ Basic Syntax
mount [options] device mount_point
๐ Step 1: Identify the Device
List available drives:
lsblk
๐ Look for something like /dev/sdb1
๐ Step 2: Create a Mount Point
sudo mkdir -p /mnt/usb
๐ Step 3: Mount the Device
sudo mount /dev/sdb1 /mnt/usb
๐ You can now access files in /mnt/usb
๐ค Unmount the Device
Before removing a drive, unmount it:
sudo umount /mnt/usb
๐ Always unmount to prevent data loss
๐ง Mount with Filesystem Type
sudo mount -t ext4 /dev/sdb1 /mnt/usb
Common types:
ext4(Linux)ntfs(Windows)vfat(USB drives)
๐ฟ Mount an ISO File
sudo mount -o loop file.iso /mnt/iso
๐ Lets you browse ISO contents without burning it
โ๏ธ Useful Options
| Option | Description |
|---|---|
-t | Specify filesystem type |
-o | Mount options |
-r | Read-only mode |
-w | Read/write mode |
-a | Mount all from /etc/fstab |
๐ Auto-Mount with /etc/fstab
To mount automatically at boot:
/dev/sdb1 /mnt/usb ext4 defaults 0 2
๐ Add this line to /etc/fstab
๐ Real-World Examples
Mount USB drive
sudo mount /dev/sdb1 /mnt/usb
Mount read-only
sudo mount -o ro /dev/sdb1 /mnt/usb
Mount Windows partition
sudo mount -t ntfs /dev/sdb1 /mnt/windows
โ ๏ธ Common Mistakes
- โ Forgetting
sudo - โ Not creating mount point
- โ Removing drive without unmounting
- โ Wrong filesystem type
๐ง Pro Tips
- Use
lsblkorblkidto verify devices - Use
/mediaor/mntfor mount points - Always unmount before unplugging drives
Check mounts with:
mount |grepsdb1
๐ Quick Summary
mountconnects a device to a directory- Use
umountto safely disconnect - Works with USB, disks, and ISO files
- Configure
/etc/fstabfor auto-mount
๐ฏ Final Thoughts
The mount command is essential for managing storage in Linux. Once you understand mount points and device paths, you can easily work with any disk, USB drive, or ISO file like a pro.