13 C
Texas
Melhttp://www.osradar.com
Guru Unix /Linux and GNU supporter

How to Recover Corrupted Partition using Rescue Mode in CentOS/RHEL

The root partition is the core of every Linux system’s heart. This is the place where the operating system is stored. This is also the place where every single app are installed and important operations are performed. That’s why it’s really important that no data corruption happens to this part of the hard drive.

However, due to the nature of the hardware, data is prone to corruption. There can be any accidental data deletion or other problems that may cause the root partition lose important data, thus the system can’t boot anymore.

If you’re using CentOS/RHEL in your system or server, you can easily recover the data of a corrupted root partition from the “Rescue” mode.

Root partition corruption

If the partition is corrupted, you’ll get the following error:

- Advertisement -
Checking all file systems.
[/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/VolGroup00/LogVol00
/dev/VolGroup00/LogVol00 contains a file system with errors, check forced.
/dev/VolGroup00/LogVol00: Inodes that were part of a corrupted orphan linked list found.

/dev/VolGroup00/LogVol00: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
[FAILED]

*** An error occurred during the file system check.
*** Dropping you to a shell; the system will reboot
*** when you leave the shell.
Give root password for maintenance

It indicates that the data in the partition is corrupted. For recovering,

  • Boot the system from the CD/DVD of the same release of the installed system. After the system boots successfully from the ISO, run this command without quotes. It’ll look like this:
boot: linux rescue
  • When asked, enter all the required information like keyboard layout, language and pertinent information for the system. When you’ll be asked for network device enabling, select “No”.
  • When you’ll be prompted to allow rescue environment mounting Oracle Linux installation under “/mnt/sysimage”, directory, select “Skip”.
  • Depending on the LVM usage on the system, run the following commands:

If not using LVM,

# e2fsck -f /dev/sda1
e2fsck 1.41.12.14 (17-May-2014)
[…]

If using LVM,

# pvscan
PV /dev/sda1 VG VolGroup00 lvm2 [96.00 MB / 0 free]
Total: 1 [3.34 GB] / in use: 1 [3.34 GB] / in no VG: 0 [0 ]
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
# lvscan
INACTIVE '/dev/VolGroup00/LogVol00' [3.34 GB] inherit
# lvdisplay 

--- Logical volume --- 
LV Name /dev/VolGroup00/LogVol00 
VG Name VolGroup00 
LV UUID 335qTi-Ossg-32O5-yQC7-xNON-egdI-frj4et 
LV Write Access read/write 
LV Status NOT available 
LV Size 3.34 GB 
Current LE 107 
Allocation inherit 
Read ahead sectors 0
# vgchange -ay
1 logical volume(s) in volume group "VolGroup00" now active
# e2fsck -f -y /dev/VolGroup00/LogVol00
e2fsck 1.41.12.14 (17-May-2014)
[...]

After the process is complete, exit rescue mode, remove the CD/DVD or boot device from the system and reboot the machine normally.

It should work just fine. If the luck is still not in your favor, you may want to re-install the system.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article