Solaris Volume Manager Administration Guide

Chapter 11 RAID 1 (Mirror) Volumes (Tasks)

This chapter explains how to perform Solaris Volume Manager tasks related to RAID 1 volumes. For information about related concepts, see Chapter 10, RAID 1 (Mirror) Volumes (Overview).

RAID 1 Volumes (Task Map)

The following task map identifies the procedures needed to manage Solaris Volume Manager RAID 1 volumes.

Task 

Description 

Instructions 

Create a mirror from unused slices 

Use the Solaris Volume Manager GUI or the metainit command to create a mirror from unused slices.

How to Create a RAID 1 Volume From Unused Slices

Create a mirror from an existing file system 

Use the Solaris Volume Manager GUI or the metainit command to create a mirror from an existing file system.

How to Create a RAID 1 Volume From a File System

Record the path to the alternate boot device for a mirrored root 

Find the path to the alternative book device and enter it in the boot instructions.  

How to Record the Path to the Alternate Boot Device

Attach a submirror 

Use the Solaris Volume Manager GUI or the metattach command to attach a submirror.

How to Attach a Submirror

Detach a submirror 

Use the Solaris Volume Manager GUI or the metadetach command to detach the submirror.

How to Detach a Submirror

Place a submirror online or take a submirror offline 

Use the Solaris Volume Manager GUI or the metaonline command to put a submirror online. Use the Solaris Volume Manager GUI or the metaoffline command to take a submirror offline.

How to Place a Submirror Offline and Online

Enable a component within a submirror 

Use the Solaris Volume Manager GUI or the metareplace command to enable a slice in a submirror.

How to Enable a Slice in a Submirror

Check mirror status 

Use the Solaris Volume Manager GUI or the metastat command to check the status of RAID 1 volumes.

How to Check the Status of Mirrors and Submirrors

Change mirror options 

Use the Solaris Volume Manager GUI or the metaparam command to change the options for a specific RAID 1 volume.

How to Change RAID 1 Volume Options

Expand a mirror 

Use the Solaris Volume Manager GUI or the metattach command to expand the capacity of a mirror.

How to Expand a RAID 1 Volume

Replace a slice within a submirror 

Use the Solaris Volume Manager GUI or the metareplace command to replace a slice in a submirror.

How to Replace a Slice in a Submirror

Replace a submirror 

Use the Solaris Volume Manager GUI or the metattach command to replace a submirror.

How to Replace a Submirror

Remove a mirror (unmirror) 

Use the Solaris Volume Manager GUI or the metadetach command or the metaclear command to unmirror a file system.

How to Unmirror a File System

Remove a mirror (unmirror) of a file system that cannot be unmounted 

Use the Solaris Volume Manager GUI or the metadetach command or the metaclear command to unmirror a file system that cannot be unmounted.

How to Unmirror a File System That Cannot Be Unmounted

Use a mirror to perform backups 

Use the Solaris Volume Manager GUI or the metaonline command and the metaoffline commands to perform backups with mirrors.

How to Use a RAID 1 Volume to Make an Online Backup

Creating a RAID 1 Volume

ProcedureHow to Create a RAID 1 Volume From Unused Slices

Steps
  1. Check Prerequisites for Creating Solaris Volume Manager Components and Background Information for Creating RAID 1 Volumes.

  2. Create two stripes or concatenations, which will be the submirrors.

    See How to Create a RAID 0 (Stripe) Volume or How to Create a RAID 0 (Concatenation) Volume.

  3. To create the mirror, 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 to create a one-way mirror:


      metainit volume-name -m  submirror-name
      
      • volume-name is 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.

      See the following examples and the metainit(1M) man page for more information.

  4. To add the second submirror, use one of the following methods:

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, then choose the mirror you want to modify. Choose Action->Properties, then the Submirrors tab and follow the instructions on screen to Attach Submirror. For more information, see the online help.

    • Use the following form of the metattach command:


      metattach mirror-name new-submirror-name
      
      • volume-name is the name of the RAID 1 volume to modify.

      • submirror-name specifies the name of the component that will be the next submirror in the mirror.

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


Example 11–1 Creating a Two-Way Mirror


# metainit d51 1 1 c0t0d0s2
d51: Concat/Stripe is setup
# metainit d52 1 1 c1t0d0s2
d52: Concat/Stripe is setup
# metainit d50 -m d51
d50: Mirror is setup
# metattach d50 d52
d50: Submirror d52 is attached

This example shows the creation of a two-way mirror, d50. The metainit command creates two submirrors (d51 and d52), which are RAID 0 volumes. The metainit -m command creates the one-way mirror from the d51 RAID 0 volume. The metattach command attaches d52, creating a two-way mirror and causing a resynchronization. (Any data on the attached submirror is overwritten by the other submirror during the resynchronization.) The system verifies that the objects are defined.



Example 11–2 Creating a Two-Way Mirror Without Resynchronization


# metainit d51 1 1 c0t0d0s2
d51: Concat/Stripe is setup
# metainit d52 1 1 c1t0d0s2
d52: Concat/Stripe is setup
# metainit d50 -m d51 d52
metainit: d50: WARNING: This form of metainit is not recommended.
The submirrors may not have the same data.
Please see ERRORS in metainit(1M) for additional information.
d50: Mirror is setup

