Skip to main content
Engineering LibreTexts

04-C.10: Mounting Linux File Systems

  • Page ID
    26846
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)

    EXAM OBJECTIVES COVERED
    1.4 Given a scenario, manage storage in a Linux environment.

    Mount Points

    A mount point is simply a directory, like any other, that is created as part of the root filesystem. So, for example, the home filesystem is mounted on the directory /home. Filesystems can be mounted at mount points on other non-root filesystems but this is less common.

    The ability to mount and unmount filesystems is a critical skill for Linux administrators. In this video you will see how to mount and unmount a simple file system. This technique applies to all filesystems. 

    The mount Command

    The Linux root filesystem is mounted on the root directory (/) very early in the boot sequence. Mounting of filesystems during the startup process is managed by the /etc/fstab configuration file. An easy way to remember this is that fstab stands for "file system table," and it is a list of filesystems that are to be mounted, their designated mount points, and any options that might be needed for specific filesystems.

    Filesystems are mounted on an existing directory/mount point using the mount command. In general, any directory that is used as a mount point should be empty and not have any other files contained in it. Linux will not prevent users from mounting one filesystem over one that is already there or on a directory that contains files. If you mount a filesystem on an existing directory or filesystem, the original contents will be hidden and only the content of the newly mounted filesystem will be visible.

    Syntax:

    mount -t type device dir
    • "device" is the device special file, such as /dev/sda1.
    • dir is the mount point where the partition is to be mounted.
    • If you leave the dir argument out of command it looks for a mount point in /etc/fstab.
    • You can use –source or –target to avoid ambivalent interpretation.
      mount --target /mountpoint
    • /etc/fstab usually contains information about which device is need to be mounted where.

    Command Options:

    Options Option Meaning
    auto / noauto With the auto option, the device will be mounted automatically at bootup or when the mount -a command is issued. auto is the default option. For the device not to be mounted automatically, the noauto option is used in /etc/fstab. With noauto, the device can be only mounted explicitly.
    exec / noexec exec lets binaries that are on the partition be executed, whereas noexec is the opposite. noexec might be useful for a partition that contains no binaries, like /var, or contains binaries the user may not want to execute on the system, or that cannot even be executed on the system, as might be the case of a Windows partition.
    rw / ro Mount the filesystem in either read write or read only mode. Explicitly defining a file system as rw can alleviate some problems in file systems that default to read only.
    sync / async How the input and output to the filesystem should be done. sync means it is done synchronously; async would mean it is to be done asynchronously.
    user / users / nouser user Permits any user to mount the filesystem. This automatically implies noexec, nosuid, nodev unless overridden. If nouser is specified, only root can mount the filesystem. If users is specified, every user in group users will be able to unmount the volume.
    defaults Use default settings. Default settings are defined per file system at the file system level. For ext3 file systems these can be set with the tune2fs command. The normal default for Ext3 file systems is equivalent to rw, suid, dev, exec, auto, nouser, async (no acl support). Modern Red Hat based systems set acl support as default on the root file system but not on user created Ext3 file systems. Some file systems such as XFS enable acls by default. Default file system mount attributes can be overridden in /etc/fstab.

    The umount Command

    The umount command detaches the file system(s) mentioned from the file hierarchy. A file system is specified by giving the directory where it has been mounted. Giving the special device on which the file system lives may also work, but is obsolete, mainly because it will fail in case this device was mounted on more than one directory.

    Syntax:

    umount -a [-dflnrv] [-t vfstype] [-O options]
    umount [-dflnrv] {dir|device}...
    

    Command Options:

    Options Option Meaning
    -h Print a help message and exit.
    -f Force unmount (in case of an unreachable NFS system). (Requires kernel 2.1.116 or later.)
    -l “Lazy” unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore.
    -t vfstype Indicate that the actions should only be taken on file systems of the specified type. More than one type may be specified in a comma separated list. The list of file system types can be prefixed with no to specify the file system types on which no action should be taken.
    -O options Indicate that the actions should only be taken on file systems with the specified options in /etc/fstab. More than one option type may be specified in a comma separated list. Each option can be prefixed with no to specify options for which no action should be taken.

    Adapted from:
    "mount command in Linux with Examples" by Vivek Agrawal, Geeks for Geeks is licensed under CC BY-SA 4.0
    "fstab" by Multiple ContributorsWijipedia is licensed under CC BY-SA 3.0
    "unmount filesystems" by Multiple contributors, man7.org is in the Public Domain, CC0


    04-C.10: Mounting Linux File Systems is shared under a CC BY-NC license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?