Home > Package & System Management > mount

mount: Mount and Unmount File Systems

The mount command connects a file system to a specified directory, making it accessible. It is used to integrate various storage devices such as hard disks, USB drives, and CD-ROMs into the system's file hierarchy.

Overview

To use a file system on a Linux system, a 'mount' operation is required to connect it to a specific directory. The `mount` command links a storage device (disk partition) to a designated mount point (directory), allowing access to the device's file system through that directory. This process enables the system to manage multiple physical or logical storage devices within a unified file system structure.

Key Features

Key features of the mount command include:

  • Connects a file system to a directory, making it accessible.
  • Can mount various devices such as hard disks, USB drives, and network shared folders.
  • Allows viewing a list of currently mounted file systems.
  • Manages settings for automatic mounting during system boot.

Basic Concepts of Mounting

Mounting can be understood as the process of connecting a device and a directory.

  • Device: A physical or logical storage device. E.g., /dev/sdb1
  • Mountpoint: An empty directory where the file system will be attached. E.g., /mnt/data
  • Filesystem: The logical structure created on a device. E.g., ext4, xfs

Main Options

Key options for the `mount` command are grouped by purpose.

1) Mounting and Information Display

2) Mount Option Control

Generated command:

Try combining the commands.

Description:

`mount` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Explore the various usage examples of the `mount` command to understand its functionalities.

Check all currently mounted file systems

mount

Executing the `mount` command without arguments displays all devices and mount points currently mounted on the system.

Mount a new disk partition

sudo mkdir /mnt/data
sudo mount /dev/sdb1 /mnt/data

Mounts the `/dev/sdb1` partition to the `/mnt/data` directory. The `data` directory must be created beforehand.

Mount a USB drive

sudo mkdir /mnt/usb
sudo mount -t vfat /dev/sdc1 /mnt/usb

Mounts a USB drive to `/mnt/usb`. The file system type of the USB (e.g., `vfat`) can be explicitly specified.

Mount as Read-Only

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

Mounts `/dev/sdb1` to `/mnt/data` as read-only (`ro`) to prevent accidental data modification.

Tips & Cautions

Here are some points to note when using the `mount` command.

Tips

  • The mount command requires sudo privileges. Regular users cannot mount.
  • The directory used as a mount point must exist beforehand and be empty. If you mount to a directory that already contains files, the existing files will become inaccessible.
  • To automatically mount devices at system boot, you must add the relevant information to the /etc/fstab file. Be careful, as incorrect syntax in this file can lead to boot failure.
  • Before removing a mounted device, you must always unmount it using the umount command. Failure to do so can lead to data corruption.

Related commands

These are commands that are functionally similar or are commonly used together.



Same category commands