This example creates a two-way mirror, d50. The metainit command creates two submirrors (d51 and d52), which are RAID 0 volumes. The metainit -m command with both submirrors creates the mirror from the d51 RAID 0 volume and avoids resynchronization. It is assumed that all information on the mirror is considered invalid and will be regenerated (for example, through a newfs operation) before the mirror is used.


See Also

To prepare a newly created mirror for a file system, see Chapter 16, Creating UFS, TMPFS, and LOFS File Systems (Tasks), in System Administration Guide: Devices and File Systems. An application, such as a database, that uses the raw volume must have its own way of recognizing the volume.

ProcedureHow to Create a RAID 1 Volume From a File System

Use this procedure to mirror an existing file system. If the file system can be unmounted, the entire procedure can be completed without a reboot. For file systems (such as root (/)) that cannot be unmounted, the system will have to be rebooted to complete the procedure.

When creating a RAID 1 volume from an existing file system built on a slice, only the single slice may be included in the primary RAID 0 volume (submirror). If you are mirroring root or other system-critical file systems, all submirrors must consist of only a single slice.


Note –

When mirroring root (/), it is essential that you record the secondary root slice name to reboot the system if the primary submirror fails. This information should be written down, not recorded on the system, which might not be available. See Chapter 26, Troubleshooting Solaris Volume Manager (Tasks) for details on recording the alternate boot device, and on booting from the alternate boot device.

If you are mirroring root on an x86 system, install the boot information on the alternate boot disk before you create the RAID 0 or RAID 1 devices. See Chapter 10, Booting a System (Tasks), in System Administration Guide: Basic Administration.


In this procedure, an existing device is c1t0d0s0. A second device, c1t1d0s0, is available for the second half of the mirror. The submirrors will be d1 and d2, respectively, and the mirror will be 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.


Steps
  1. Check Prerequisites for Creating Solaris Volume Manager Components and Background Information for Creating RAID 1 Volumes.

  2. Identify the slice that contains the existing file system to be mirrored (c1t0d0s0 in this example).

  3. Create a new RAID 0 volume on the slice from the previous step 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 and follow the instructions on screen. For more information, see the online help.

    • Use the metainit -f raid-0-volume-name 1 1 ctds-of-slice command.


      # metainit -f d1 1 1 c1t0d0s0
      
  4. Create a second RAID 0 volume (concatenation) on an unused slice (c1t1d0s0 in this example) to act as the second submirror. The second 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 metainit second-raid-0-volume-name 1 1 ctds-of-slice command.


      # metainit d2 1 1 c1t1d0s0
      
  5. 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 and follow the instructions on screen. For more information, see the online help.

    • Use the metainit mirror-name -m raid-0-volume-name command.


      # metainit d0 -m d1
      

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


    Note –

    When you create a mirror from an existing file system, you must follow the next two steps precisely to avoid data corruption.


    If you are mirroring any file system other than the root (/) file system, then edit the /etc/vfstab file so that the file system mount instructions refer to the mirror, not to the block device.

    For more information about the/etc/vfstab file, see Mounting File Systems in System Administration Guide: Devices and File Systems.

  6. Remount your newly mirrored file system according to one of the following procedures:

    • If you are mirroring your root (/) file system, run the metaroot d0 command, replacing d0 with the name of the mirror you just created, then reboot your system.

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

    • If you are mirroring a file system that can be unmounted, then unmount and remount the file system.

    • If you are mirroring a file system other than root (/) that cannot be unmounted, then reboot your system.

  7. Use the metattach command to attach the second submirror.


    # metattach d0 d2
    

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

  8. If you mirrored your root file system, record the alternate boot path.

    See How to Record the Path to the Alternate Boot Device.


Example 11–3 Creating a Two-Way Mirror (Unmountable File System)


# metainit -f d1 1 1 c1t0d0s0
d1: Concat/Stripe is setup
# metainit d2 1 1 c1t1d0s0
d2: Concat/Stripe is setup
# metainit d0 -m d1
d0: Mirror is setup
# umount /master
(Edit the /etc/vfstab file so that the file system references the mirror)
# mount /master
# metattach d0 d2
d0: Submirror d2 is attached

The -f option forces the creation of the first concatenation, d1, which contains the mounted file system /master on /dev/dsk/c1t0d0s0. The second concatenation, d2, is created from /dev/dsk/c1t1d0s0. (This slice must be the same size or greater than that of d1.) The metainit command with the -m option creates the one-way mirror, d0, from d1.

Next, the entry for the file system should be changed in the /etc/vfstab file to reference the mirror. For example, the following line:


/dev/dsk/c1t0d0s0 /dev/rdsk/c1t0d0s0 /var ufs 2 yes -

should be changed to:


/dev/md/dsk/d0 /dev/md/rdsk/d0 /var ufs 2 yes -

Finally, the file system is remounted and submirror d2 is attached to the mirror, causing a mirror resynchronization. The system confirms that the RAID 0 and RAID 1 volumes are set up, and that submirror d2 is attached.



Example 11–4 Creating a Mirror From root (/)


