Skip to main content

Mounting a file system in Linux

Before performing any operations in the Rescue mode, you need to mount the OS file system. If the disk with the system partition is connected to a hardware RAID controller, use the guide for disk partitioning without software RAID. If the system partition is in LVM, use the instructions for a system with LVM.

Mounting a file system using infiltrate-root

  1. Boot your server into the Rescue mode.

  2. Output the information about partitions on disks:

    lsblk

    The output will contain information about partitions on disks. For example:

    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
    sda 8:0 0 2.9G 0 disk
    └─sda1 8:1 0 2.9G 0 part
    sdb 8:16 0 160G 0 disk
    ├─sdb1 8:17 0 159.9G 0 part
    ├─sdb14 8:30 0 4M 0 part
    └─sdb15 8:31 0 106M 0 part

    Here sda1, sdb1, sdb14, sdb15 are the names of the partitions on the disks.

  3. Select the system partition, typically it is the largest partition on the disk. In the example in step 2 it is the sdb1 partition.

  4. Mount the file system:

    infiltrate-root /dev/<partition>

    Specify <partition> — the name of the disk partition you selected in step 3, in the example it is sdb1.

    The partition will be mounted to the /newroot directory.

  5. If the infiltrate-root command does not work, mount the file system manually.

  6. Perform recovery and diagnostic work.

  7. Exit the environment after finishing the work. The file system will be unmounted automatically:

    exit

Mounting a file system manually

  1. Boot your server into the Rescue mode.

  2. Output the information about partitions on disks:

    lsblk

    The output will contain information about partitions on disks. For example:

    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
    sda 8:0 0 2.9G 0 disk
    └─sda1 8:1 0 2.9G 0 part
    sdb 8:16 0 160G 0 disk
    ├─sdb1 8:17 0 159.9G 0 part
    ├─sdb14 8:30 0 4M 0 part
    └─sdb15 8:31 0 106M 0 part

    Here sda1, sdb1, sdb14, sdb15 are the names of the partitions on the disks.

  3. Select the system partition, typically it is the largest partition on the disk. In the example in step 2 it is the sdb1 partition.

  4. Mount the file system to the /mnt directory:

    mount /dev/<partition> /mnt

    Specify <partition> — the name of the system partition on the disk you selected in step 3, in the example it is sdb1.

  5. Mount the system file systems:

    mount -t proc /proc /mnt/proc
    mount -t sysfs /sys /mnt/sys
    mount --bind /dev /mnt/dev
    mount -t devpts /dev/pts /mnt/dev/pts
  6. Connect to the environment:

    chroot /mnt /bin/bash
  7. Export the PATH variable:

    export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
  8. Perform recovery and diagnostic work.

  9. After finishing the work, exit the environment:

    exit
  10. Unmount the system file systems:

    umount -t devpts /dev/pts /mnt/dev/pts
    umount --bind /dev /mnt/dev
    umount -t sysfs /sys /mnt/sys
    umount -t proc /proc /mnt/proc
  11. Unmount the file system:

    umount /dev/<partition> /mnt

    Specify <partition> — the name of the system partition whose file system you mounted in step 4, in the example it is sdb1.