Thursday, 9 June 2011

HowTo: Recovering Linux Grub Boot Loader Password




If you have, a password protected grub boot loader and you forgot both root and grub password, then you can recover grub-boot loader password using the following method/procedure:


* Use Knoppix cd

* Remove the password from Grub configuration file

* Reboot the system

* Change the root password

* Setup new Grub password if required (optional)

Knoppix Live cd


The best way to recovering (or reset) a password (and to solve many other problem) is useKnoppix Live CD. First downloaded knoppix and burn it on CD. Put CD into CD/DVD rom and boot the system. You need to boot system into a single user mode, at boot: prompt type linux single:

boot: linux singleMount Partition


You need to mount a partition where you grub configuration file is stored. Depend upon your Linux distribution the location of Grub configuration file changes. Following list summaries Grub configuration file location for pouplar distros:
Debian Linux Grub configuration file location: /boot/grub/menu.lst
Suse Linux Grub configuration file location: /etc/grub.conf
Red Hat/Fedora Linux Grub configuration file location: /boot/grub/grub.conf


If you forgot partition name use the fdisk -l command to obtained partition list / names:
# fdisk -lFinally, you need to mount your partition as follows:\# mount /dev/sdb1 /mntRemove The Grub Passworda) If you are using Debian Linux you need to modify /boot/grub/menu.lst file:# cd /mnt/boot/grub# vi menu.lstb) If you are using Suse Linux you need to modify /etc/grub.conf file# cd /mnt/etc# vi grub.confIf you are using Red Hat / Fedora Linux you need to modify /boot/grub/grub.conf file# cd /mnt/boot/grub# vi grub.confOnce file opened using a text editor, locate password line and remove it:password --md5 $1$9sdflksdf/sdf44kFig.03: Removing The Grub Password LineSave and close the file. Reboot the system.# sync; sync# cd /# umount /mnt# rebootChange Root passwordNow your Grub password is removed from the system. You need to login to the system without any password. To restore root user password boot system into a single user mode.1) At Grub prompt press 'e' to edit command before booting.2) Select second line3) Again, press 'e' to edit selected command4) Type the following lineinit=/bin/shORinit=/bin/bashig.04: Booting into a single user mode using Grub4) Press 'b' to boot system.5) Now you are at shell prompt. Just change root password with the passwd command:# passwdPlease note that depend upon your Linux distribution you may need to remount root partition in read/write mode before running the above command.



No comments:

Post a Comment

Twitter Bird Gadget