# metainit -f d1 1 1 c0t0d0s0
d1: Concat/Stripe is setup
# metainit d2 1 1 c0t1d0s0
d2: Concat/Stripe is setup
# metainit d0 -m d1d0: Mirror is setup
# metaroot d0
# lockfs -fa
# reboot
...
# metattach d0 d2
d0: Submirror d2 is attached
# ls -l /dev/rdsk/c0t1d0s0
lrwxrwxrwx   1 root     root          88 Feb  8 15:51 /dev/rdsk/c1t3d0s0 ->
../../devices/iommu@f,e0000000/vme@f,df010000/SUNW,pn@4d,1080000/ipi3sc@0,0/i
d@3,0:a,raw

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

The -f option forces the creation of the first RAID 0 volume, d1, which contains the mounted file system root (/) on /dev/dsk/c0t0d0s0. The second concatenation, d2, is created from /dev/dsk/c0t1d0s0. (This slice must be the same size or greater than that 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.) 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.



Example 11–5 Creating a Two-way Mirror (File System That Cannot Be Unmounted—/usr)


# metainit -f d12 1 1 c0t3d0s6
d12: Concat/Stripe is setup
# metainit d22 1 1 c1t0d0s6
d22: Concat/Stripe is setup
# metainit d2 -m d12
d2: Mirror is setup
(Edit the /etc/vfstab file so that /usr references the mirror)
# reboot
...
# metattach d2 d22
d2: Submirror d22 is attached

The -f option forces the creation of the first concatenation, d12, which contains the mounted file system /usr on /dev/dsk/c0t3d0s6. The second concatenation, d22, is created from /dev/dsk/c1t0d0s6. (This slice must be the same size or greater than that of d12.) The metainit command with the -m option creates the one-way mirror d2 using the concatenation containing /usr. Next, the /etc/vfstab file must be edited to change the entry for /usr to reference the mirror. For example, the following line:


/dev/dsk/c0t3d0s6 /dev/rdsk/c0t3d0s6 /usr ufs 1 yes -

should be changed to:


/dev/md/dsk/d2 /dev/md/rdsk/d2 /usr ufs 1 yes -

After a reboot, the second submirror d22 is attached to the mirror, causing a mirror resynchronization. (The system confirms that the concatenation and the mirror are set up, and that submirror d22 is attached.)



Example 11–6 Creating a Mirror From swap


# metainit -f d11 1 1 c0t0d0s1
d11: Concat/Stripe is setup
# metainit d21 1 1 c1t0d0s1
d21: Concat/Stripe is setup
# metainit d1 -m d11
d1: Mirror is setup
(Edit the /etc/vfstab file so that swap references the mirror)
# reboot
...
# metattach d1 d21
d1: Submirror d21 is attached

The -f option forces the creation of the first concatenation, d11, which contains the mounted file system swap on /dev/dsk/c0t0d0s1. The second concatenation, d21, is created from /dev/dsk/c1t0d0s1. (This slice must be the same size or greater than that of d11.) The metainit command with the -m option creates the one-way mirror d1 using the concatenation that contains swap. Next, if there is an entry for swap in the /etc/vfstab file, it must be edited to reference the mirror. For example, the following line:


/dev/dsk/c0t0d0s1 - - swap - no -

should be changed to:


/dev/md/dsk/d1 - - swap - no -

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

To save the crash dump when you have mirrored swap, use the dumpadm command to configure the dump device as a volume. For instance, if the swap device is named /dev/md/dsk/d2, use the dumpadm command to set this device as the dump device.


Special Considerations for Mirroring root (/)

The process for mirroring root (/) is the same as in mirroring any other file system that you cannot unmount, with the exception that you run the metaroot command instead of manually editing the /etc/vfstab file. See How to Create a RAID 1 Volume From a File System. The following sections outline special considerations and issues for mirroring root (/) file systems.

Understanding Boot Time Warnings

After mirroring your root (/) file system, error messages will be displayed in the console and logged in the system log (as defined in /etc/syslog.conf). These error messages do not indicate a problem—they show up for each device type that you are not currently using, because an unused module cannot be force loaded. The error messages look similar to the following:


Jul 13 10:17:42 ifr genunix: [ID 370176 kern.warning] WARNING: forceload of 
    misc/md_trans failed
Jul 13 10:17:42 ifr genunix: [ID 370176 kern.warning] WARNING: forceload of 
    misc/md_raid failed
Jul 13 10:17:42 ifr genunix: [ID 370176 kern.warning] WARNING: forceload of 
    misc/md_hotspares failed

You can safely disregard these warning messages.

How to Record the Path to the Alternate Boot Device

When you are mirroring root (/), you might need the path to the alternate boot device later if the primary device fails. The process for finding and recording the alternate boot device differs, depending on your system's architecture. See SPARC: Example—Recording the Alternate Boot Device Path or x86: Example—Recording the Alternate Boot Device Path.

SPARC: Example—Recording the Alternate Boot Device Path

In this example, you determine the path to the alternate root device by using the ls -l command on the slice that is being attached as the second submirror to the root (/) mirror.


# ls -l /dev/dsk/c1t3d0s0
lrwxrwxrwx 1  root root  55 Mar 5 12:54  /dev/rdsk/c1t3d0s0 -> \ 
../../devices/sbus@1,f8000000/esp@1,200000/sd@3,0:a

