Solaris SVM : Grow Mirrored root under SDS / SVM

This is a step by step procedure to grow a root filesystem which is mirrored using Solstice Disksuite or Solaris Volume Manager.

It is strongly recommended that a backup of the root filesystem be performed  prior to following this procedure. Also, experience with the Disksuite or Solaris Volume Manager products and their command line utilities is recommended, since this document may not provide ALL the commands necessary to perform the task, so some additional commands or steps may be necessary.

Please note that depending on the configuration of the root disk on the  server, the ability to grow the root filesystem may not be possible without  additional preliminary work which is not covered in this document.


Instructions:

There needs to be free space on the root drive which follows the root slice.

If there is free space at any other location on the drive, and nofree space following the final cylinder for the root slice, this procedure will not work. If the slice following root is swap, and there is other free space on the root devices, it may be possible to move swap to this other free space, but reconfiguring swap is beyond the scope of this document.

An example of a prtvtoc output which we can grow:


   *                          First     Sector    Last
   * Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
          0      2    00          0  15581349  15581348
          2      5    00          0  17682084  17682083

An example of a prtvtoc which we may not be able to grow:


   *                          First     Sector    Last
   * Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
          0      2    00          0  15581349  15581348
          1      0    01   15581349   1027026  16608374
          2      5    00          0  17682084  17682083

The reason the second VTOC may not be able to be grown is because Slice1 starts immediately following Slice 0, which contains the root filesystem. If Slice 1 exists, but is not used, then we can still grow this root filesystem. If this slice is used for any other filesystem,then we cannot grow root, unless this slice is swap as indicated above.

The initial configuration for the root filesystem (mounted on /dev/md/dsk/d0) under SVM that we will be working with throughout this procedure is as follows:


   # metastat d0

   d0: Mirror
       Submirror 0: d1
         State: Okay
       Submirror 1: d2
         State: Okay
       Pass: 1
       Read option: roundrobin (default)
       Write option: parallel (default)
       Size: 15581349 blocks

   d1: Submirror of d0
       State: Okay
       Size: 15581349 blocks
       Stripe 0:
           Device     Start Block  Dbase        State Reloc Hot Spare
           c0t0d0s0          0     No            Okay   Yes


   d2: Submirror of d0
       State: Okay
       Size: 15581349 blocks
       Stripe 0:
           Device     Start Block  Dbase        State Reloc Hot Spare
           c0t1d0s0          0     No            Okay   Yes

Also, the partition configuration for the root drive is as follows:


   # prtvtoc /dev/rdsk/c0t0d0s2
   *                          First     Sector    Last
   * Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
          0      2    00          0  15581349  15581348
          2      5    00          0  17682084  17682083

Before starting this procedure it is important to note the location of any database replicas on this device. Normally they will be on a separate slice and should not be affected by this procedure as long as those slices are not changed.

Copy the /etc/system and /etc/vfstab files to a backup location other than /tmp:

   # cp /etc/vfstab /etc/vfstab.old
   # cp /etc/system /etc/system.old

Next, we need to edit the /etc/vfstab file to contain the root slice(c0t0d0s0 for our configuration):

Before changes to the /etc/vfstab:

   #device         device          mount           FS      fsck    mount mount
   #to mount       to fsck         point           type    pass    at boot options
   #
   fd      -       /dev/fd fd      -       no      -
   /proc   -       /proc   proc    -       no      -
   /dev/dsk/c0t2d0s0       -       -       swap    -       no      -
   /dev/md/dsk/d0  /dev/md/rdsk/d0 /       ufs     1       no      -
   swap    -       /tmp    tmpfs   -       yes     -

Make the changes to the root filesystem entry in /etc/vfstab by running the metaroot command with the root slice:

   # metaroot c0t0d0s0

And the resulting /etc/vfstab file:

   #device         device          mount           FS      fsck    mount mount
   #to mount       to fsck         point           type    pass    at boot options
   #
   fd      -       /dev/fd fd      -       no      -
   /proc   -       /proc   proc    -       no      -
   /dev/dsk/c0t2d0s0       -       -       swap    -       no      -
   /dev/dsk/c0t0d0s0       /dev/rdsk/c0t0d0s0      /       ufs     1 no      -
   swap    -       /tmp    tmpfs   -       yes     -

Now that we have this file set, we need to verify that the /etc/system file does not contain an uncommented line beginning with rootdev:

   # grep rootdev /etc/system
   *       rootdev:        Set the root device.  This should be a fully
   *               rootdev:/sbus@1,f8000000/esp@0,800000/sd@3,0:a

If you see something such as the following:


   # grep rootdev /etc/system
   *       rootdev:        Set the root device.  This should be a fully
   *               rootdev:/sbus@1,f8000000/esp@0,800000/sd@3,0:a
   rootdev:/pseudo/md@0:0,0,blk

The uncommented line “rootdev:/pseudo/md@0:0,0,blk” needs to be removed from the /etc/system file before continuing on.

