Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Rescue Mode

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8

####################################RESCUE

MODE######################################

1:

#vi /etc/grub.conf

# grub.conf generated by anaconda


#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,2)
# kernel /vmlinuz-version ro root=/dev/hda6
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=9
splashimage=(hd0,2)/grub/splash.xpm.gz
hiddenmenu
password --md5 $1$Bw.kp$41Z8tyvP6tTfGXMKajmxy/
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,2)
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-53.el5.img
title WINDOWSXP
rootnoverify (hd0,0)
chainloader +1

In this file :
root (hd0,2) just change this to
root (hd1,2)
By doing this the system will not be able to boot properly.
so we have to edit the file at the grub screen by pressing "e"
where you have to edit the line given below:

root (hd1,2)
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-53.el5.img

here you see it is root (hd1,2)


so you have to change it to (hd0,2)
then you have to press "b" to boot the O.S.
After proper booting of the O.S. you have to manually open the grub file and do the
changes which we did at the grub screen.

###################################################################################

2:

#vi /etc/grub.conf
default=0
timeout=9
splashimage=(hd0,2)/grub/splash.xpm.gz
hiddenmenu
password --md5 $1$Bw.kp$41Z8tyvP6tTfGXMKajmxy/
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,2)
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-53.el5.img
title WINDOWSXP
rootnoverify (hd0,0)
chainloader +1

in this file :

kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet

just change it to

kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/root rhgb quiet

by doing this also your machine wil not boot .

so the solution:

at the grub screen again you have to press "e" to edit the file.
then again press "e" to edit the line given below:

kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/root rhgb quiet


now in this line change LABEL=/root to LABEL=/

and then again press "b" to boot the system. and after proper login again do the
changes in /etc/grub.conf file as we did in grub screen.

###################################################################################

3:

#vi /etc/grub.conf
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,2)
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-53.el5.img

again in this file in the below line:

kernel /vmlinuzz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet

here you see the spelling of /vmlinuz is /vmlinuzz so bcoz of which your O.S.cant
boot
so you have to go in grub screen and press "e" to edit the file
and just edit it to from /vmlinuzz to /vmlinuz then press "b" to boot the O.S.
and after booting edit the /etc/grub.conf file and do the changes which we did at
the grub screen.

###################################################################################

4:

cd /boot

over here we will see a file called

initrd-2.6.18-53.el5.img
just change the name of this file is
#mv initrd-2.6.18-53.el5.img initrd-2.6.18-53.el5.img.corrupt

so by doing this your system cant boot,


so at the grub screen again press "e" to edit the file and modify the line i.e:

initrd-2.6.18-53.el5.img
just add corrupt ahead of this line

initrd-2.6.18-53.el5.img.corrupt
and then press "b" to boot the system.
and after booting go to

#cd /boot
and again make the file normal as

#mv initrd-2.6.18-53.el5.img.corrupt initrd-2.6.18-53.el5.img

###################################################################################
##

5:

vi /etc/fstab

LABEL=/ / ext3 defaults 1 1


LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/home /home ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda6 swap swap defaults 0 0
/dev/sda9 /var/ftp/pub ext3 defaults 0 0
~
in this file just change :
LABEL=/ to LABEL=/root

LABEL=/ / ext3 defaults 1 1

LABEL=/root / ext3 defaults 1 1

so here you can see there is /root in place of / which is wrong ,


by doing this you get a error at the booting so to troubleshoot we have to boot the
machine via first cd or dvd of RHEL 5.

at the first screen you have to press

boot:linux rescue
your machine wil boot from cd in rescue mode next

do the following steps of booting

ok --> ok --> no(networking) --> continue --> ok


after doing this steps you will be in this prompt:
sh-3.1#fdisk -l
now you will see the total no of partitions in your system
sh-3.1#df -h
here you will see that your partitions are mounted under /mnt/sysimage, but
your "/" will not be mounted so mount it manually

sh-3.1#mount /dev/sda2 /mnt/sysimage

sh-3.1#cd /mnt/sysimage
sh-3.1#cd /etc
now edit the fstab file by nano editor and remove "root" from "/root" from the
first line in the file
sh-3.1#nano fstab
save the file (important) press ctrl+x then press y to save the file
sh-3.1#reboot

reboot the system and remove the cd from your cdrom ad your system will boot
properly.

###################################################################################

6:

#cd /etc
#mv fstab fstab.corrupt

by doing this also your system will not boot so the solution:

boot the machine with RHEL 5 cd/dvd


at the first screen you have to press

boot:linux rescue
your machine wil boot from cd in rescue mode next

