Mount a file system in Linux
Before any operations in Rescue mode, you must mount the OS file system.
-
Verify that the server is booted in Rescue recovery and diagnostic mode.
-
Output data about storage devices (disks and partitions created on them):
fdisk -l
-
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.
- if LVM is used, the list of storage devices will have entries with
-
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
-
If the
infiltrate-root
command fails, mount the filesystem manually. -
Perform recovery and diagnostic work.
-
When the work is complete, exit the environment. The partition will be unmounted automatically:
exit
Mount the file system manually
-
Verify that server is booted in Rescue recovery and diagnostic mode.
-
Output data about storage devices (disks and partitions created on them):
fdisk -l
-
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
-
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.
- if LVM is used, the list of storage devices will have entries with root in the name like
-
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
-
Connect to the environment using the command:
chroot /mnt /bin/bash
-
Perform recovery and diagnostic work.
-
Exit the environment when the work is complete:
exit
-
Unmount the file system:
umount /dev/sda1 /mnt