[Gentoo Linux]- Restoring the root password

Last update on August 6, 2009 06:21 PM by jak58
Published by jak58

[Gentoo Linux]- Restoring the root password







If you lose your root password the easiest way to recover it is to use the LiveCD
  • Boot with the LiveCD
  • Launch the fdisk command and then use the p option for the device on your boot partition and root.


# fdisk  /dev/sda


The number of cylinders for this disk is set to 9726.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa08da08d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         256     1951897+  82  Linux swap / Solaris
/dev/sda3             257        9726    76067775   83  Linux
  • Mount the sda3 partition (or equivalent)

# mount /dev/sda3 /mnt/gentoo
  • Use chroot command in the mounted environment

# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"
  • Change the root password

#passwd 
  • Reboot without Live CD

If you do not have a LiveCD, you must reboot the system in single user mode to reset the user password.
At Kernel level the following changes must be made init=/bin/sh (via bootloader menu).
When the system starts, it will launch a root shell, the drive will be mounted as read-only mode and you ,ust set it to write/read mode, in the following command ROOT must be replaced by root partition.

mount -o rw,remount /dev/ROOT


Then edit etc/shadow and remove the encrypted password. Reset the root password with the passwd command and reboot the system.
Best answers for « Restoring the root password » in :
Reinitializing the root password of MySQL Show Reinitializing the root password of MySQL The root password is lost! Reinitializing the password: It's important that you are able to access and modify the admin (root) password of MYSQL, either when installing MySQL for the first...
PhpMyAdmin - Access denied for user root@localhost Show PhpMyAdmin - Access denied for user root@localhost To reset the rights of the root user Insert the host and password Beginners may face the problem of accessing MySql by the root user. This issue happens when the root requires you...
How to reset your OS X password without an OS X CD? ShowHow to reset your OS X password without an OS X CD? Issue Solution Note Issue I forgot my admin password and I lost my OS X disk! How can I reset the admin password? Solution Here is the best and easiest way how to reset your OS X...
[Windows XP] Support/Backup/Recovery/Repair Show[Windows XP] Support/Backup/Recovery/Repair Remote Assistance System Restore Recovery Console Here are some methods to handle major problems with Windows XP Remote Assistance You can ask an expert to troubleshoot your system...
Backup/Restore Mysql database ShowBackup/Restore Mysql database Backup Restore your database Note A simple approach on how to backup and restore MySQL databases. Backup To save an existing database it is recommended that you create a dump. To dump all...
Download Password Cracker ShowEach time you must create a count on Websites, he asks you for an identifying or "Login" and for a password. Then when you have a good time giving different names and different passwords for every count, it is rather easy to forget it. Password...
Download Password Generator Professional 2009 ShowSave time when you need to generate a large number of passwords or license keys by using Password Generator Professional, a powerful application capable of creating strong passwords from random numbers. Advantage The program offers a truly...