This document shows the steps to reset the root password for ZFS file system in Solaris 10 Operating System..
Steps to Recovery the root password:
Example 1: Resetting the root Password after Booting from the Network
In this example, I boot from the network into single-user mode and I assume that the JumpStart server has been set up properly.
Note: You can also use this method if you boot from CD.
1. Boot the server from the network into single-user mode.
ok> boot net -s
2. Check what pools are available to import. The system will report that rpool is available to import.
# zpool import
3. Import rpool.
# zpool import rpool
The system will report messages similar to this:
cannot mount '/export': failed to create mountpoint
cannot mount '/export/home': failed to create mountpoint
cannot mount '/rpool': failed to create mountpoint
Although the ZFS file systems in the pool cannot be mounted, they exist.
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 12.5G 54.4G 97K /rpool
rpool/ROOT 6.97G 54.4G 21K legacy
rpool/ROOT/s10s_u8wos_08a 6.97G 54.4G 6.97G /
rpool/dump 1.00G 54.4G 1.00G -
rpool/export 2.53G 54.4G 23.5K /export
rpool/export/home 2.53G 54.4G 2.53G /export/home
rpool/swap 2G 56.4G 16K -
The file /etc/shadow that we need to access is in rpool/ROOT/s10s_u8wos_08a, whose mountpoint, /, is already in use.
# zfs get mountpoint rpool/ROOT/s10s_u8wos_08a
NAME PROPERTY VALUE SOURCE
rpool/ROOT/s10s_u8wos_08a mountpoint / local
# zfs get mounted rpool/ROOT/s10s_u8wos_08a
NAME PROPERTY VALUE SOURCE
rpool/ROOT/s10s_u8wos_08a mounted no -
4. Change the mountpoint of rpool/ROOT/s10s_u8wos_08a:
# zfs set mountpoint=/mnt rpool/ROOT/s10s_u8wos_08a
5. Mount rpool/ROOT/s10s_u8wos_08a:
# zfs mount rpool/ROOT/s10s_u8wos_08a
6. Change the password for root.
# cd /mnt/etc
# cp shadow shadow.bk
I have found that most of the time, in single-user mode, the vi editor does not perform well. So I use sed `s/current_root_passwd/new_root_password/` shadow to change the password, for example:
# sed 's/5Qa1EuzftNkIQ/v.UaDklqLain6:14586/' shadow > shadow2
# mv shadow2 shadow
7. Unmount the file system.
# cd /
# zfs umount rpool/ROOT/s10s_u8wos_08a
8. Reset the mountpoint back to /.
# zfs set mountpoint=/ rpool/ROOT/s10s_u8wos_08a
9. Reboot the system and you can log in to the system with root again.
# init 6
Example 2: Resetting the Password From a Second Disk in the System
If you have another OS, such as the Solaris 10 05/09 OS, on a second disk with a ZFS root file system, use the following procedure. This method is especially useful and practical when you are testing operating systems and applications on one development box and you need to move files between operating systems and applications.
1. With the OS running on the second disk, check what pools are available to import. The system will report that rpool is available to import.
# zpool import
2. Since the current system has rpool, import rpool on the first disk using a different name, for example, r2pool.
# zpool import rpool r2pool
You will see messages complaining that mountpoint / and /export are not empty.
3. Check that the ZFS file systems in pool r2pool are imported.
# zfs list -r r2pool
NAME USED AVAIL REFER MOUNTPOINT
r2pool 25.0G 42.0G 97K /rpool
r2pool/ROOT 6.97G 42.0G 21K legacy
r2pool/ROOT/s10s_u8wos_08a 6.97G 42.0G 6.97G /r2poolroot
r2pool/dump 8.00G 42.0G 8.00G -
r2pool/export 23.5K 42.0G 23.5K /export
r2pool/swap 10G 52.0G 16K -
4. Change the mountpoint of r2pool/ROOT/s10s_u8wos_08a and mount it.
# zfs set mountpoint=/r2poolroot r2pool/ROOT/s10s_u8wos_08a
# zfs mount r2pool/ROOT/s10s_u8wos_08a
5. Access the root file system in the first disk to change the password.
# cd /r2poolroot/etc
# vi shadow
root:5Qa1EuzftNk00:6445::::::
6. Unmount the file system.
# zfs umount r2pool/ROOT/s10s_u8wos_08a
7. Reset the mountpoint back to /.
# zfs set mountpoint=/ r2pool/ROOT/s10s_u8wos_08a
8. Set the system to boot from the first disk and reboot.
# eeprom boot-device="disk0 disk1"
9. After booting into the first disk, you will see that the root pool name is r2pool, which does not affect OS operation.
# init 6
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
r2pool 68G 15.0G 53.0G 22% ONLINE -
Great Article.
ReplyDeleteUndeniably imagine that which you stated. Your favourite reason seemed to
ReplyDeletebe on the web the easiest factor to have in mind of.
I say to you, I certainly get annoyed while folks
think about concerns that they plainly don't realize about.
You controlled to hit the nail upon the top as neatly as outlined out the whole
thing with no need side-effects , other people can take a signal.
Will probably be back to get more. Thanks
Here is my weblogthere online dating profile examples