Mount Command - Mount Filesystems Easily | Online Free DevTools by Hexmos

Mount filesystems with the mount command. Learn to mount temporary filesystems like TMPFS for secure and temporary storage. Free online tool for developers.

Mount Command

Understanding the Mount Command

The mount command in Linux is a fundamental utility used to attach a filesystem to a specific directory in your system's directory tree. This process makes the files and directories within that filesystem accessible. It's crucial for managing storage devices, network shares, and even virtual file systems.

Mounting a Temporary Filesystem (TMPFS)

A common and powerful use case for mount is creating temporary file systems. The example below demonstrates how to mount a 4GB temporary filesystem (TMPFS) to the /mnt directory. TMPFS stores its data in volatile memory, meaning its contents are lost upon reboot. This is ideal for temporary data, such as bootstrap tarballs or sensitive information that should not persist.

Example: Mounting TMPFS

# mount
# Mount a filesystem

# Mount a temporary filesystem (TMPFS) of 4GB to '/mnt'. The contents will
# vanish when you reboot, but this can be very useful when working with things
# like bootstrap tarballs or temporary storages for sensitive data.
mount -t tmpfs -o mode=755,size=4096M tmpfs /mnt

Key Options Explained

  • -t tmpfs: Specifies the filesystem type as tmpfs, which is a RAM-based filesystem.
  • -o mode=755,size=4096M: Sets the mount options.
    • mode=755: Defines the permissions for the mounted filesystem, allowing the owner to read, write, and execute, and others to read and execute.
    • size=4096M: Sets the maximum size of the temporary filesystem to 4 Gigabytes.
  • tmpfs: The source of the filesystem (for tmpfs, this is often just 'tmpfs').
  • /mnt: The mount point, which is the directory where the filesystem will be attached.

Further Resources