Saturday, 12 March 2011

Creating Alternate Boot Enviornment for ZFS

 Today i learned how to create an alternate boot enviornment for a ZFS installed solaris SPARC machine.
I follwed the below steps:
                                                                                                                          

Check if any boot enviornments are created already or not
1)bash-3.00# lustatus
  ERROR: No boot environments are configured on this system
  ERROR: cannot determine list of all boot environment names
---------------------------------------------------------------------------------------

so here only one boot enviornment is configured,now we can create
one more boot enviornment by 'lucreate' command with the alternate 
boot enviornment name as 's10s_u9wos_14a2'(here i have given name to my choice) 

2)bash-3.00# lucreate -n s10s_u9wos_14a2
  
  Analyzing system configuration.
  No name for current boot environment.
  INFORMATION: The current boot environment is not named - assigning name <s10s_u9wos_14a>.
  Current boot environment is named <s10s_u9wos_14a>.
  Creating initial configuration for primary boot environment <s10s_u9wos_14a>.
  The device </dev/dsk/c1t0d0s0> is not a root device for any boot environment; cannot get BE ID.
  PBE configuration successful: PBE name <s10s_u9wos_14a> PBE Boot Device </dev/dsk/c1t0d0s0>.
  Comparing source boot environment <s10s_u9wos_14a> file systems with the
  file system(s) you specified for the new boot environment. Determining
  which file systems should be in the new boot environment.
  Updating boot environment description database on all BEs.
  Updating system configuration files.
  Creating configuration for boot environment <s10s_u9wos_14a2>.
  Source boot environment is <s10s_u9wos_14a>.
  Creating boot environment <s10s_u9wos_14a2>.
  Cloning file systems from boot environment <s10s_u9wos_14a> to create boot environment <s10s_u9wos_14a2>.
  Creating snapshot for <zpool/ROOT/s10s_u9wos_14a> on <zpool/ROOT/s10s_u9wos_14a@s10s_u9wos_14a2>.
  Creating clone for <zpool/ROOT/s10s_u9wos_14a@s10s_u9wos_14a2> on <zpool/ROOT/s10s_u9wos_14a2>.
  Setting canmount=noauto for </> in zone <global> on <zpool/ROOT/s10s_u9wos_14a2>.
  Creating snapshot for <zpool/ROOT/s10s_u9wos_14a/var> on <zpool/ROOT/s10s_u9wos_14a/var@s10s_u9wos_14a2>.
  Creating clone for <zpool/ROOT/s10s_u9wos_14a/var@s10s_u9wos_14a2> on <zpool/ROOT/s10s_u9wos_14a2/var>.
  Setting canmount=noauto for </var> in zone <global> on <zpool/ROOT/s10s_u9wos_14a2/var>.
  Creating dataset <zpool/ROOT/s10s_u9wos_14a2/zoneds/zonesan-s10s_u9wos_14a2> for zone <zonesan>
  Copying root of zone <zonesan>.
  Creating snapshot for <zpool/export/home/zonejos> on <zpool/export/home/zonejos@s10s_u9wos_14a2>.
  Creating clone for <zpool/export/home/zonejos@s10s_u9wos_14a2> on <zpool/export/home/zonejos-s10s_u9wos_14a2>.
  Population of boot environment <s10s_u9wos_14a2> successful.
  Creation of boot environment <s10s_u9wos_14a2> successful.
----------------------------------------------------------------------------------

Check for the new boot enviornment created
3)bash-3.00# lustatus
  Boot Environment           Is       Active Active    Can    Copy
  Name                       Complete Now    On Reboot Delete Status
  -------------------------- -------- ------ --------- ------ ----------
  s10s_u9wos_14a             yes      yes    yes       no     -
  s10s_u9wos_14a2            yes      no     no        yes    -


-----------------------------------------------------------------------------------

4)bash-3.00# zfs list
NAME                                                        USED  AVAIL  REFER  MOUNTPOINT
zpool                                                      22.9G   111G    97K  /zpool
zpool/ROOT                                                 5.57G   111G    21K  legacy
zpool/ROOT/s10s_u9wos_14a                                  5.47G   111G  5.38G  /
zpool/ROOT/s10s_u9wos_14a@s10s_u9wos_14a2                  78.5K      -  5.38G  -
zpool/ROOT/s10s_u9wos_14a/var                              93.0M   111G  92.9M  /var
zpool/ROOT/s10s_u9wos_14a/var@s10s_u9wos_14a2                59K      -  92.9M  -
zpool/ROOT/s10s_u9wos_14a2                                  104M   111G  5.38G  /
zpool/ROOT/s10s_u9wos_14a2/var                                 0   111G  92.9M  /var
zpool/dump                                                 2.00G   111G  2.00G  -
zpool/export                                                201M   111G    23K  /export
zpool/export/home                                           201M   111G   104M  /export/home
zpool/swap                                                 15.1G   126G    16K  -

