Thursday, January 5, 2012

What to Do If the Root Password Is Lost in sun solaris operating system?

1) Insert the Solaris Operating System CD-ROM into the CD-ROM drive.

2) Once the CD-ROM is in the drive, perform a stop-a command. This brings the system down to the ok prompt.

3) From the ok prompt, perform a single-user boot from the Solaris 2.x installation CD-ROM.

ok  boot cdrom -s

4) At the "#" prompt, try to determine which disk is the system's boot disk (containing the root file system).

There are several Sun architectures and various configurations of the systems when it comes to a boot disk. As a general rule, most boot disks are attached to controller 0 (c0). Usually, their SCSI target is either 3 (t3) or 0 (t0). However, because Sun machines are very flexible, the boot disk could be at a different location.

NOTE: If your boot disk is MIRRORED using Solaris Disksuite[TM] or Solaris[TM] Volume Manager software, "Solaris[TM] Volume Manager software and Solstice DiskSuite[TM] software: Mounting metadevices" This article explains how to mount a metadevice without breaking the integrity of the mirrored data.

5) At the "#" prompt, enter the following:

# eeprom boot-device

The output might appear to be simple, such as "disk" or "disk1," or as a pathname "/iommu/sbus/espdma@4,8400000/...../sd@3,0:a". Make note of the boot-device. If the boot-device is a pathname, it is beyond the scope of this Technical Instruction to provide the location of the customized boot disk. However, for most configurations, you can find the location easily.

6) The "Format" command shows you all available disks:

# format
    Searching for disks...done
    AVAILABLE DISK SELECTIONS:
           0. c0t0d0 

             /pci@1f,0/pci@1,1/ide@3/dad@0,0
    Specify disk (enter its number):

7) Press d to exit format.

Now, you will have an idea what disks are on the system. If the boot-device is "disk" and the format shows "c0t0d0" (or on some systems "c0t3d0"), then that is a boot device. If the boot-device shows "disk1" and the format shows "c0t1d0," then that is the boot device. If format shows multiple disks, then based on what the "eeprom boot-device" command shows, the boot disk would be:

boot-device        format
disk               c0t0d0 or c0t3d0 (machine dependent)
disk1              c0t1d0
disk2              c0t2d0
disk3              c0t3d0 or c0t0d0 (machine dependent)

and so on ....

8) Because the system was not brought down gracefully (no root password, means having to use the Stop-a keystroke to "crash" the system), you should run "fsck" to clean the root partition (slice). Fsck also confirms that you selected the proper slice:

   # fsck /dev/rdsk/cXtYd0s0

where the X and Y are determined by the previous procedure . It is also possible to have a root partition that is not on slice 0 (s0), but, again, that is not a standard configuration. The output of "fsck" will look like this:

** /dev/rdsk/c0t0d0s0
** last mounted on /
** Phase 1 .....

.....

The second line "** Last mounted on /" confirms that this is the correct root fs partition.

9) Answer "y" to any questions fsck asks. There shouldn't be too many items needing repair. If there are numerous items needing repair, then there could be a corrupted root fs.

10) After fsck is finished, you can mount the root partition:

# mount /dev/dsk/cXtYd0s0 /a

Again, X and Y are same as for the fsck command.

Example:

# mount /dev/dsk/c0t0d0s0 /a

11) From the root prompt, enter the following command:

# TERM=sun; export TERM

12) Edit the /etc/shadow file:

# vi /a/etc/shadow

The first line of the file is almost always the one you want to modify. The first line looks like this:

root:c3.yAVmYodWsc:6445::::::

13) Delete every character between the first and second colons in the first line.

When you finish the process, the first line should look like this:

root::6445::::::

14) After you delete the characters in the first line, enter the following (in the command mode) to perform a write force quit to exit the document and save the changes:

:wq!

15) Unmount the file system, as follows:

# cd /
# umount /a

16) Reboot the system:

# reboot

The preceding command shuts down the system and brings it back up in multi-user mode.

17) At the login window, log in as root. You should get in automatically.

18) Change the root password immediately.

No comments: