Skip to main content
Mount a file system in Linux
Last update:

Mount a file system in Linux

Before any operations in Rescue mode, you must mount the OS file system.

  1. Make sure that the server loaded in the Rescue recovery and diagnostic mode.

  2. Output data about storage devices (disks and partitions created on them):

    fdisk -l
  3. Determine if LVM (logical volume manager) is in use:

    • If LVM is used, the list of storage devices will include entries with root type name /dev/mapper/vg0-root;
    • If LVM is not used, the list of storage devices will contain entries of type /dev/sda1, /dev/sdb1 et cetera.
  4. Mount the file system, the partition will be mounted in the directory /newroot:

    • with LVM:
    infiltrate-root /dev/mapper/vg0-root
    • without LVM:
    infiltrate-root /dev/sda1
  5. If the command infiltrate-root doesn't work, mount the file system manually.

  6. Perform recovery and diagnostic work.

  7. When finished, exit the environment. The partition will be unmounted automatically:

    exit

Mount the file system manually

  1. Make sure that the server is booted in the Rescue and Diagnostic mode.

  2. Output data about storage devices (disks and partitions created on them):

    fdisk -l
  3. If the server OS has disk partitioning without RAID, skip this step. If the disk is partitioned with RAID (RAID + LVM), check if it is built. If RAID is built, the list of storage devices will contain entries like /dev/md. If they are not present, assemble the components of the previously created RAID into a RAID:

    mdadm --assemble --scan
  4. Determine if LVM (logical volume manager) is in use:

    • If LVM is used, the list of storage devices will contain entries with root type name /dev/mapper/vg0-root;
    • If LVM is not used, the list of storage devices will contain entries of type /dev/sda1, /dev/sdb1 et cetera.
  5. Mount the file system, the partition will be mounted in the /mnt directory:

    • with LVM :
    mount /dev/mapper/vg0-root /mnt
    • without LVM:
    mount /dev/sda1 /mnt
  6. Connect to the environment using the command:

    chroot /mnt /bin/bash
  7. Perform recovery and diagnostic work.

  8. Exit the environment when the work is complete:

    exit
  9. Unmount the file system:

    umount /dev/sda1 /mnt