Thursday, June 29, 2006

ZFS Root on Solaris Part 3

Hopefully, you have had success and you now have root on ZFS. In this next post I will describe how to get access to the root partition from failsafe. If you tried like me, you will find that you cannot see the zfs filesystems from failsafe. This is because the zpool.cache configuration file in /etc/zfs has not been copied onto the failsafe miniroot. One thing that is not wise at this point is to use the command "zfs import -f [pool_name]", to import the pool. While it may work, it will probably make your pool inaccessible when you next boot. So what you need to do is to copy the configuration file from your running system into the failsafe miniroot archive. Let' get into it. The steps are -

1) Boot ZFS root partition and get access to root

2) gunzip your miniroot image into /tmp

gzcat /grub/boot/x86.miniroot-safe > /tmp/miniroot.img

3) Using the loopback filesystem to mount the image on /mnt - replace the /dev/lofi/1 with appropriate returned device

lofiadm -a /tmp/miniroot.img
mount /dev/lofi/1 /mnt

4) Copy the file /etc/zfs/zpool.cache into /mnt/etc/zfs

cp -p /etc/zfs/zpool.cache /mnt/etc/zfs

5) unmount the filesystem

umount /mnt
lofiadm -d /tmp/miniroot.img

6) gzip the image back to grub.

gzip -c /tmp/miniroot.img > /grub/boot/x86.miniroot-safe

7) Edit the /grub/boot/grub/menu.lst and make sure that there is an identical "root" entry for failsafe and ZFS. Below are the entries for my machine.

#---------- ADDED BY BOOTADM - DO NOT EDIT ----------
title Solaris failsafe
root (hd0,0,a)
kernel /boot/multiboot kernel/unix -s
module /boot/x86.miniroot-safe
#---------------------END BOOTADM--------------------
title Solaris ZFS
root (hd0,0,a)
kernel /boot/multiboot
module /boot/boot_archive

8) You should now be able to reboot into failsafe and see your zfs pool with the "zpool list" command. Also you should be able to see your root filesystem with the "zfs list" command. When you booted, it would have asked you if you want to mount a filesystem on /a. If you answered yes, then unmount it with "umount /a". Now you can use the mount command to mount your ZFS root filesystem on to /a. Note, I previously named my root filesystem "intdisk/snv42_root". Change the command to suite your setup. Also don't forget to add the option "-F zfs". If you dont, mount will try NFS....

mount -F zfs intdisk/snv42_root /a

Finally you can now cd into /a and fix your system. Enjoy!!!

1 comment:

Dick said...

Does the 'zpool import -f can hang your next reboot' issue still apply?