do the following steps of booting

ok --> ok --> no(networking) --> continue --> ok


after doing this steps you will be in this prompt:

sh-3.1#fdisk -l
now you will see the total no of partitions in your system
sh-3.1#df -h
here you will see that no partitons are mounted under /mnt/sysimage,so mount it
manually
sh-3.1#mkdir /mnt/sysimage
sh-3.1#e2label /dev/sda2
to check which is your "/" partition
sh-3.1#mount /dev/sda2 /mnt/sysimage
sh-3.1#cd /mnt/sysimage
sh-3.1#cd etc
sh-3.1#ls
check for your fstab file its name is being changed so make it normal
sh-3.1#mv fstab.corrupt fstab
and then just check the file for confirmationa and reboot
sh-3.1#reboot

reboot the system and remove the cd.


##################################################################################

7:
# vi /etc/inittab

# Default runlevel. The runlevels used by RHS are:


# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

now in this file we specify our run level through wich we have to boot the O.S

so if we remove the run level value from the line:


id:5:initdefault:

and make it as

id::initdefault:

by doing this what will happen to your system.


Your system will go in runlevel "9"
Oh what that ,dont worry reboot the system, at the grub screen press "a",
then give space and type "1" to boot your sytem in single user mode.
after coming in single user mode:

sh-3.1#

open your /etc/inittab file.


sh-3.1#vi /etc/inittab

# Default runlevel. The runlevels used by RHS are:


# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id::initdefault:

here we see that in the line that is :

id::initdefault:

there is no runlevel specified so we go in insert mode and put the value of the
runlevel through
which we have to boot the system ,so make it like this:

id:5:initdefault:

and then save the file and reboot the system it will work fine.
###################################################################################
###############

8:

#vi /etc/inittab

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

now in this paragraph we do this changes:

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 6
l3:3:wait:/etc/rc.d/rc 6
l4:4:wait:/etc/rc.d/rc 6
l5:5:wait:/etc/rc.d/rc 6
l6:6:wait:/etc/rc.d/rc 6

i replace the last digit with "6"


and save the file ,now if i reboot the system it will not be able to boot.
as my system start's rebooting,
so reboot the system at the grub screen press "a" and give space and type "1" to go
in single user mode:
after going in single user mode open the /etc/inittab file for editing:

sh-3.1#vi /etc/inittab

here we see the paragraph been misconfigured as given below:

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 6
l3:3:wait:/etc/rc.d/rc 6
l4:4:wait:/etc/rc.d/rc 6
l5:5:wait:/etc/rc.d/rc 6
l6:6:wait:/etc/rc.d/rc 6

as all values set to "6" so we change the values as per the run levels:

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
and then save the file and reboot the system.it works fine.

###################################################################################
################

9: If you forget "root" and "grub" password ??

#vi /etc/grub.conf

# grub.conf generated by anaconda


#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,4)
# kernel /vmlinuz-version ro root=/dev/hda7
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=9
splashimage=(hd0,4)/grub/splash.xpm.gz
hiddenmenu
password --md5 $1$g2kNq$OILDgjY1gBNAhU9PKtivu0
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,4)
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-53.el5.img
title WINDOWSXP
rootnoverify (hd0,0)
chainloader +1

here in this file we see the grub password is been set:


but imagine after reboot of your system you came to know that you have forgotten
the password so how to crack.

reboot the system:

boot the machine with RHEL 5 cd/dvd


at the first screen you have to press

boot:linux rescue
your machine wil boot from cd in rescue mode next

do the following steps of booting

ok --> ok --> no(networking) --> continue --> ok


after doing this steps you will be in this prompt:

sh-3.1#
at this prompt you have to give the following command.

sh-3.1#chroot /mnt/sysimage
sh-3.1#vi /etc/grub.conf

default=0
timeout=9
splashimage=(hd0,4)/grub/splash.xpm.gz
hiddenmenu
password --md5 $1$g2kNq$OILDgjY1gBNAhU9PKtivu0
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,4)
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-53.el5.img
title WINDOWSXP
rootnoverify (hd0,0)
chainloader +1
here we found that the grub password is set so we remove the password line and the
file will look
like this:

default=0
timeout=9
splashimage=(hd0,4)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,4)
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-53.el5.img
title WINDOWSXP
rootnoverify (hd0,0)
chainloader +1

after removing password line reset the password for root:

sh-3.1#passwd
Changing password for user root.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
sh-3.1#

so now i have removed the grub password and also reset my new root password.
then exit and reboot the system and remove the cd from cdrom.

###################################################################################
################

You might also like