Record the string that follows the /devices directory: /sbus@1,f8000000/esp@1,200000/sd@3,0:a.

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/c0t0d0s0 
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

You can use the OpenBootTM Prom nvalias command to define a “backup root” device alias for the secondary root (/) mirror. For example:


ok  nvalias backup_root /sbus@1,f8000000/esp@1,200000/disk@3,0:a

Then, 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

In the event of primary root disk failure, the system would automatically boot to the second submirror. Or, if you boot manually, rather than using auto boot, you would only enter:


ok  boot backup_root

x86: Example—Recording the Alternate Boot Device Path

In this example, you would determine the path to the alternate boot device by using the ls -l command on the slice that is being attached as the second submirror to the root (/) mirror.


# ls -l /dev/dsk/c1t0d0s0
lrwxrwxrwx 1  root root  55 Mar 5 12:54  /dev/rdsk/c1t0d0s0 -> ../.
./devices/eisa/eha@1000,0/cmdk@1,0:a

Here, you would record the string that follows the /devices directory: /eisa/eha@1000,0/cmdk@1,0:a

Booting From Alternate Boot Devices

If your primary submirror on a mirrored root (/) fails, you will need to initiate the boot from the other submirror. You can either configure the system to boot automatically from the second side of the mirror, or can manually boot from the second side.

See Chapter 10, Booting a System (Tasks), in System Administration Guide: Basic Administration.

Working With Submirrors

ProcedureHow to Attach a Submirror


Note –

If you see an error message stating can't attach labeled submirror to an unlabeled mirror, that indicates that you unsuccessfully attempted to attach a RAID 0 volume to a mirror. A labeled volume (submirror) is a volume whose first component starts at cylinder 0, while an unlabeled volume's first component starts at cylinder 1. To prevent the labeled submirror's label from being corrupted, Solaris Volume Manager does not allow labeled submirrors to be attached to unlabeled mirrors.


Steps
  1. Identify the component (concatenation or stripe) to be used as a submirror.

    It must be the same size (or larger) as the existing submirror in the mirror. If you have not yet created a volume to be a submirror, see Creating RAID 0 (Stripe) Volumes or Creating RAID 0 (Concatenation) Volumes.

  2. Make sure that you have root privilege and that you have a current backup of all data.

  3. Use one of the following methods to attach a submirror.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, choose the mirror, then choose Action->Properties and click the Submirrors tab. Follow the instructions on screen. For more information, see the online help.

    • Use the metattach mirror submirror command.


      # metattach mirror submirror
      

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


Example 11–7 Attaching a Submirror


# metastat d30
d30: mirror
    Submirror 0: d60
      State: Okay   
...
# metattach d30 d70
d30: submirror d70 is attached
# metastat d30
d30: mirror
    Submirror 0: d60
      State: Okay        
    Submirror 1: d70
      State: Resyncing
    Resync in progress: 41 % done
    Pass: 1
    Read option: roundrobin (default)
    Write option: parallel (default)
    Size: 2006130 blocks
...

This example shows the attaching of a submirror, d70, to a one-way mirror, d30, creating a two-way mirror. The mirror d30 initially consists of submirror d60. The submirror d70 is a RAID 0 volume. You verify that the status of the mirror is “Okay” with the metastat command, then attach the submirror. When the metattach command is run, the new submirror is resynchronized with the existing mirror. When you attach an additional submirror to the mirror, the system displays a message. To verify that the mirror is resynchronizing, use the metastat command.


ProcedureHow to Detach a Submirror

Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Read Background Information for RAID 1 Volumes.

  3. Use one of the following methods to detach a submirror.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, choose the mirror, then choose Action->Properties and click the Submirrors tab. Follow the instructions on screen. For more information, see the online help.

    • Use the metadetach command to detach a submirror from a mirror.


      # metadetach mirror submirror
      

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


Example 11–8 Detaching a Submirror


# metastat
d5: mirror
    Submirror 0: d50
...
# metadetach d5 d50
d5: submirror d50 is detached

In this example, mirror d5 has a submirror, d50, which is detached with the metadetach command. The underlying slices from d50 are going to be reused elsewhere. When you detach a submirror from a mirror, the system displays a confirmation message.


ProcedureHow to Place a Submirror Offline and Online

The metaonline command can only be used when a submirror was taken offline by the metaoffline command. After the metaonline command runs, Solaris Volume Manager automatically begins resynchronizing the submirror with the mirror.


Note –

The metaoffline command's capabilities are similar to that offered by the metadetach command. However, the metaoffline command does not sever the logical association between the submirror and the mirror.


Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Read Background Information for RAID 1 Volumes.

  3. Use one of the following methods to place a submirror online or offline.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, choose the mirror, then choose Action->Properties and click the Submirrors tab. Follow the instructions on screen. For more information, see the online help.

    • Use the metaoffline command to take offline a submirror.


      # metaoffline mirror submirror
      

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

    • Use the metaonline command to bring a submirror online.


      # metaonline mirror submirror
      

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


Example 11–9 Placing a Submirror Offline


# metaoffline d10 d11
d10: submirror d11 is offlined

In this example, submirror d11 is taken offline from mirror d10. Reads will continue to be made from the other submirror. The mirror will be out of sync as soon as the first write is made. This inconsistency is corrected when the offlined submirror is brought back online.



