Monday, May 2, 2011

SVM mirroring root disk

How to Mirror root With Solaris Volume Manager in the Solaris 9 and 10 OS



Prerequisites

First, you need to identify the disks that you want to create mirrors with. You can do this by using the format command to find the disks in question.

Run the format command; below is an example of the output:

AVAILABLE DISK SELECTIONS:

0. c3t2d0

/pci@7b,0/pci1022,7458@11/pci1000,3060@2/sd@2,0

1. c3t3d0

/pci@7b,0/pci1022,7458@11/pci1000,3060@2/sd@3,0

In my example, I'm mirroring the root partitions along with the other partitions from the disk drive.

My drives are c3t2d0 and c3t3d0.

Procedure for Mirroring root

First, partition your primary drive, typically the one that the Solaris OS is currently running on. (In my case, this is drive 0, c3t2d0.) I traditionally do this during the installation of the Solaris OS to prevent data loss.

You will need one partition that is about 10 Mbyte for the meta database.

Once you are satisfied with the partition that you have created, ensure that you label the disk, and then perform the following steps to transfer the same partitioning table.

Transfer the partition table from one drive to another.

prtvtoc /dev/rdsk/c3t2d0s2
fmthard -s - /dev/rdsk/c3t3d0s2

Note: Notice the use of s2, which is typically the overlap partition; if you changed this on the disk, please substitute the proper slice in its place.

Now that you have the two disks looking the same, execute the following:

metadb -a -c 3 -f c3t2d0s7 c3t3d0s7

The -c 3 creates three copies of the metastat database in this space, just in case a single copy gets corrupted (which is never good).

We will initialize the disk that makes up the root partition by doing the following. I'm using s0 because this is my root partition; you can substitute where appropriate.

metainit -f d11 1 1 c3t2d0s0

metainit -f d12 1 1 c3t3d0s0

Now we will create the actual mirror:

metainit d10 -m d11

After you have completed the preceding steps, you need to run the following command, which will automatically update /etc/system and /etc/vfstab to let it know that you are using a metadevice as your root disk.

metaroot d10

After you have executed the commands above, you need to reboot the machine before attaching the other half of the mirror to the root device. You can't attach a currently mounted device, or the machine will go crazy. In order to attach the device you will need to do the following:

metattach d10 d12

To check on the status of the mirror, you can do the following:

metastat d10

You will want to update the Openboot with the prior alias for the boot devices. You can do this by doing the following:

ls -l /dev/dsk/c0t0d0s0

You output will look similar to the following

lrwxrwxrwx 1 root root 42 Jul 12 2007 /dev/dsk/c0t0d0s0 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:a

You will need to update the bold part above, with your output. You will then run the following command from the OS

eeprom "nvramrc=devalias mirror /pci@1e,600000/ide@d/disk@0,0:a devalias mirror-a /pci@1e,600000/ide@d/disk@1,0:a"

eeprom boot-device="mirror mirror-a"

eeprom "use-nvramrc?=true"

The below commands for doing this are from the OK prompt, don't do this else wise.

"nvalias mirror /pci@1e,600000/ide@d/disk@0,0:a mirror-a /pci@1e,600000/ide@d/disk@1,0:a"

"setenv boot-device mirror mirror-a"

If you are mirroring just the two internal drives, you will want to add the following line to /etc/system to allow it to boot from a single drive. This will bypass the SVM Quorum rule

set md:mirrored_root_flag = 1

Please note that if you are running a Sparc platform you can use the installboot command in order to install the boot blocks onto the head of the drive.

For a UFS based File system you will use the below command.

installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t0d0s0

And on a ZFS based File System you will use the below command.

installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c0t1d0s0

If you are on a X86 Platform you will want to use installgrub to do similar functions, below you will find references for that

/sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d0s0

No comments:

Post a Comment