Use this procedure to mirror file systems, such as /usr, /opt, and swap, that cannot be unmounted during normal system usage.
To save the crash dump when you have mirrored swap, use the dumpadm(1M) command to configure the dump device as a metadevice. For instance, if the swap device is named /dev/md/dsk/d2, use dumpadmdumpadm to set this as the dump device.
To use the command line to mirror root (/), refer to "SPARC: How to Create a Mirror From root (/) (Command Line)", or "x86: How to Create a Mirror From root (/) (Command Line)".
The high-level steps in this procedure are:
Using metainit(1M) -f to put the file system's slice in a single slice (one-way) concat/stripe (submirror1)
Creating a second concat/stripe (submirror2)
Using metainit(1M)to create a one-way mirror from submirror1
Editing the /etc/vfstab file so that the file system refers to the mirror
Rebooting
Using metattach(1M) to attach submirror2
Do not create a multi-way mirror. Rather, create a one-way mirror with the metainit(1M) command, then attach the additional submirrors with the metattach(1M) command. When the metattach(1M) command is not used, no mirror resync occurs and data could become corrupted.
After checking the prerequisites ("Prerequisites for Creating DiskSuite Objects"), and the preliminary information ("Preliminary Information for Creating Mirrors"), use the metainit(1M) and metattach(1M) commands to create the mirror.
# 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 resync. (The system verifies that the concatenations and the mirror are set up, and that submirror d22 is attached.)
# 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 containing 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 resync. (The system verifies that the concatenations and the mirror are set up, and that submirror d21 is attached.)