Example 11–10 Placing a Submirror Online


# metaonline d10 d11
d10: submirror d11 is onlined

In this example, submirror d11 is brought back online in mirror d10.


ProcedureHow to Enable a Slice in a Submirror

Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Read Overview of Replacing and Enabling Components in RAID 1 and RAID 5 Volumes and Background Information for RAID 1 Volumes.

  3. Use one of the following methods to enable a slice in a submirror.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, choose the mirror, then choose Action->Properties and click the Submirrors tab. Follow the instructions on screen. For more information, see the online help.

    • Use the metareplace command to enable a failed slice in a submirror.


      # metareplace -e mirror failed-slice 
      

      The metareplace command automatically starts a resynchronization to synchronize the repaired or replaced slice with the rest of the mirror.

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


Example 11–11 Enabling a Slice in a Submirror


# metareplace -e d11 c1t4d0s7
d11: device c1t4d0s7 is enabled

In this example, the mirror d11 has a submirror that contains slice, c1t4d0s7, which had a soft error. The metareplace command with the -e option enables the failed slice.

If a physical disk is defective, you can either replace it with another available disk (and its slices) on the system as documented in How to Replace a Slice in a Submirror. Alternatively, you can repair/replace the disk, format it, and run the metareplace command with the -e option as shown in this example.


Maintaining RAID 1 Volumes

Solaris Volume Manager reports status information on RAID 1 volumes and submirrors so a system administrator can determine what, if any, maintenance action is required. The following table explains mirror states.

Table 11–1 Submirror States

State 

Meaning 

Okay 

The submirror has no errors and is functioning correctly. 

Resyncing 

The submirror is actively being resynchronized. An error has occurred and been corrected, the submirror has just been brought back online, or a new submirror has been added. 

Needs Maintenance 

A slice (or slices) in the submirror has encountered an I/O error or an open error. All reads and writes to and from this slice in the submirror have been discontinued. 

Additionally, for each slice in a submirror, the metastat command shows the “Device” (device name of the slice in the stripe); “Start Block” on which the slice begins; “Dbase” to show if the slice contains a state database replica; “State” of the slice; and “Hot Spare” to show the slice being used to hot spare a failed slice.

The slice state is perhaps the most important information when you are troubleshooting mirror errors. The submirror state only provides general status information, such as “Okay” or “Needs Maintenance.” If the submirror reports a “Needs Maintenance” state, refer to the slice state. You take a different recovery action if the slice is in the “Maintenance” or “Last Erred” state. If you only have slices in the “Maintenance” state, they can be repaired in any order. If you have a slices in the “Maintenance” state and a slice in the “Last Erred” state, you must fix the slices in the “Maintenance” state first then the “Last Erred” slice. See Overview of Replacing and Enabling Components in RAID 1 and RAID 5 Volumes.

The following table explains the slice states for submirrors and possible actions to take.

Table 11–2 Submirror Slice States

State 

Meaning 

Action 

Okay 

The component has no errors and is functioning correctly. 

None. 

Resyncing 

The component is actively being resynchronized. An error has occurred and been corrected, the submirror has just been brought back online, or a new submirror has been added. 

If desired, monitor the submirror status until the resynchronization is done. 

Maintenance 

The component has encountered an I/O error or an open error. All reads and writes to and from this component have been discontinued. 

Enable or replace the failed component. See How to Enable a Slice in a Submirror, or How to Replace a Slice in a Submirror. The metastat command will show an invoke recovery message with the appropriate action to take with the metareplace command. You can also use the metareplace -e command.

Last Erred 

The component has encountered an I/O error or an open error. However, the data is not replicated elsewhere due to another slice failure. I/O is still performed on the slice. If I/O errors result, the mirror I/O will fail. 

First, enable or replace components in the “Maintenance” state. See How to Enable a Slice in a Submirror, or How to Replace a Slice in a Submirror. Usually, this error results in some data loss, so validate the mirror after it is fixed. For a file system, use the fsck command, then check the data. An application or database must have its own method of validating the device.

ProcedureHow to Check the Status of Mirrors and Submirrors

Step

    Use one of the following methods to check mirror or submirror status.

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

    • Run the metastat command on a mirror to see the state of each submirror, the pass number, the read option, the write option, and the size of the total number of blocks in mirror. For example, to check the status of the one-way mirror d70, use:


      # metastat d70
      d70: Mirror
          Submirror 0: d71
            State: Okay         
          Pass: 1
          Read option: roundrobin (default)
          Write option: parallel (default)
          Size: 12593637 blocks
      
      d71: Submirror of d70
          State: Okay         
          Size: 12593637 blocks
          Stripe 0:
              Device              Start Block  Dbase State        Reloc  Hot Spare
              c1t3d0s3                   0     No    Okay         Yes    
          Stripe 1:
              Device              Start Block  Dbase State        Reloc  Hot Spare
              c1t3d0s4                   0     No    Okay         Yes    
          Stripe 2:
              Device              Start Block  Dbase State        Reloc  Hot Spare
              c1t3d0s5                   0     No    Okay         Yes    

      See How to Change RAID 1 Volume Options to change a mirror's pass number, read option, or write option.

      See metastat(1M) for more information about checking device status.


