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 that cannot be unmounted, such as /usr and /swap, the system must 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 system-critical file systems, all submirrors must consist of only a single slice.
For the procedures associated with mirroring the root (/) file system, see“SPARC: How to Create a RAID-1 Volume From the root (/) File System” on page 113and“x86: How to Create a RAID-1 Volume From the root (/) File System by Using DCA” on page 122.
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 –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.
Check“Prerequisites for Creating Solaris Volume Manager Components” on page 45and“Creating and Maintaining RAID-1 Volumes” on page 97.
Identify the slice that contains the existing file system to be mirrored This example uses the slice c1t0d0s0.
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. 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” on page 42.
number-of-stripes Specifies the number of stripes to create.
Before You Begin
1
2
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.
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 following form of the metainit command.
# metainit volume-name number-of-stripes components-per-stripe component-name
Note –See Step 2 for an explanation of the options.
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. See the metainit(1M) man page for more information.
Caution –When you create a mirror from an existing file system, you must follow the next two steps precisely to avoid data corruption.
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.
For example, if the /etc/vfstab file contains the following entry for the file system: /dev/dsk/slice /dev/rdsk/slice /var ufs 2 yes -
3
4
5
Change the entry to read as follows:
/dev/md/dsk/mirror-name /dev/md/rdsk/mirror-name /var ufs 2 yes -
Remount your newly mirrored file system according to one of the following procedures:
■ If you are mirroring a file system that can be unmounted, then unmount and remount the file system.
# umount /filesystem # mount /filesystem
■ If you are mirroring a file system that cannot be unmounted, then reboot your system. # reboot
Use the following form of themetattach 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.