Friday, June 22, 2012

Root Password Recovery - Solaris 10 without using CD/DVD

     In The Name Of Allah The Beneficent The Merciful
                  1. Bring the server at OK prompt
# init 0
2.Boot the system using new boot mode called Failsafe mode which is used to boot your server from RAM without any need of CD/DVD.
{0} ok boot -F failsafe
Starting shell.

# uname –a

SunOS 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-V245
# df –k

Filesystem kbytes used avail capacity Mounted on
/ramdisk-root:a 201463 178943 2374 99% / ————> Server booted from RAM.
/devices 0 0 0 0% /devices
ctfs 0 0 0 0% /system/contract
proc 0 0 0 0% /proc
mnttab 0 0 0 0% /etc/mnttab
swap 7725248 320 7724928 1% /etc/svc/volatile
objfs 0 0 0 0% /system/object
sharefs 0 0 0 0% /etc/dfs/sharetab
swap 7725504 576 7724928 1% /tmp
/tmp/dev 7725504 576 7724928 1% /dev
fd 0 0 0 0% /dev/fd
#

Note: Sometimes (always with X-86 servers) the Failsafe mode will ask you to mount the rootdisk before giving you the Shell prompt. Do not mount at that time, just say No everywhere and bring the failsafe mode at Shell Prompt and then do the mount and update archive manually.
3.      Once your server will boot up in Failsafe, mount your rootdisk at /a. Here my rootdisk is c1t1d0s0.
# mount /dev/dsk/c1t1d0s0 /a
# df -h /a

Filesystem size used avail capacity Mounted on
/dev/dsk/c1t1d0s0 7.9G 7.1G 714M 92% /a
4.      Take a copy of /a/etc/passwd & /a/etc/shadow file.
# cp -p /a/etc/passwd /a/etc/passwd-orig
# cp -p /a/etc/shadow /a/etc/shadow-orig
5.      Remove the encrypted password entry for root from /a/etc/shadow file
Before Modifications:
#grep root /a/etc/shadow
root:WP7grKsEFAgt.:15182::::::
After Modifications:
#grep root /a/etc/shadow
root::15182::::::
6.      Update the boot archive as below before proceeding with the reboot.
# bootadm update-archive -R /a
Creating boot_archive for /a
updating /a/platform/sun4u/boot_archive
7.      Reboot your system
# init 6
This time you are allowed to login into the server without password. Set the root password.
Note: The procedure for Solaris X-86 is also same, In X-86 select the Failsafe mode from GRUB Menu which is present in the GRUB menu bydefault. The GRUB is picking the entry from /boot/grub/menu.lst.

No comments:

Post a Comment