Once the /etc/system and /etc/vfstab file are now setup to boot to the alternate root drive, we need to metadetach the submirror created from our root slice (d1 in our configuration):

   # metadetach d0 d1
   d0: submirror d1 is detached

Once this has been detached, we need to clear the metadevice assigned to this slice:

   # metaclear d1
   d1: Concat/Stripe is cleared

Now that this Submirror is detached and cleared, we can repartition this slice on this drive (c0t0d0s0 for our example) to be larger. For this change of the slice size, when defining the cylinder boundaries, it is required to start at the same cylinder. We will change the ending cylinder to allow for the slice to be larger:

   partition> pri
   Volume:  root
   Current partition table (unnamed):
   Total disk cylinders available: 4924 + 2 (reserved cylinders)

   Part      Tag    Flag     Cylinders        Size            Blocks
     0       root    wm       0 - 4338        7.43GB    (4339/0/0) 15581349
     1 unassigned    wm       0               0         (0/0/0)           0
     2     backup    wm       0 - 4923        8.43GB    (4924/0/0) 17682084
     3 unassigned    wu       0               0         (0/0/0)           0
     4 unassigned    wu       0               0         (0/0/0)           0
     5 unassigned    wm       0               0         (0/0/0)           0
     6 unassigned    wm       0               0         (0/0/0)           0
     7 unassigned    wm       0               0         (0/0/0)           0

   partition> 0
   Part      Tag    Flag     Cylinders        Size            Blocks
     0       root    wm       0 - 4338        7.43GB    (4339/0/0) 15581349

   Enter partition id tag[root]:	<-- Accept the default
   Enter partition permission flags[wm]:	<-- Accept the default
   Enter new starting cyl[0]: 0	<-- Accept the default
   Enter partition size[15581349b, 4339c, 4338e, 7608.08mb, 7.43gb]: 4924c	<-- Set the size using a larger cylinder count than the previous size
   partition> pri	<-- Print out the new configuration to verify the new layout
   Volume:  root
   Current partition table (unnamed):
   Total disk cylinders available: 4924 + 2 (reserved cylinders)

   Part      Tag    Flag     Cylinders        Size            Blocks
     0       root    wm       0 - 4923        8.43GB    (4924/0/0) 17682084
     1 unassigned    wm       0               0         (0/0/0)           0
     2     backup    wm       0 - 4923        8.43GB    (4924/0/0) 17682084
     3 unassigned    wu       0               0         (0/0/0)           0
     4 unassigned    wu       0               0         (0/0/0)           0
     5 unassigned    wm       0               0         (0/0/0)           0
     6 unassigned    wm       0               0         (0/0/0)           0
     7 unassigned    wm       0               0         (0/0/0)           0

   partition> lab	<-- Label the disk with the new layout
   Ready to label disk, continue? y

Now, we need to fsck the primary root filesystem which we have detached from the mirror metadevice. Once the fsck has completed, we need to mount and grow the filesystem:

   # fsck -y /dev/dsk/c0t0d0s0

If this fixes any problems, then run the fsck command again, and do so until no errors are found.

Once the fsck comes back clean, mount this filesystem to /mnt:

   # mount /dev/dsk/c0t0d0s0 /mnt

Once mounted, cd into the /mnt and do an ls to be sure that this is a root filesystem. Once verifying this, cd out of this directory and run the df -k command to verify the size of this filesystem:

   # df -k
   Filesystem            kbytes    used   avail capacity  Mounted on
   /dev/md/dsk/d0       7670973 1618595 5975669    22%    /
   /proc                      0       0       0     0%    /proc
   mnttab                     0       0       0     0%    /etc/mnttab
   fd                         0       0       0     0%    /dev/fd
   swap                 4447288      40 4447248     1%    /var/run
   swap                 4447256       8 4447248     1%    /tmp
   /dev/dsk/c0t0d0s0    7670973 1618585 5975679    22%    /mnt

We see that prior to growing this filesystem, we have a size of 7670973 kbytes. Now we need to run the growfs command to grow this filesystem to the new slice size. Syntax: growfs -M

   # growfs -M /mnt /dev/rdsk/c0t0d0s0

Once this completes, running the df -k again will show the new size:

   # df -k
   Filesystem            kbytes    used   avail capacity  Mounted on
   /dev/md/dsk/d0       7670973 1618597 5975667    22%    /
   /proc                      0       0       0     0%    /proc
   mnttab                     0       0       0     0%    /etc/mnttab
   fd                         0       0       0     0%    /dev/fd
   swap                 4446944      40 4446904     1%    /var/run
   swap                 4446912       8 4446904     1%    /tmp
   /dev/dsk/c0t0d0s0    8705501 1618585 7010207    19%    /mnt	<-- Notice the new size

Once this new slice size has been verified, we are ready for a reboot:

   # init 6

