This was written as a quick reference guide for setting up a mirrored (RAID 1) boot device.
I used a Sun Fire V240 system for this article. The same principles apply to mirroring the boot drive of any system running Solaris.
Requirements:
If you are using Solaris 9 or 10 then the Solaris Volume Manager (SVM) software is already installed with the entire distribution installation.
If using Solaris 8 you will need to have the Solaris 8 DVD or CD Software 2 of 2 to install Solstice Disk Suite.
Procedures:
We will be creating a RAID 1 using the first 2 disks on a SunFire
V240 system. A SunFire V240 will have the following logical device files for
the four internal disk drives.
/dev/dsk/c1t0d0s2 <== Boot drive
/dev/dsk/c1t1d0s2 <== Disk drive to mirror boot drive
/dev/dsk/c1t2d0s2
/dev/dsk/c1t3d0s2
For the sake of example, I will assume the following partitioning on the boot drive. Please refer to your /etc/vfstab after installation to confirm how your disk drives are partitioned.
c1t0d0s0 /
c1t0d0s1 swap
c1t0d0s3 /usr
1. Installing Solaris Operating Environment.
Install Solaris to preferred specifications following these rules:
- During the installation make sure to leave a small partition to create the metadevice state database on. This is a slice of disk that will hold all the metadata for the SVM configurations. Generally this will be done on slice 7, 50MB will be plenty of space. During installation you can create a 50MB filesystem mounted to /META on slice 7. Once the install completes you can umount /META and then modify /etc/vfstab to remove this entry for future system reboots. To keep the root directory clean, remove the /META directory.
- Install the entire distribution with OEM support.
2. Install Solstice Disk Suite on Solaris 8 systems.
If you are using Solaris 8 you will need to install Disk Suite.
If you have Solaris 9 or Solaris 10 installed you can skip to step 3.
Insert the Solaris 8 DVD after the installation is complete and perform the following.
# cd /cdrom/cdrom0/s0/Solaris_8/EA/products/DiskSuite_4.2.1/sparc/Packages
# pkadd -d .
Answer yes to all the questions and then reboot.
3. Partition the second disk drive to match the boot Drive.
# prtvtoc /dev/rdsk/c1t0d0s2 > /tmp/vtoc
# fmthard -s /tmp/vtoc /dev/rdsk/c1t1d0s2
4. Create Meta-State Databases.
It is good practice to create several replicas of the metadevice state databas on each slice. In the following example 3 state database replicas will be created on each disk’s slice 7.
# metadb -a -f -c3 c1t0d0s7 c1t1d0s7
Run the following command to confirm that the state databases have been created.
# metadb
In SVM there must always be 50% + 1 of the state database replicase available for a system to boot up. The problem is that if one of these two disks fail then only 50% of the state databases will be available. Therefore, the system will fail any subsequent reboots after one of the two boot disks fails. The following entry in the /etc/system file will allow the system to boot in case of a single disk failure.
set md:mirrored_root_flag = 1
5. Create logical devices for mirroring.
With SVM you can only mirror striped logical devices. You can not create a mirror using physical devices. So you will first have to setup each slice as a logical stripe of 1 unit. You will then mirror these logical devices.
Create a logical stripe of 1 for each slice of disk that will be a part of each mirror. You must use the -f (force) option for the slices that contain mounted file systems.
# metainit -f d10 1 1 c1t0d0s0
# metainit -f d11 1 1 c1t0d0s1
# metainit -f d13 1 1 c1t0d0s3
Create the logical stripes on the second drive.
# metainit d20 1 1 c1t1d0s0
# metainit d21 1 1 c1t1d0s1
# metainit d23 1 1 c1t1d0s3
Confirm the creation of these devices.
# metastat
6. Create initial mirrors.
This step will only set up one half of each mirror.
The second half will be attached in the next step.
# metainit d0 -m d10
# metaroot d0
The metaroot command will modify the /etc/vfstab file and the /etc/system file for you so that you will boot from the /dev/md/dsk/d0 device.
Create Mirrors for swap and /usr.
# metainit d1 -m d11
# metainit d3 -m d13
Modify the /etc/vfstab file to reflect these new meta-devices. The entries should look something like the following.
/dev/md/dsk/d1 – - swap – no -
/dev/md/dsk/d3 /dev/md/rdsk/d3 /usr ufs 1 no -
Reboot in order to get the / and /usr file systems to be remounted as the /dev/md/dsk/d* devices
# init 6
After the reboot check to make sure that the filesystems are mounted as /dev/md/dsk/d* devices.
# df –k
7. Attach second half of mirrors.
# metattach d0 d20
# metattach d1 d21
# metattach d3 d23
Run the metastat command to track the progress of the syncing of the mirrors.
# metastat
8. Setup system PROM.
You will need to modify the system PROM in order to boot from the second disk in the mirror if the first disk fails. For most systems the PROM already has a device alias for the second disk drive called ‘disk 1′.
# eeprom boot-device=”disk disk1 net”
9. TEST.
Wait until the mirrors are finished syncing.
# reboot — “disk1”