Sunday, August 23, 2009

Reset a forgotten root password with a live CD

Info from here
If you have forgotten the root password of a system, you can very easily reset it with a live CD. Any live Linux cd from standard Linux distros such a ubuntu , knoppix etc can be used.

Boot the system with the live CD. Open a terminal and use dmesg command to find out the hard disk. The ide hard disk are generally named as hda, hdb etc. SATA and SCSI disks are named sda sdb etc.
You have to find out where your root partitions is mounted. You can use cfdisk to find out the partitions.
$sudo cfdisk /dev/sda

You can examine the screen and find out the Linux partitions . If you have multiple installations , this can be tricky. You can quit from cfdisk and return to terminal. Now, try to mount the desired partition into some directory. ( Assuming that you Linux partition is /dev/sda2 , the following commands are described.)
Acquire root powers on the terminal with ( in the case of ubuntu live cd which I use)
$sudo su
# mount /dev/sda2 /mnt/

Now, chroot to /mnt
# chroot /mnt

Change the password
# passwd

Next unmount the partition and enjoy .

# umount /mnt

No comments:

Post a Comment