Example 11–12 Checking Status of RAID 1 Volumes

Here is sample output from the metastat command.


# metastat
d0: Mirror
    Submirror 0: d1
      State: Okay        
    Submirror 1: d2
      State: Okay        
    Pass: 1
    Read option: roundrobin (default)
    Write option: parallel (default)
    Size: 5600 blocks
 
d1: Submirror of d0
    State: Okay        
    Size: 5600 blocks
    Stripe 0:
        Device              Start Block  Dbase State        Hot Spare
        c0t2d0s7                   0     No    Okay        
 
...

For each submirror in the mirror, the metastat command shows the state, an “invoke” line if there is an error, the assigned hot spare pool (if any), size in blocks, and information about each slice in the submirror.


ProcedureHow to Change RAID 1 Volume Options

Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Check Background Information for Changing RAID 1 Volume Options.

  3. Use one of the following methods to change mirror options.

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

    • Use the metaparam command to display and change a mirror's options. For example, to change a mirror to “first”, rather than round-robin, for reading, use the following:


      # metaparam -r first mirror  
      

      See RAID 1 Volume Options for a description of mirror options. Also see the metaparam(1M) man page.


Example 11–13 Changing a RAID 1 Volume's Read Policy


# metaparam -r geometric d30
# metaparam d30
d30: mirror current parameters are:
    Pass: 1
    Read option: geometric (-g)
    Write option: parallel (default)

In this example, the -r option changes a mirror's read policy to geometric.



Example 11–14 Changing a RAID 1 Volume's Write Policy


# metaparam -w serial d40
# metaparam d40
d40: mirror current parameters are:
    Pass: 1
    Read option: roundrobin (default)
    Write option: serial (-S)

In this example, the -w option changes a mirror's write policy to serial.



Example 11–15 Changing a RAID 1 Volume's Pass Number


# metaparam -p 5 d50
# metaparam d50
d50: mirror current parameters are:
    Pass: 5
    Read option: roundrobin (default)
    Write option: parallel (default)

In this example, the -p option changes a mirror's pass number to 5.


ProcedureHow to Expand a RAID 1 Volume

Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Read Background Information for RAID 1 Volumes.

  3. Use one of the following methods to expand a mirror.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, choose the mirror, then choose Action->Properties and click the Submirrors tab. Follow the instructions on screen. For more information, see the online help.

    • Use the metattach command to attach additional slices to each submirror. For example, to attach a component to a submirror, use the following:


      # metattach submirror component
      

      Each submirror in a mirror must be expanded. See the metattach(1M) man page for more information.


Example 11–16 Expanding a Two-Way Mirror That Contains a Mounted File System


# metastat
d8: Mirror
    Submirror 0: d9
      State: Okay        
    Submirror 1: d10
      State: Okay        
...
# metattach d9 c0t2d0s5
d9: component is attached
# metattach d10 c0t3d0s5
d10: component is attached

This example shows how to expand a mirrored mounted file system by concatenating two disk drives to the mirror's two submirrors. The mirror is named d8 and contains two submirrors named d9 and d10.


See Also

For a UFS, run the growfs(1M) command on the mirror volume. See How to Expand a File System.

An application, such as a database, that uses the raw volume must have its own way of growing the added space.

Responding to RAID 1 Volume Component Failures

ProcedureHow to Replace a Slice in a Submirror

Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Read Overview of Replacing and Enabling Components in RAID 1 and RAID 5 Volumes and Background Information for RAID 1 Volumes.

  3. Use one of the following methods to replace a slice in a mirror.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, choose the mirror, then choose Action->Properties and click the Submirrors tab. Follow the instructions on screen. For more information, see the online help.

    • Use the following form of the metareplace command to replace a slice in a submirror:


      metareplace mirror-name component-name
      
      • mirror-name is the name of the volume to create.

      • component-name specifies the name of the component that is to be replaced.

      See the following examples and the metainit(1M) man page for more information.


Example 11–17 Replacing a Failed Slice in a Mirror

The following example illustrates how to replace a failed slice when the system is not configured to use hot spare pools for the automatic replacement of failed disks. See Chapter 16, Hot Spare Pools (Overview) for more information about using hot spare pools.


# metastat d6
d6: Mirror
    Submirror 0: d16
      State: Okay        
    Submirror 1: d26
      State: Needs maintenance
...
d26: Submirror of d6
    State: Needs maintenance
    Invoke: metareplace d6 c0t2d0s2 <new device>
...
# metareplace d6 c0t2d0s2 c0t2d2s2
d6: device c0t2d0s2 is replaced with c0t2d2s2

The metastat command confirms that mirror d6 has a submirror, d26, with a slice in the “Needs maintenance” state. The metareplace command replaces the slice as specified in the “Invoke” line of the metastat output with another available slice on the system. The system confirms that the slice is replaced, and starts resynchronizing the submirror.


ProcedureHow to Replace a Submirror

Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Read Overview of Replacing and Enabling Components in RAID 1 and RAID 5 Volumes and Background Information for RAID 1 Volumes.

  3. Use one of the following methods to replace a submirror.

    • From the Enhanced Storage tool within the Solaris Management Console, open the Volumes node, choose the mirror, then choose Action->Properties and click the Submirrors tab. Follow the instructions on screen. For more information, see the online help.

    • Use the metadetach, metaclear, metatinit, and metattach commands to replace an entire submirror.