-----------------------------------------------------------
if you have created zones the boot enviornment will reflect there also.
here i configured a zone 'zonejos'
5)bash-3.00# zfs list
NAME                                                        USED  AVAIL  REFER  MOUNTPOINT
zpool                                                      22.9G   111G    97K  /zpool
zpool/ROOT                                                 5.57G   111G    21K  legacy
zpool/ROOT/s10s_u9wos_14a                                  5.47G   111G  5.38G  /
zpool/ROOT/s10s_u9wos_14a@s10s_u9wos_14a2                  78.5K      -  5.38G  -
zpool/ROOT/s10s_u9wos_14a/var                              93.0M   111G  92.9M  /var
zpool/ROOT/s10s_u9wos_14a/var@s10s_u9wos_14a2                59K      -  92.9M  -
zpool/ROOT/s10s_u9wos_14a2                                  104M   111G  5.38G  /
zpool/ROOT/s10s_u9wos_14a2/var                                 0   111G  92.9M  /var
zpool/ROOT/s10s_u9wos_14a2/zoneds                           103M   111G    23K  /zoneds
zpool/ROOT/s10s_u9wos_14a2/zoneds/zonesan-s10s_u9wos_14a2   103M   111G   103M  /zoneds/zonesan-s10s_u9wos_14a2
zpool/dump                                                 2.00G   111G  2.00G  -
zpool/export                                                201M   111G    23K  /export
zpool/export/home                                           201M   111G   104M  /export/home
zpool/export/home/zonejos                                  97.0M   111G  97.0M  /export/home/zonejos
zpool/export/home/zonejos@s10s_u9wos_14a2                      0      -  97.0M  -
zpool/export/home/zonejos-s10s_u9wos_14a2                  39.5K   111G  97.0M  /export/home/zonejos-s10s_u9wos_14a2
zpool/swap                                                 15.1G   126G    16K  -

---------------------------------------------------------------
you can boot from alternate boot envionment using boot -L command from ok> prompt or using luactivate command and its recommended highly not to give reboot commands or shutdoen commands
6)bash-3.00# luactivate s10s_u9wos_14a2
A Live Upgrade Sync operation will be performed on startup of boot environment <s10s_u9wos_14a2>.
---------------------------------------------------------------
{2} ok boot -L
Boot device: /pci@9,600000/SUNW,qlc@2/fp@0,0/disk@w500000e0129fa191,0:a  File and args: -L
1 s10s_u9wos_14a
2 s10s_u9wos_14a2
Select environment to boot: [ 1 - 2 ]: 2

To boot the selected entry, invoke:
boot [<root-device>] -Z zpool/ROOT/s10s_u9wos_14a2
{2} ok boot -Z rpool/ROOT/zfsnv_952BE
Resetting ...
{2} ok boot -Z zpool/ROOT/s10s_u9wos_14a2
Resetting ...


Software Reset

Enabling system bus....... Done
Initializing CPUs......... Done
Initializing boot memory.. Done
Initializing OpenBoot
Probing system devices
Probing I/O buses

Sun Fire V490, No Keyboard
Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
OpenBoot 4.18.8, 8192 MB memory installed, Serial #71211080.
Ethernet address 0:14:4f:3e:98:48, Host ID: 843e9848.





Rebooting with command: boot -Z zpool/ROOT/s10s_u9wos_14a2
Boot device: /pci@9,600000/SUNW,qlc@2/fp@0,0/disk@w500000e0129fa191,0:a  File and args: -Z zpool/ROOT/s10s_u9wos_14a2
SunOS Release 5.10 Version Generic_142909-17 64-bit
Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved.
Hostname: PTEST231
Reading ZFS config: done.
Mounting ZFS filesystems: (19/19)

PTEST231 console login:
----------------------------------------------------------------------------
now the boot environment is the new one created.At times we will get an error that root file system will not get mounted,what i did was:
got to single user mode from cdrom
{2}ok boot cdrom -s
now just try restarting system usin init command(Please don't use reboot or shutdown command)
#init 6
again if its coming to ok prompt then we have to try another method,
1) Boot the machine to Single User mode from solaris dvd 
 {2}ok boot cdrom -s
  
----------------------------------------------------------------------
Now mount / directory (from current boot environment) on to a new directory,say /mnt after that run command 'luactivate' which activte earlier boot enviornment
2) #zpool import zpool 
3) #zfs get mountpoint zpool/ROOT/s10s_u9wos_14a
4) #zfs get mounted zpool/ROOT/s10s_u9wos_14a
5) #zfs set mountpoint=/mnt zpool/ROOT/s10s_u9wos_14a
6) #zfs mount zpool/ROOT/s10s_u9wos_14a (name of my pool is 'zpool' and don't get confused)
7) #/mnt/sbin/luactivate
8) #init 6
it will be successful

No comments:

Post a Comment