Setting Up RAID Volumes with Solaris Volume Manager, Part 2

By Sandra Henry-Stocker, ITworld.com |  Hardware Add a new comment

In last week's column, we examined the process of setting up RAID volumes on a Solaris 9 server. The process is surprisingly straightforward when there are no file systems on the target disks or partitions. When file systems occupy the target space, they have to be backed up and then reloaded for RAID 5. For mirrored volumes, on the other hand, you can set up your volume in such a way as to preserve the initial partition's contents. In this column, we'll look at how these things are done.



RAID 5 for File Systems



Let's says that we want to turn the /var partition on our new Solaris 9 server into a RAID 5 volume. One way to back up its contents is to use a ufsdump command to copy the file system to another location on the disk. A command such as this will copy /var quite expediently (you need to create /var-bkp first):




# ufsdump 0f - /dev/rdsk/c0t0d0s5 | (cd /var-bkp/; ufsrestore xf -)



The 0f argument in this command specifies that we want a full dump and that we will specify the device that we are writing to. The - argument says that we're not really writing to a device at all; instead we are going to pipe the dump output to another command. The /dev/rdsk/c0t0d0s5 argument is, of course, our /var partition.



On the right side of the pipe, we have grouped two commands -- one to move into the /var-bkp directory and another to extract the contents from the dump. When this command completes, /var-bkp looks the same as /var.



Since the system won't allow us to unmount /var, we'll just make some changes to /etc/vfstab and reboot the system to use the backup as /var. To do this, we first comment out the mount line for /var from /etc/vfstab. Then, we move /var to /var-orig (to get the mount out of the way), move /var-bkp to /var and reboot:


# mv /var /var-orig
# mv /var-bkp /var
# reboot


At this point, /var is simply a subdirectory in root and partition 5 is not mounted. We can, therefore, proceed with our construction of the new RAID 5 volume using a metainit command such as this:


# metainit d5 -r c0t0d0s5 c0t1d0s5 c0t2d0s5d5: RAID is setup


Again, metainit has not completed the configuration of the volume when it spits out "RAID is setup". It will take a while longer and we can use the metastat command to watch its progress. The new volume will be ready when the state is "Okay":



# metastat | grep State
    State: Okay



Once the RAID volume is ready, we can build a new file system with newfs, mount the volume on a temporary mount and then copy the contents of /var-bkp (now /var) back to what will become the new /var. The newfs and mount commands will look like this:



# newfs /dev/md/rdsk/d5
# mkdir /var-new
# mount /dev/md/dsk/d5 /var-new


We then have some choices on how to copy the original contents of /var to the new RAID volume. One choice is to use a tar-to-tar command such as this:

# cd /var; tar cpBf - * | (cd /var-new; tar xf -)



Another is to use a ufsdump command similar to the one we used to back up /var in the first place. Using a ufsdump like that shown below, however, our files will end up in /var-new/var and will then have to be moved up one level when we're done:



# ufsdump 0f - /var | (cd /var-new; ufsrestore xf -)
# cd /var-new/var
# mv * ..


Once we have moved our files into our new partition, we are ready to uncomment the old /var mount line in /etc/vfstab and change it to look like this:



/dev/md/dsk/d5    /dev/md/rdsk/d5    /var    ufs    3    yes    -


We can then move /var back to /var-bkp, /var-new to /var and reboot.


Once we've verified that our RAID volume is working properly (check the mount and the output of metastat), we can remove the contents of /var-bkp entirely and delete the /var-orig mount point.

# rm -rf /var-bkp
# rmdir /var-orig



Mirrors for File Systems


Creating mirrors for file systems that you want to preserve (even root and swap) turns out to be surprisingly easy, especially if you have a copy of the "Solaris Volume Manager Administration Guide" by your side. The meta-commands (metadb, metainit, metastat) can be a little intimidating if you have never used them or rarely use them, but the inch-thick book has a good number of examples to serve as "recipes" while you're cooking up your own RAID volumes.


One naming convention for mirrors seems to be to use numbers divisible by 10, such as 10 and 20, for volumes and intervening numbers such as 11 and 12 for the individual mirror components. The components for mirror d10, for example, would be d11 and d12 while those for mirror d20 would be d21 and d22.

    Add a comment

    Post a comment using one of these accounts
    Or join now
    At least 6 characters

    Note: Comment will appear soon after you have activated your account.
    Obscene/spam comments will be removed and accounts suspended.
    The information you submit is subject to our Privacy Policy and Terms of Service.

    ITworld LIVE

    Ask a question

    Ask a Question