To add a mirror to a metadevice with one or
more soft partitions can be
done with a short amount of downtime,. The best way to illustrate this procedure
is with an example.
In the example below, we'll use the following metadevice names:
d50 - this is the current metadevice (most likely a stripe or
concat device) which is divided into softpartitons
d70 thru d79 - these are the soft partitions currently on d50.
d80 - a new metadevice that we will create to be used the main
The problem with this configuration is that d50 cannot be used directly as a submirror because it is currently the "parent" of one or more softpartitions. To get it mirrored, we first have to remove the softpartitions (but just temporarily). Then, after d50 is simply a submirror of a mirror metadevice, we can create the soft partitions on the mirror device without loss of data. Here is the step-by-step example procedure:
1. Backup all data, and verify that no hotspare is in use for any of the metadevices being modified.
2. Run 'metastat -p' and save the output into a file. then, edit the file and remove all the lines EXCEPT for the soft partitions d70 thru d79. Also change all occurance of d50 to d80, since that will be the new "parent" of the softpartitions. If you put the word "metainit" in front of each line, you'll then have a script that you can run in step 5 (below) to recreate all the soft partitons. So in summary, we've changed the file from this:
d70 -p d50 -o 496594974 -b 20480
d71 -p d50 -o 496574493 -b 20480
d72 -p d50 -o 496554012 -b 20480
d73 -p d50 -o 1385984063 -b 106954752
d74 -p d50 -o 1377427518 -b 8556544
d75 -p d50 -o 1373233213 -b 4194304
d76 -p d50 -o 1356455996 -b 16777216
d77 -p d50 -o 1339678779 -b 16777216
d78 -p d50 -o 1322901562 -b 16777216
d79 -p d50 -o 1306124345 -b 16777216
metainit d70 -p d80 -o 496594974 -b 20480
metainit d71 -p d80 -o 496574493 -b 20480
metainit d72 -p d80 -o 496554012 -b 20480
metainit d73 -p d80 -o 1385984063 -b 106954752
metainit d74 -p d80 -o 1377427518 -b 8556544
metainit d75 -p d80 -o 1373233213 -b 4194304
metainit d76 -p d80 -o 1356455996 -b 16777216
metainit d77 -p d80 -o 1339678779 -b 16777216
metainit d78 -p d80 -o 1322901562 -b 16777216
metainit d79 -p d80 -o 1306124345 -b 16777216
3. Unmount all the softpartitions.
4. Run 'metaclear' on all the softpartitions to remove them. For example:
metaclear d70 d71 d72 d73 d74 d75 d76 d77 d78 d79
5. Now you are free to use d50 as a submirror, so create a mirror device (d80) using d50:
# metainit d80 -m d50
6. Recreate the softpartitions by running the script file you edited instep 2. This will recreate all the soft partitions, but on d80, instead of d50. Since the locations of the soft partitions are the same, the data will still be intact.
7. Mount all the softpartitions again... at this point, your downtime is over, and normal operations on the soft partitions are able to start.
8. Create a new concat or stripe metadevice of the same size as d50.
We'll call this new submirror d60. then, attach it to d80:
# metainit d60 1 4 c1t2d0s0 c1t2d1s0 c1t2d2s0 c1t2d3s0
# metattach d80 d60
Sun Microsystems, Inc. All Rights Reserved
MOVING FILES WITH CPIO
If you have a multitude of files to move from one directory or filesystem to another, here's a one liner:
# find /old_directory -depth | cpio -pdmv /new_directory
This will move all of the files under the specified old_directory to the new_directory, keeping the same ownership, permissions, and directory structure.