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. Verify that the server is booted in 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 have entries with root in the name of type /dev/mapper/vg0-root;
    • if LVM is not used, the list of storage devices will contain entries like /dev/sda1, /dev/sdb1, etc.
  4. Mount the file system, the partition will be mounted in the /newroot directory:

    • with LVM:
    infiltrate-root /dev/mapper/vg0-root
    • without LVM:
    infiltrate-root /dev/sda1
  5. If the infiltrate-root command fails, mount the filesystem manually.

  6. Perform recovery and diagnostic work.

  7. When the work is complete, exit the environment. The partition will be unmounted automatically:

    exit

Mount the file system manually

  1. Verify that server is booted in Rescue recovery and diagnostic mode.

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

    fdisk -l
  3. If the server OS has non-RAID disk partitioning, skip this step. If partitioning the disk with RAID (RAID + LVM), check if it is assembled. If RAID is assembled, there will be entries of type /dev/md in the list of storage devices. If there are none, 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 have entries with root in the name like /dev/mapper/vg0-root;
    • if LVM is not used, the list of storage devices will contain entries like /dev/sda1, /dev/sdb1, etc.
  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