Example 11–18 Replacing a Submirror in a Mirror

The following example illustrates how to replace a submirror in an active mirror.

The specific configuration of the new volume d22 will depend on the component you are replacing. A concatenation, as shown here, would be fine to replace a concatenation, but would not be an ideal replacement for a stripe as it could impact performance.


# metastat d20
d20: Mirror
    Submirror 0: d21
      State: Okay        
    Submirror 1: d22
      State: Needs maintenance
...
# metadetach -f d20 d22
d20: submirror d22 is detached
# metaclear -f d22
d22: Concat/Stripe is cleared
# metainit d22 2 1 c1t0d0s2 1 c1t0d1s2
d22: Concat/Stripe is setup
# metattach d20 d22
d20: components are attached

The metastat command confirms that the two-way mirror d20 has a submirror, d22, in the “Needs maintenance” state. In this case, the entire submirror will be cleared and recreated. The metadetach command detaches the failed submirror from the mirror by using the -f option, which forces the detach to occur. The metaclear command clears the submirror. The metainit command recreates submirror d22, with new slices. The metattach command attaches the rebuilt submirror, and a mirror resynchronization begins automatically.

You temporarily lose the capability for data redundancy while the mirror is a one-way mirror.


Removing RAID 1 Volumes (Unmirroring)

ProcedureHow to Unmirror a File System

Use this procedure to unmirror a file system that can be unmounted while the system is running. To unmirror root (/), /var, /usr, or swap, or any other file system that cannot be unmounted while the system is running. see How to Unmirror a File System That Cannot Be Unmounted.

Steps
  1. Make sure that you have root privilege and that you have a current backup of all data.

  2. Read Background Information for RAID 1 Volumes.

  3. Verify that at least one submirror is in the Okay state.


    # metastat
    
  4. Unmount the file system.


    # umount /home
    
  5. Detach the submirror that will continue to be used for the file system

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


    # metadetach d1 d10
    
  6. Clear the mirror and remaining subcomponents.

    For more information, see the metaclear(1M)


    # metaclear -r d1
    
  7. Edit the /etc/vfstab file to use the component detached in Step 5, if necessary.

  8. Remount the file system.


Example 11–19 Unmirroring the /opt File System


# metastat d4
d4: Mirror
    Submirror 0: d2
      State: Okay        
    Submirror 1: d3
      State: Okay        
...
# umount /opt
# metadetach d4 d2
d4: submirror d2 is detached
# metaclear -r d4
d4: Mirror is cleared
d3: Concat/Stripe is cleared
(Edit the /etc/vfstab file so that the entry for /opt is changed  from d4 to the underlying slice or volume)
# mount /opt

In this example, the /opt filesystem is made of a two-way mirror named d4; its submirrors are d2 and d3, made of slices /dev/dsk/c0t0d0s0 and /dev/dsk/c1t0d0s0, respectively. The metastat command verifies that at least one submirror is in the “Okay” state. (A mirror with no submirrors in the “Okay” state must be repaired first.) The file system is unmounted then submirror d2 is detached. The metaclear -r command deletes the mirror and the other submirror, d3.

Next, the entry for /opt in the /etc/vfstab file is changed to reference the underlying slice. For example, if d4 were the mirror and d2 the submirror, the following line:


/dev/md/dsk/d4  /dev/md/rdsk/d4  /opt ufs  2  yes -

should be changed to:


/dev/md/dsk/d2  /dev/md/rdsk/d2  /opt ufs  2  yes -

By using the submirror name, you can continue to have the file system mounted on a volume. Finally, the /opt file system is remounted.

By using d2 instead of d4 in the /etc/vfstab file, you have unmirrored the mirror. Because d2 consists of a single slice, you can mount the file system on the slice name (/dev/dsk/c0t0d0s0) if you do not want the device to support a volume.


ProcedureHow to Unmirror a File System That Cannot Be Unmounted

Use this task to unmirror file systems that cannot be unmounted during normal system operation, including root (/), /usr, /opt, and swap.

Steps
  1. Run the metastat command to verify that at least one submirror is in the “Okay” state.

  2. Run the metadetach command on the mirror that contains root (/), /usr, /opt, or swap to make a one-way mirror.

  3. For /usr, /opt, and swap: change the file system entry in the /etc/vfstab file to use a non-Solaris Volume Manager device (slice).

  4. For root (/) only: running the metaroot command.

  5. Reboot the system.

  6. Run the metaclear command to clear the mirror and submirrors.


Example 11–20 Unmirroring root (/)


# metadetach d0 d20
d0: submirror d20 is detached
# metaroot /dev/dsk/c0t3d0s0
# reboot
...
# metaclear -r d0
d0: Mirror is cleared
d10: Concat/Stripe is cleared
# metaclear d20
d20: Concat/Stripe is cleared

