Creating a RAID 1 (mirroring) on Solaris
Introduction
The Solaris system includes the DiskSuite package that allows RAID 1 mirroring of a UFS filesystem using LVM. This tutorial explains how to achieve this. It goes without saying that you need two disks of the same capacity.
Procedure
Here are the necessary steps: Once we’re ready to mirror a disk, we display its partitions with the format command:
|
|
We choose the 1st disk (if it’s the one to be duplicated), then:
|
|
And we display the partition table with “p”:
|
|
Note: In Solaris, like in BSD, the 3rd partition (no. 2) is actually the entire disk.
So now we have a view of our existing partitions…
UFS
Important: We need to create a small partition of about 20MB that will host the “metadata” concerning the RAID 1. This metadata will be used by DiskSuite. The first step will be to copy the partition table from the 1st disk to the 2nd. Then we will create databases for the metadata. Then we will manually decide which partition will be mirrored by creating sub-mirrors. We will change the vfstab (the file that indicates which partition mounts where). We will attach the sub-mirrors to a mirror. We will create aliases for the mirrors. We will add this alias to the “boot-device”.
ZFS
We will simply create an identical partition to the one on the master disk and set it as root. Go directly to Copying the partition table to the 2nd disk
Creating a small partition for the metadata
partition> p
Volume: root
Current partition table (original):
Total disk cylinders available: 14087 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 14086 136.71GB (14087/0/0) 286698624
1 unassigned wm 0 0 (0/0/0) 0
2 backup wm 0 - 14086 136.71GB (14087/0/0) 286698624
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
Enter the number of the partition to edit and press “Enter” Choose the tag “unassigned” flag: vm size: 20mb
Then exit:
label
Copying the partition table to the 2nd disk
|
|
Use the 2nd slice to indicate the entire disk.
Creating metadata database for DiskSuite
|
|
CAUTION: Choose the correct partition letter on both disks (the small one we created)
Creating sub-mirrors
UFS
Let’s assume we want to mirror the 6 partitions of the disk (except the swap), for example / /usr /var /opt /home and /etc
Let’s start with / (root partition):
|
|
CAUTION: Be sure to enter the correct disk names. So here we have associated the partition containing / on the 1st disk with the mirror partition that will be on the 2nd disk, then we indicated that the 1st partition will be the master, then we specified that it was the root partition.
You need to do this for each partition (except the last command)
For /usr:
|
|
For /var:
|
|
For /opt:
|
|
For /etc:
|
|
For /home:
|
|
We can view the metadata with the command:
|
|
ZFS
|
|
Once finished, that’s it! You can stop here, it’s done for ZFS.
Editing the vfstab file
|
|
From now on, vfstab will no longer point to a disk but to a cluster. Here are the lines to edit:
Before, for /: /dev/md/dsk/d30 /dev/md/rdsk/d30 / ufs 1 no logging After, for /: /dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no logging
d0 will be the partition for /, then d1, d2, d3, etc…
At this point we can restart with these two commands in succession:
|
|
Attaching mirrors to sub-mirrors
|
|
These commands will start the synchronization of mirrors and sub-mirrors with each other. You can see the progress with “metastat”.
Then we change the crash dump:
|
|
Creating mirror aliases
We need to know the absolute path of the mirrored disk:
|
|
With this, we will create an alias for the mirror, replacing “dad” with “disk”:
|
|
Adding mirrors to the boot device
|
|
Then if we only have 2 disks, we need to add this line to the /etc/system file:
set md:mirrored_root_flag = 1
Resources
Last updated 11 Feb 2009, 16:15 +0200.