Skip to main content
Engineering LibreTexts

04-D.11: File System Management

  • Page ID
    26849
  • \( \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}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    EXAM OBJECTIVES COVERED
    1.4 Given a scenario, manage storage in a Linux environment.
    2.7 Explain the use and operation of Linux devices.
    4.1 Given a scenario, analyze system properties and remediate accordingly.

    Linux File Systems 

    The /proc/mounts File

    To display all mounted file systems Linux provides the information in /proc/mounts. It is actually not a real file, but part of the virtual file system that represents the status of mounted objects as reported by the Linux kernel. It is in a format similar to the /etc/fstab file: the mounted device, the mount point, the file system type, mount flags, dump frequency, and file system check order. Even though it is not truly a file, you can use commands like cat or less on this "file."

    The /etc/mtab File

    This file lists all currently mounted file systems along with their initialization options. mtab is very similar to /proc/mounts in that they both report the status of currently mounted file systems. However, since the kernel updates /proc/mounts is typically more accurate and includes more up-to-date information about the file systems. The mount command maintains the contents of the mtab file.

    The /proc/partitions File

    The /proc/partitions file contains partition block allocation information. Like the other files in the /proc file system, it is not a real file but part of the virtual file system. The format of /proc/partitions contains 4 columns:
    major—This value represents the class of device so that it can be mapped to an appropriate driver.
    minor—This value separates partitions into physical devices. This corresponds to the number at the end of the partition's name (such as sda1, sda2, etc).
    #blocks—How many physical blocks the partition takes up.
    name—The name of the partition.

    major    minor  #blocks  name
       8        0  488386584 sda
       8        1    9216000 sda1
       8        2   81920000 sda2
       8        5   81920000 sda5
       8        6  315317248 sda6
       8        7       8192 sda7
      11        0    1048575 sr0

    Learn how to use the e2fsck command to troubleshoot file system in this video. 

    The lsblk Command

    The lsblk command lists information about all available or the specified block devices. The lsblk command reads the sysfs file system and udev db to gather information. If the udev db is not available or lsblk is compiled without udev support than it tries to read LABELs, UUIDs and file system types from the block device. In this case root permissions are necessary.

    Syntax:

    lsblk [ OPTIONS ]
    lsblk [ OPTIONS ] device
    

    Command Options:

    Options Option Meaning
    -a, --all Also list empty devices. (By default they are skipped.)
    -e, --exclude list Exclude the devices specified by the comma-separated list of major device numbers. Note that RAM disks (major=1) are excluded by default. The filter is applied to the top-level devices only.
    -f, --fs Output info about file systems. This option is equivalent to -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT. The authoritative information about file systems and raids is provided by the blkid(8) command.
    -l, --list Produce output in the form of a list.
    -m, --perms Output info about device owner, group and mode. This option is equivalent to -o NAME,SIZE,OWNER,GROUP,MODE.
    -n, --noheadings Do not print a header line.
    -o, --output list Specify which output columns to print. Use --help to get a list of all supported columns.
    The default list of columns may be extended if list is specified in the format +list (e.g. lsblk -o +UUID)./pre>

    A simple example:

    pbmac@pbmac-server $ lsblk -f
    NAME   FSTYPE  LABEL UUID                                 MOUNTPOINT
    loop0  squashf                                            /snap/core18/1705
    loop1  squashf                                            /snap/core18/1754
    loop2  squashf                                            /snap/nmap/1356
    sda                                                       
    ├─sda1 ext4    /     6e73a278-7609-4612-b1dc-5e7451bb3f0d /
    ├─sda2 ext4    /usr  815e345f-4e06-4a42-b19d-35cf6ef7fd32 /usr
    ├─sda5 ext4    /var  ad74f5a8-188a-4282-93a4-2107dfb08fc5 /var
    ├─sda6 ext4    /home 3709f1b7-6417-413e-a4cd-2bec3002ba25 /home
    └─sda7 swap          68e33827-8998-49f9-98a1-94415abad3bb [SWAP]

    The blkid Command

    The blkid command reads information directly from devices and for non-root users it returns cached unverified information. blkid is mostly designed for system services and to test libblkid functionality. Options and syntax are very similar to the lsblk command.

    Syntax:

    blkid [options] [device name]

    When device is specified, tokens from only this device are displayed. It is possible to specify multiple device arguments on the command line. If none is given, all devices which appear in /proc/partitions are shown, if they are recognized. See the blkid man page for additional options.

    pbmac@pbmac-server $ blkid
    /dev/sda1: LABEL="/" UUID="6e73a278-7609-4612-b1dc-5e7451bb3f0d" TYPE="ext4" PARTUUID="a3f88df0-01"
    /dev/sda2: LABEL="/usr" UUID="815e345f-4e06-4a42-b19d-35cf6ef7fd32" TYPE="ext4" PARTUUID="a3f88df0-02"
    /dev/sda5: LABEL="/var" UUID="ad74f5a8-188a-4282-93a4-2107dfb08fc5" TYPE="ext4" PARTUUID="a3f88df0-05"
    /dev/sda6: LABEL="/home" UUID="3709f1b7-6417-413e-a4cd-2bec3002ba25" TYPE="ext4" PARTUUID="a3f88df0-06"
    /dev/sda7: UUID="68e33827-8998-49f9-98a1-94415abad3bb" TYPE="swap" PARTUUID="a3f88df0-07"
    pbmac@pbmac-server $ blkid -i sda1
    /dev/sda1:
       MINIMUM_IO_SIZE="512"
       PHYSICAL_SECTOR_SIZE="512"
       LOGICAL_SECTOR_SIZE="512"

     


    04-D.11: File System Management is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?