In this example, root (/) is a two-way mirror named d0; its submirrors are d10 and d20, which are made of slices /dev/dsk/c0t3d0s0 and /dev/dsk/c1t3d0s0, respectively. The metastat command verifies that at least one submirror is in the “Okay” state. (A mirror with no submirrors in the “Okay” state must first be repaired.) Submirror d20 is detached to make d0 a one-way mirror. The metaroot command is then run, using the rootslice from which the system is going to boot. This command edits the /etc/system and /etc/vfstab files to remove information that specifies the mirroring of root (/). After a reboot, the metaclear -r command deletes the mirror and the other submirror, d10. The last metaclear command clears submirror d20.



Example 11–21 Unmirroring swap


# metastat d1
d1: Mirror
    Submirror 0: d11
      State: Okay        
    Submirror 1: d21
      State: Okay        
...
# metadetach d1 d21
d1: submirror d21 is detached
(Edit the /etc/vfstab file to change the entry for swap from  metadevice to slice name)
# reboot
...
# metaclear -r d1
d1: Mirror is cleared
d11: Concat/Stripe is cleared
# metaclear d21
d21: Concat/stripe is cleared

In this example, swap is made of a two-way mirror named d1; its submirrors are d11 and d21, which are made of slices /dev/dsk/c0t3d0s1 and /dev/dsk/c1t3d0s1, respectively. The metastat command verifies that at least one submirror is in the “Okay” state. (A mirror with no submirrors in the “Okay” state must first be repaired.) Submirror d21 is detached to make d1 a one-way mirror. Next, the /etc/vfstab file must be edited to change the entry for swap to reference the slice that is in submirror d21. For example, if d1 was the mirror, and d21 the submirror containing slice /dev/dsk/c0t3d0s1, the following line:


/dev/md/dsk/d1 - - swap - no -

should be changed to:


/dev/dsk/c0t3d0s1 - - swap - no -

After a reboot, the metaclear -r command deletes the mirror and the other submirror, d11. The final metaclear command clears submirror d21.


Using a RAID 1 Volume to Back Up Data

Although Solaris Volume Manager is not meant to be a “backup product,” it does provide a means for backing up mirrored data without unmounting the mirror or taking the entire mirror offline, and without halting the system or denying users access to data. This process happens as follows: one of the submirrors is detached, temporarily losing the mirroring, and backed up. That submirror is then reattached and resynchronized as soon as the backup is complete.

The UFS Snapshots feature provides the ability to take a backup of a system without taking the file system offline, and without needing to detach a submirror and incur the performance penalty of resynchronizing the mirror later. See Chapter 24, Using UFS Snapshots (Tasks), in System Administration Guide: Devices and File Systems for more information.

ProcedureHow to Use a RAID 1 Volume to Make an Online Backup

You can use this procedure on any file system except root (/). Be aware that this type of backup creates a “snapshot” of an active file system. Depending on how the file system is being used when it is write-locked, some files and file content on the backup might not correspond to the actual files on disk.

The following limitations apply to this procedure:

The high-level steps in this procedure are as follows:


Note –

If you use these procedures regularly, put them into a script for ease of use.



Tip –

The safer approach to this process is to attach a third or fourth submirror to the mirror, allow it to resync, and use it for the backup. This technique ensures that data redundancy is maintained at all times.


Steps
  1. Run the metastat command to make sure the mirror is in the “Okay” state.

    A mirror that is in the “Maintenance” state should be repaired first.

  2. Flush data and UFS logging data from cache to disk and write-lock the file system.


    # /usr/sbin/lockfs -w mount point 
    

    Only a UFS volume needs to be write-locked. If the volume is set up as a raw device for database management software or some other application, running lockfs is not necessary. (You might, however, want to run the appropriate vendor-supplied utility to flush any buffers and lock access.)


    Caution – Caution –

    Write-locking root (/) causes the system to hang, so it should never be performed. If you are backing up your root file system, skip this step.


  3. Detach one submirror from the mirror.


    # metadetach mirror submirror 
    

    In this command:

    mirror

    Is the volume name of the mirror.

    submirror

    Is the volume name of the submirror (volume) being detached.

    Reads will continue to be made from the other submirror. The mirror will be out of sync as soon as the first write is made. This inconsistency is corrected when the detached submirror is reattached in Step 7.

  4. Unlock the file system and allow writes to continue.


    # /usr/sbin/lockfs -u mount-point 
    

    You might need to perform necessary unlocking procedures based on vendor-dependent utilities used in Step 2 above.

  5. Use the fsck command to check the file system on the detached submirror to ensure a clean backup.


    # fsck /dev/md/rdsk/name
    
  6. Perform a backup of the offlined submirror.

    Use the ufsdump command or your usual backup utility.


    Note –

    To ensure a proper backup, use the raw volume, for example, /dev/md/rdsk/d4. Using “rdsk” allows greater than 2 Gbyte access.


  7. Attach the submirror.


    # metattach mirror submirror
    

    Solaris Volume Manager automatically begins resynchronizing the submirror with the mirror.


Example 11–22 Using a Mirror to Make an Online Backup

This example uses a mirror named d1, consisting of submirrors d2, d3 and d4. The submirror d3 is detached and backed up while submirrors d2 and d4 stay online. The file system on the mirror is /home1.


# /usr/sbin/lockfs -w /home1
# metadetach d1 d3
# /usr/sbin/lockfs -u /home1
# /usr/sbin/fsck /dev/md/rdsk/d3
(Perform backup using /dev/md/rdsk/d3)
# metattach d1 d3