Repair Corrupted File System
Repair Corrupted File System
Mount -n -o remount , rw /
1. If you don’t know the device name, use fdisk, df , or any other tool to
find it.
2. Unmount the device:
If you want to check or repair the root file system, you have several options
at your disposal. You can set the fsck to run on boot, boot the system in
recovery mode, or use a live CD.
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:
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
[…]
If using LVM,
# pvscan
# vgscan
# lvscan
# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID 335qTi-Ossg-32O5-yQC7-xNON-egdI-frj4et
LV Size 3.34 GB
Current LE 107
Allocation inherit
# vgchange -ay
# e2fsck -f -y /dev/VolGroup00/LogVol00
[...]
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.
If you've lost your root password, you might be able to recover it using the steps below. However,
some systems are protected with boot loader passwords that will not let you do that without THAT
password. If the boot loader is password protected, you need to boot from other media Like the
OpenSUSE CD/DVD/mini-boot. OpenSUSE install CD is probably the best one to use.
CD/DVD Recovery Mode
If using CD/DVD boot media, You need to choose Rescue System. You enter root and then mount the
disk manually. For example, a Compaq raid controller will probably be /dev/ida/c0d0 or an IDE drive
will be /dev/hda1. Find the partitions by using fdisk /dev/ida/c0d0 or fdisk /dev/hda (just "p" and quit)
and then mount what you need.
# cd /mnt
# chroot /mnt
# passwd
Start the rescue system. Find the disk root partition, then, assuming its hdxy (or probably sdxy):
chroot /mnt
you are root in the installed sytem, with all at hand: passwd, but also YaST...
"bind" allow using two mount points for system virtual folders.
If all fails, consider that you can pull this drive (or install another drive in this machine) and mount it
from another running Linux. Then recover the root password as explained above.
The first thing to try is to boot to single user mode. This MIGHT not work for you, because your
system might be configured to still ask for a root password to get to single user mode. If that's the
case, we'll use another trick that replaces init with /bin/bash.
First, try single user. If you don't see either a LILO or GRUB boot screen, try hitting CTRL-X to get
one. If it's LILO, just type "linux single" and that should do it (assuming that "linux" is the lilo label). If
GRUB, hit 'e", then select the "kernel" line, hit "e" again, and add " single" (or just " 1") to the end of
the line. Press ENTER, and then "b" to boot. (Newer version of grub uses "a" to append to the boot
line)
You should get a fairly normal looking boot sequence except that it terminates a little early at a bash
prompt. If you get a "Give root password for system maintenance", this isn't going to work, so see the
"init or /bin/bash" version below.
If you do get the prompt, the / filesystem may not be mounted rw (although "mount" may say it is). Do
mount -o remount,rw /
If that doesn't work (it might not), just type "mount" to find out where "/" is mounted. Let's say it is on
/dev/sda2. You'd then type:
If you can do this, just type "passwd" once you are in and change it to whatever you like. Or just
edit /etc/shadow to remove the password field: move to just beyond the first ":" and remove everything
up to the next ":". With vi, that would be "/:" to move to the first ":", space bar once, then "d/:" and
ENTER. You'll get a warning about changing a read-only file; that's normal. Before you do this,
/etc/shadow might look like:
root:$1$8NFmV6tr$rT.INHxDBWn1VvU5gjGzi/:12209:0:99999:7:-1:-
1:1074970543
bin:*:12187:0:99999:7:::
daemon:*:12187:0:99999:7:::
adm:*:12187:0:99999:7:::
root::12209:0:99999:7:-1:-1:1074970543
bin:*:12187:0:99999:7:::
daemon:*:12187:0:99999:7:::
adm:*:12187:0:99999:7:::
You'll need to force the write: with vi, ":wq!". (If that still doesn't work, you needed to do the -o
remount,rw, above).
Another trick is to add "init=/bin/bash" (LILO "linux init=/bin/bash" or add it to the Grub "kernel" line).
This will dump you to a bash prompt much earlier than single user mode, and a lot less has been
initialised, mounted, etc. You'll definitely need the "-o remount,rw" here. Also note that other
filesystems aren't mounted at all, so you may need to mount them manually if you need them. Look
in /etc/fstab for the device names.
Keep this in mind if you have a Linux machine in a publically accessible place : without more
protection, it's not usually hard to recover a lost root password, which means it's just as easy for
someone to CHANGE it, or access root without your knowledge.
Another way to do this is to remove the password from /etc/shadow. Just in case you screw up, I'd
copy it somewhere safe first. You want to end up with the root line looking something like this:
Original line:
root:$1$EYBTVZHP$QtjkCG768giXzPvW4HqB5/:12832:0:99999:7:::
After editing:
root::12832:0:99999:7:::
If you are having trouble with editing (you really do have to learn vi one of these days), you could just
(after making a copy, of course) just
FOR CENTOS 6
Option A
1. Boot Computer & Interrupt (Press space).
3. Append 1 at the end of “rhgbquiet” and press ‘Enter’ key to boot in Single mode.
Option B
1. Bootsystem and list avaiable kernel version. (Press any key to enter the menu)
2. Press ‘e’.
6. Type password.
FOR CENTOS 7
1. Reboot your system, and interrupt the countdown in the boot loader menu.
a. Send a Ctrl+Alt+Del to your system using the relevant button or menu entry.
b. When the boot loader menu appers, press any key to interrupt the countdown.
2. Edit the default boot loader entry (in memory) to abort the boot process just after
all file systems have been mounted, but before control is handed over to systemd,
then boot.
a. Use the cursor keys to highlight the default boot loader entry.
https://www.unixarena.com/2013/09/redhat-linux-how-to-fix-read-only-root.html/
One of the most common problem in Redhat Linux is “read only root filesystem”
when there is issue with hardware or SAN sub-systems .To fix the “read only
filesystem” issue ,you need to reboot the server.But while rebooting the server,
you will definitely encounter many issues and that requires a manual intervention
by logging in with the root. Unfortunately you may not logging as root if root
filesystem is corrupted and it will not accept the root password. In this case, you
need to boot the system in rescue mode using Redhat Linux DVD.
Here is the steps which you need to try before rebooting the system
in rescue mode using Redhat Linux DVD.
4.If the system is booted in maintenance mode and not accpeting the root
password, then you need to boot the system in rescue mode using redhat Linux
DVD.
1.Insert the redhat DVD and boot the system in rescue mode.
5.If you are not using “LVM” for root filesystem,execute fsck on the device which
contains the root filesystem
UnixArena# e2fsck -f /dev/sda1
e2fsck 1.51.12 (17-May-2013)
[...]
6.If you are using LVM for root filesystem, You need to activate the logical volumes
using below method.
# lvm pvscan
PV /dev/sda1 VG VolGroup00 lvm2 [996.00 MB / 0 free]
Total: 1 [8.48 GB] / in use: 1 [8.48 GB] / in no VG: 0 [0 ]
# lvm vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
# lvm lvscan
INACTIVE '/dev/VolGroup00/LogVol00' [8.48 GB] inherit
7.Run fsck on the root filesystem logical volume to check the integrity.
# e2fsck -f /dev/mapper/VolGroup00/LogVol00
e2fsck 1.51.12 (17-May-2013)
[...]
8.Exit the rescue mode and boot the system normally.
I have seen many times , redhat Linux which is running on VMWARE ESX may face
this issue.In these cases , you need to follow the below steps.
1. Update VMware tools .
2. Migrate the affected virtual machine to other datastore and monitors the virtual
machine. If issue doesn’t reappears, It could be problem with the storage. Engage
the storage vendor.
2. Even after the storage migration, if issue reoccurs .Update the Linux kernel to
the latest version.
3. Increase the SCSI timeout of each disk presented from VMWare as per
the Redhat Linux article.
To troubleshoot further on VMWARE ESX for this issue, Please follow this article.
Thanks to www.vmwarearena.com
Thank you for visiting UnixArena. Please leave a comment if you have any doubt.
https://forums.centos.org/viewtopic.php?t=2040&p=11497
Post by bubber14 » 2013/11/17 00:56:56
in maitenace mode
mount -o remount,rw /