The system will reboot and after logging in as root, do a df -k to verify that we are booted from the expected partition:

   # df -k
   Filesystem            kbytes    used   avail capacity  Mounted on
   /dev/dsk/c0t0d0s0    8705501 1619023 6999423    19%    /
   /proc                      0       0       0     0%    /proc
   mnttab                     0       0       0     0%    /etc/mnttab
   fd                         0       0       0     0%    /dev/fd
   swap                 4447312      40 4447272     1%    /var/run
   swap                 4447272       0 4447272     0%    /tmp

Once this is verified, we need to clear out the previous root metadevice, reformat the other root submirror which has not already been resized, and last, we need to put the root filesystem back under Disksuite/SVM control.

First, we need to metaclear the original root mirror, d0 for this configuration, by running the following command:

   # metaclear -rf d0
   d0: Mirror is cleared
   d2: Concat/Stripe is cleared

Next, we need to make the slice on the mirror drive for root (c0t1d0s0 for our example configuration) the same size as our mounted root filesystem by following the same steps that we used to repartition the now mounted root slice (c0t0d0s0 in our configuration):

   # format
   Choose the device used for the root mirror.
   format> partition
   partition> 0  <-- The slice used for the root filesystem
   Enter partition id tag[root]:
   Enter partition permission flags[wm]:
   Enter new starting cyl[0]: 0    <-- Need to enter the starting cylinder for the soon to be root mirror
   Enter partition size[15581349b, 4339c, 4338e, 7608.08mb, 7.43gb]: 4924c <-- Enter the size of the now mounted root slice
   partition> pri	<-- Verify the new layout
   Current partition table (unnamed):
   Total disk cylinders available: 4924 + 2 (reserved cylinders)

   Part      Tag    Flag     Cylinders        Size            Blocks
     0       root    wm       0 - 4923        8.43GB    (4924/0/0) 17682084
     1 unassigned    wm       0               0         (0/0/0)           0
     2     backup    wm       0 - 4923        8.43GB    (4924/0/0) 17682084
     3 unassigned    wu       0               0         (0/0/0)           0
     4 unassigned    wu       0               0         (0/0/0)           0
     5 unassigned    wu       0               0         (0/0/0)           0
     6 unassigned    wu       0               0         (0/0/0)           0
     7 unassigned    wu       0               0         (0/0/0)           0

     partition> label
     Ready to label disk, continue? yes

Now that the root mirror slice is the same size as the current root slice, we can configure the root filesystem back under Disksuite/SVM control:

Create a metadevice out of the currently mounted root slice (c0t0d0s0 in our configuration)

   # metainit -f d1 1 1 c0t0d0s0
   d1: Concat/Stripe is setup

Create the root mirror metadevice out of the metadevice created in the previous step

   # metainit d0 -m d1
   d0: Mirror is setup

Create the other root submirror metadevice out of the mirror drive (c0t1d0s0 in our configuration)

   # metainit d2 1 1 c0t1d0s0
   d2: Concat/Stripe is setup

Now that the metadevices have been setup, we need to configure this system to use this metadevice as the root filesystem rather than a slice:

   # metaroot d0

We can now reboot this host to get the root metadevice, d0, again mounted and being used:

   # init 6

Once rebooted, log back in as root and run a df -k to verify that the metadevice created above is now mounted as root, and is also displaying the new size for the root filesystem:


   # df -k
   Filesystem            kbytes    used   avail capacity  Mounted on
   /dev/md/dsk/d0       8705501 1619049 6999397    19%    /		<-- Notice the new size
   /proc                      0       0       0     0%    /proc
   mnttab                     0       0       0     0%    /etc/mnttab
   fd                         0       0       0     0%    /dev/fd
   swap                 4448072      40 4448032     1%    /var/run
   swap                 4448032       0 4448032     0%    /tmp

The root filesystem from before following this procedure:

   /dev/md/dsk/d0       7670973 1618595 5975669    22%    /

The final step is to remirror the root filesystem by reattaching the second root submirror metadevice created above (d2 in this configuration) to the mirror metadevice (d0 in this configuration):

   # metattach d0 d2
   d0: submirror d2 is attached

To verify the progress of the resyncing of the Submirrors, run the metastat command for the root mirror metadevice:

   # metastat d0
   d0: Mirror
       Submirror 0: d1
         State: Okay
       Submirror 1: d2
         State: Resyncing
       Resync in progress: 15 % done
       Pass: 1
       Read option: roundrobin (default)
       Write option: parallel (default)
       Size: 17682084 blocks

When both Submirrors are in an Okay state, which will happen when the Resync in progress gets to 100%, this procedure is finished and you have grown the root filesystem.


Ramdev

Ramdev

I have started unixadminschool.com ( aka gurkulindia.com) in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' unixadminschool.com. You can connect me at - https://www.linkedin.com/in/unixadminschool/

1 Response

  1. September 16, 2015

    […] Read – Grow Mirrored root under SDS / SVM […]

What is in your mind, about this post ? Leave a Reply

Close
  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us