mount is the command used in Linux systems to mount file systems. It allows you to connect devices (such as hard disk partitions, USB drives, CDs, etc.) or remote file systems to a specific directory in the file system, enabling access to their contents.
๐ง Basic Syntax
mount [options] [device] [mount point]
๐งพ Common Examples
1. Mount a device to a specified directory
sudo mount /dev/sdb1 /mnt/usb
Note: Mounts the device /dev/sdb1 to the directory /mnt/usb.
Note: The mount point directory must exist beforehand.
2. View current mount information
mount
Or use:
df -h
Or:
findmnt
3. Mount a specified file system type (e.g., NTFS, vfat)
sudo mount -t ntfs /dev/sdb1 /mnt/usb
Common file system types include:
ext4(commonly used in Linux)ntfs(Windows partition)vfat(USB drives, FAT32)iso9660(CD image)nfs(Network File System)
4. Mount using UUID (recommended method)
sudo mount UUID="1234-5678-90AB-CDEF" /mnt/data
You can check the UUID of a device using the following command:
blkid
5. Mount a read-only file system
sudo mount -o ro /dev/sdc1 /mnt/cdrom
6. Mount an ISO image file
sudo mount -o loop image.iso /mnt/iso
7. Unmount a file system
sudo umount /mnt/usb
Note: Ensure no programs are using the mount point before unmounting.
๐ ๏ธ Common Options (-o parameter)
| Option | Description |
|---|---|
ro |
Read-only mount |
rw |
Read-write mount (default) |
noauto |
Do not automatically mount at startup |
users |
Allow ordinary users to mount/unmount |
uid=1000 |
Set the user ID of files after mounting |
gid=1000 |
Set the group ID of files after mounting |
umask=0022 |
Set permission mask |
loop |
Mount image files (e.g., ISO) |
๐ /etc/fstab file
Used to define file systems that are automatically mounted at system startup.
Example entry:
UUID=1234-5678-90AB-CDEF /mnt/data ext4 defaults 0 2
Field descriptions:
| Field | Meaning |
|---|---|
| 1 | Device identifier (device path or UUID) |
| 2 | Mount point |
| 3 | File system type |
| 4 | Mount options (e.g., defaults) |
| 5 | Whether to be dumped (0/1) |
| 6 | File system check order (0-2) |
๐ Tips
- When mounting USB drives or external hard drives, it is generally recommended to use directories under
/mediaor/mntas mount points. - If you are using a desktop environment (like GNOME or KDE), devices are usually mounted automatically when inserted.
- If mounting fails, you can check the logs:
dmesgor/var/log/syslog(depending on the distribution).