Cheat Sheet #day68 - mount

Cloud TunedCloud Tuned
2 min read

mount Command Cheatsheet

The mount command in Unix-like systems is used to mount filesystems and network shares onto the directory tree. It is essential for managing storage devices and network shares efficiently. Here’s a quick reference guide:

Basic Syntax

mount [OPTION]... [DEVICE] [DIRECTORY]

Common Options

  • -t TYPE, --types TYPE: Specify the filesystem type (e.g., ext4, nfs).

      mount -t ext4 /dev/sdb1 /mnt/data
    
  • -o OPTIONS, --options OPTIONS: Mount options (e.g., rw for read-write, ro for read-only).

      mount -o rw /dev/sdb1 /mnt/data
    
  • -a, --all: Mount all filesystems listed in /etc/fstab (except noauto entries).

      mount -a
    
  • -r, --read-only: Mount the filesystem read-only.

      mount -o ro /dev/sdb1 /mnt/data
    
  • -v, --verbose: Verbose mode, print detailed information during the mount operation.

      mount -v /dev/sdb1 /mnt/data
    

Examples

  1. Mount a device to a directory:

     mount /dev/sdb1 /mnt/data
    
  2. Mount a filesystem specifying type and options:

     mount -t ext4 -o rw /dev/sdb1 /mnt/data
    
  3. Mount all filesystems listed in /etc/fstab:

     mount -a
    
  4. Mount a remote NFS share:

     mount -t nfs server:/share /mnt/nfs
    
  5. Unmount a mounted filesystem:

     umount /mnt/data
    

Additional Information

  • List mounted filesystems:

      mount
    
  • Help option:

      mount --help
    
  • View manual page for mount:

      man mount
    

The mount command is crucial for managing filesystems and network shares in Unix-like systems. It allows administrators to control storage devices and network resources effectively. For more detailed options and usage scenarios, refer to the man page or use mount --help.

0
Subscribe to my newsletter

Read articles from Cloud Tuned directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Cloud Tuned
Cloud Tuned