Set up RAID1 and RAID5 in (Open-)Solaris
- January 18th, 2008
- Write comment
This paper is meant to show how to set up RAID1 and RAID5 under solaris using SVM (Solaris Volume Manager). Following operations has been tested on open-solaris 10.
Suppose you have 10 disks of the same size. Under solaris disk devices are listed under /dev/dsk/ as block devices, and /dev/rdsk/ as char-devices or raw disks. The descriptor of the disks connected via SCSI are in the form c<controller-number>t<scsi-id>d<LUN- id>s<slice-id>.
The slice #2 is the one for the whole disk, the one you should use when addressing the whole drive or to do a backup.
Ok, suppose you have just installed Solaris 10 onto the first drive c0t0d0s2, partitioned like following:
c0t0d0s0 mounted as /
c0t0d0s1 used as SWAP
c0t0d0s7 unused partition ( about ~30 MB )
Using slice #7 as following is a convention, you can use which you want.
Ok, now you want to ser up a RAID1 for both root and SWAP partition mirroring them on another drive, c0t1d0s2.
First thing, you should have the same partition schema on both drive, so do it manually or just copy the partition table like
prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
Right, now you should populate the unused partition with information about the drives you are going to use as meta-devices.
With lack of fantasy, these informations are stored in meta-databased.
You can generate them with
metadb -a -c n -f c0t0d0s7 c0t0d0s7
where -a stands for ‘add’, -c n says you want n copies of the metadb info so if some gets corrupted you can restore it, -f stands for ‘force’ since there are mounted slices on the drive c0t0d0, and obviously the last args indicate the slice where to save the metadb.
Be careful, if metadb info gets corupted your system won’t use the meta-devices without at least the 51% of them.
To avoid this condition if you get in trouble add ‘set md:mirrored_root_flag=1‘ to /etc/system to sacrifice integrity for aviability.
Anyway, if you just get the metadb lost on the submirror drive, you can delete and rebuild them ( man metadb should help ).
Right, now you will initialize the metadevices with single stripes values:
metainit -f <metadevice-name> 1 1 <slice>
Focus on metadevices names, they usually should be called dxy in this contest since we will call the mirror dx0 so the first metadevice should be dx1, the first submirror dx2 and so on.
So to initializate root and swap slices and their mirror in our example let’s do
metainit -f d11 1 1 c0t0d0s0 metainit -f d12 1 1 c0t1d0s0 metainit -f d21 1 1 c0t0d0s1 metainit -f d22 1 1 c0t1d0s1
Easy, isn’t it ? Now let’s create the main mirrors ( -m ) :
metainit d10 -m d11 metainir d20 -m d21
We now should have our mirrors in /dev/dm/dsk/ such as /dev/dm/dsk/d10
Now we have to tell the system using the mirrors instead of the slices.
For the root slice we can just use the metaroot command like:
metaroot d10
Than just change the swap entry in /etc/vfstab telling it to mount /dev/dm/dsk/d20 instead of c0t0d0s1
During all this line, the metastat command may be helpful in getting what’s going on in your system.
Now you just have to reboot your machine, and hopefully all should be right.
You may just have trouble with metadb info. If so, just log in as root for maintenance and use ‘metadb -i’ to show which metadb have problems ( upper case indicators in general, man metadb for more info ) and eventually delete and restore them.
Now that you have your machine running with the mirrors, you just have to attach the submirrors
metattach <mirror-name> <submirror>
Eg:
metattach d10 d12 metattach d20 d22
Here you have a RAID1 configured for your system-related slices on 2 of your disks.
Suppose now you want to set up a storage system with the remaining 8 drives, using RAID5 to increase performances and failure-tollerance.
The roadmap is simple:
1) Format all the drives to contain data and metadb information
2) Create the metadb info
3) Create an hotspare pool ( this only if you want to use hotspares )
4) Initialize the RAID5 volume.
6) Attach the hotspare pool ( this only if you want to use hotspares )
7) Wait for the syncing to be done and mount or define a mountpoint
Well, i guess you guys are able to use the format command do partition one drive, i just suggest using slice 0 for the data and again, slice 7 for the metadb info.
Then use:
prtvtoc cxtydzs2 | fmthard -s - cktjdhs2
to copy the partition table to all the other drives
Then use the same
metadb -a -c n cxtydzs7
on all drives to generate metadb info.
Now, lets say you want to use hotspares and you want to create an hotspare pool with 2 of your drives.
That means that your hotspare drives will be unused but will replace one of the used ones in case of failure and your storage system will still be redundant and failure-resistant as a solid RAID5 even if 2 of your drive fail.
Create the hotspare pool with
metainit <hot-spare-name> <slice-to-use> <slice-to-use> <...>
If you want to add a slice to your hot spare pool that is already created
metahs -a <hot-spare-name> <slice-to-add>
Now let’s create the RAID5 volume
metainit <volume-name> -r <slice-to-use> <slice-to-use> <slice-to-use> <...>
-r will just create the RAID5 volume… easy, isn’t it ?
Now let’s attach the hot spare pool to the RAID5 volume
metaparam -h <hot-spare-name> <RAID5-volume-name>
All done.
<RAID5-volume-name> is the one you gave when you created it, and it’s located in /dev/dm/dsk/<RAD5-volume>
Now just use the metastat command to monitor the status of your new RAID5 storage system, wait for syncing to be done.
You may want to define a filesystem on your new storage system:
in solaris, just creating a new UFS
newfs /dev/dm/dsk/<RAID5-volume-name>/
Then mount it wherever you want or define an /etc/vfstab entry to mount it at boot time =)
That’s all,
Have a nice day.
.A


