Solaris Volume Manager Administration Guide

How 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 25, 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 a x86 system, install the boot information on the alternate boot disk before you create the RAID 0 or RAID 1 devices. See “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 interchangably.


  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: Basic Administration.

  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—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—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—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—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.