Solaris Volume Manager Administration Guide

ProcedureSPARC: How to Create a RAID-1 Volume From the root (/) File System

The process for mirroring the root (/) file system on a SPARC platform is similar to mirroring any other file system that you cannot unmount. The procedure differs in that the metaroot command is run instead of manually editing the /etc/vfstab file. Mirroring the root (/) file system also requires recording the path to the alternate boot device. This device reboots the system if the submirror fails.

In the example used in this procedure, the existing slice is c1t0d0s0. The second slice, c1t1d0s0, is available for the second half of the mirror. The submirrors are d1 and d2, respectively, and the mirror is d0.


Caution – Caution –

Be sure to create a one-way mirror with the metainit command then attach the additional submirrors with the metattach command. When the metattach command is not used, no resynchronization operations occur. As a result, data could become corrupted when Solaris Volume Manager assumes that both sides of the mirror are identical and can be used interchangeably.


Before You Begin

Check Prerequisites for Creating Solaris Volume Manager Components and Creating and Maintaining RAID-1 Volumes.

  1. Identify the slice that contains the existing root (/) file system to be mirrored. This example uses the slice c1t0d0s0.

  2. Create a new RAID-0 volume on the slice from the previous step by using one of the following methods. Only the single slice can be included in the RAID-0 volume.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, then choose Action⇒Create Volume. Follow the onscreen instructions . For more information, see the online help.

    • Use the following form of the metainit command:


      # metainit -f  volume-name number-of-stripes components-per-stripe component-name
      
      -f

      Forces the command to continue. You must use this option when the slice contains a mounted file system.

      volume-name

      Specifies the name of the volume to create. For information on naming volumes, see Volume Names.

      number-of-stripes

      Specifies the number of stripes to create.

      components-per-stripe

      Specifies the number of components each stripe should have.

      component-names

      Specifies the names of the components that are used. This example uses the root slice, c0t0d0s0.

  3. Create a second RAID-0 volume on an unused slice (c1t1d0s0 in this example) to act as the second submirror. The secondary submirror must be the same size as the original submirror, or larger. Use one of the following methods:

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, then choose Action->Create Volume and follow the instructions on screen. For more information, see the online help.

    • Use the following form of the metainit command.


      # metainit volume-name number-of-stripes components-per-stripe component-name
      

      Note –

      See Step 2 for and explanation of the options.


  4. Create a one-way mirror by using one of the following methods:

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, then choose Action⇒Create Volume. Follow the onscreen instructions . For more information, see the online help.

    • Use the following form of the metainit command.


      # metainit volume-name -m submirror-name
      
      volume-name

      Specifies the name of the volume to create.

      -m

      Specifies to create a mirror.

      submirror-name

      Specifies the name of the component that will be the first submirror in the mirror. In this example, it is the RAID-0 volume that contains the root slice.

  5. Remount your newly mirrored file system. Run the metaroot volume-name command, replacing volume-name with the name of the mirror you have created. Then, reboot your system.


    # metaroot volume-name
    # reboot
    

    For more information, see the metaroot(1M) man page.

  6. Use the following form of the metattach command to attach the second submirror.


    # metattach volume-name submirror-name
    
    volume-name

    Specifies the name of the RAID-1 volume on which to add the submirror

    submirror-name

    Specifies the name of the component that will be the second submirror attached to the mirror

    See the metattach(1M) man page for more information.

  7. Record the alternate boot path.

    1. Determine the path to the alternate root device. Use the ls -l command on the slice that is being attached as the second submirror to the root (/) file system mirror.


      # ls -l /dev/dsk/c1t1d0s0
      lrwxrwxrwx 1  root root  55 Mar 5 12:54  /dev/rdsk/c1t1d0s0 -> \ 
      ../../devices/sbus@1,f8000000/esp@1,200000/sd@3,0:a
    2. Record the string that follows the /devices directory: /sbus@1,f8000000/esp@1,200000/sd@3,0:a.


      Note –

      Because the system might not be available, this information should also be written down somewhere other than on the system. See Recovering From Boot Problems for details on booting from the alternate boot device.


    3. Edit the string to change the major name (sd, in this case) to disk, resulting in /sbus@1,f8000000/esp@1,200000/disk@3,0:a. If the system uses an IDE bus, the original full path might look like


      $ ls -l /dev/dsk/c1t1d0s0 
      lrwxrwxrwx 1 root root 38 Mar 13 15:03 /dev/dsk/c0t0d0s0 -> \
      ../../devices/pci@1f,0/ide@d/dad@0,0:a

      After changing the major name dad to disk, you would have /pci@1f,0/ide@d/disk@0,0:a

    4. Use the OpenBootTM PROM nvalias command to define a “backup root” device alias for the secondary root (/) file system mirror. For example:


      ok  nvalias backup_root /sbus@1,f8000000/esp@1,200000/disk@3,0:a
      
    5. Redefine the boot-device alias to reference both the primary and secondary submirrors, in the order in which you want them to be used, and store the configuration.


      ok printenv boot-device
      boot-device =         disk net
      ok setenv boot-device disk backup_root net
      boot-device =         disk backup_root net
      ok nvstore
      

    Note –

    In the event that the primary submirror fails, the system would automatically boot to the second submirror. Or, if you boot manually, rather than using autoboot, you would enter:


    ok boot backup_root
    


Example 11–6 SPARC: Creating a Mirror From the root (/) File System


# metainit -f d1 1 1 c0t0d0s0
d1: Concat/Stripe is setup
# metainit d2 1 1 c0t1d0s0
d2: Concat/Stripe is setup
# metainit d0 -m d1
d0: Mirror is setup
# metaroot d0
# lockfs -fa
# reboot
...
# metattach d0 d2
d0: Submirror d2 is attached
# ls -l /dev/dsk/c0t1d0s0
lrwxrwxrwx   1 root     root          88 Feb  8 15:51 /dev/rdsk/c1t3d0s0 ->
../../devices/pci@1f,0/pci@1,1/ide@3/dad@0,0:a
# init 0
.
.
.
ok nvalias backup_root /pci@1f,0/pci@1,1/ide@3/disk@0,0:a
ok setenv boot-device disk backup_root net
ok nvstore

In this example, the -f option forces the creation of the first RAID-0 volume, d1, which contains the mounted root (/) file system on /dev/dsk/c0t0d0s0. The second concatenation, d2, is created from /dev/dsk/c0t1d0s0. This slice must be the same size as, or larger than the size of d1. The metainit command with the -m option creates the one-way mirror d0 using the concatenation that contains root (/).

Next, the metaroot command edits the /etc/vfstab and /etc/system files so that the system can be booted with the root (/) file system on a volume. It is a good idea to run the lockfs -fa command before rebooting. For more information, see the lockfs(1M) man page.

Do not attach the second submirror before the system is rebooted. You must reboot after running the metaroot command and before attaching the second submirror.

After a reboot, the submirror d2 is attached to the mirror, causing a mirror resynchronization. The system confirms that the concatenations and the mirror are set up, and that submirror d2 is attached.

The ls -l command is run on the root raw device to determine the path to the alternate root device in case the system might later need to be booted from it.