mount

system administrationLinux/Unix
The mount command is one of the most frequently used commands in Linux/Unix-like operating systems. mount Mount a filesystem

Quick Reference

Command Name:

mount

Category:

system administration

Platform:

Linux/Unix

Basic Usage:

mount [options] [arguments]

Common Use Cases

    Syntax

    mount [-t fstype] [-o options] device dir

    Options

    Option Description
    -a, --all Mount all filesystems mentioned in /etc/fstab
    -B, --bind Mount a subtree somewhere else (same as -o bind)
    -c, --no-canonicalize Don't canonicalize paths
    -f, --fake Dry run; skip the mount system call
    -F, --fork Fork off for each device (use with -a)
    -i, --internal-only Don't call the /sbin/mount.* helpers
    -l, --show-labels Show also filesystem labels
    -L, --label LABEL Mount partition with the specified label
    -M, --move Move a subtree to some other place
    -n, --no-mtab Don't write to /etc/mtab
    -o, --options opts Mount options specified by a comma-separated string
    -O, --test-opts opts Limit the set of filesystems (with -a)
    -r, --read-only Mount the filesystem read-only (same as -o ro)
    -R, --rbind Mount a subtree and all submounts somewhere else
    -t, --types fstype Specify filesystem type(s)
    -U, --uuid UUID Mount partition with the specified UUID
    -v, --verbose Verbose mode
    -w, --rw, --read-write Mount the filesystem read-write (default)

    Common Mount Options:

    Option Description
    ro Mount read-only
    rw Mount read-write
    exec Allow execution of binaries
    noexec Do not allow execution of binaries
    suid Allow set-user-ID or set-group-ID bits
    nosuid Disable set-user-ID or set-group-ID bits
    dev Interpret character or block special devices
    nodev Do not interpret character or block special devices
    user Allow ordinary user to mount
    nouser Forbid ordinary user to mount
    remount Remount an already-mounted filesystem
    sync Synchronous I/O
    async Asynchronous I/O
    bind Bind mount a directory to another location
    loop Mount as a loop device

    Examples

    How to Use These Examples

    The examples below show common ways to use the mount command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    mount /dev/sdb1 /mnt
    Mount the device /dev/sdb1 at the mount point /mnt.
    mount
    Display all mounted filesystems.
    # Advanced Examples Advanced
    mount -t ext4 /dev/sdc1 /data Mount an ext4 filesystem from /dev/sdc1 to /data. mount -o ro /dev/sdb1 /mnt/usb Mount /dev/sdb1 at /mnt/usb as read-only. mount -o remount,rw / Remount the root filesystem with read-write permissions. mount -a Mount all filesystems defined in /etc/fstab. mount -t nfs 192.168.1.100:/share /mnt/nfs Mount an NFS share from a remote server. mount -t cifs -o username=user,password=pass //server/share /mnt/smb Mount a Windows/SMB share. mount -o loop,ro disk.iso /mnt/iso Mount an ISO file as a loop device. sudo mount -t tmpfs -o size=1G tmpfs /mnt/ramdisk Create and mount a 1GB RAM disk.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The 'mount' command is a fundamental Linux utility used to attach (mount) filesystems to the directory tree. It allows accessing data on storage devices like hard drives, USB drives, CD-ROMs, network shares, and virtual filesystems by connecting them to a specific location (mount point) in the directory hierarchy. Key features of the mount command: 1. Filesystem Integration: mount attaches a filesystem located on a storage device to a directory in the Linux file hierarchy, making the device's contents accessible through that directory. 2. Multiple Filesystem Support: The command can mount a wide variety of filesystem types, including ext4, XFS, NTFS, FAT32, NFS, SMB/CIFS, and many others, often using the -t option to specify the type. 3. Mount Options: mount offers extensive configuration through options that control how the filesystem is mounted, including read/write permissions, user access, execution permissions, and filesystem-specific features. 4. Automatic Mounting: When used with the -a flag, mount reads the /etc/fstab file and mounts all filesystems defined there, which is useful during system startup. 5. Special Mounts: Beyond physical storage, mount can create special mounts like tmpfs (RAM-based filesystem), proc (kernel information), sysfs (device information), and bind mounts (mounting a directory to another location). 6. Status Display: When run without arguments, mount displays all currently mounted filesystems, showing their source, mount point, type, and options. 7. Loop Device Support: With the -o loop option, mount can attach disk images and ISO files as if they were physical devices. Common use cases for mount include: - Accessing data on removable media like USB drives or SD cards - Attaching network shares from NFS or Windows servers - Mounting disk images for software installation or forensic analysis - Creating RAM disks for high-speed temporary storage - Setting up specialized filesystems for specific applications - Remounting filesystems with different options (e.g., changing from read-only to read-write) - Implementing chroot environments or container mounts It's important to note that mounting and unmounting filesystems typically requires root privileges, although systems can be configured to allow regular users to mount certain devices (like removable media) through options in /etc/fstab or through user-space mounting utilities. The mount command works in conjunction with its counterpart, umount, which is used to detach filesystems from the directory tree. Proper unmounting is important before physically disconnecting storage devices to ensure data integrity. In modern Linux distributions, many removable devices are automatically mounted by system services like udisks or by desktop environments when connected, but the mount command remains essential for system administration, troubleshooting, and advanced use cases.

    Related Commands

    These commands are frequently used alongside mount or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the mount command works in different scenarios.

    $ mount
    View All Commands