The instructions assume we are going to mirror the system/boot disk
(e.g. filesystems root (/
), /usr
, /var
,
/usr/vice/cache
, and swap). It is fairly straight forward to
adapt these instructions to mirror other filesystems (either separately or
in conjunction with the above), and to deal with systems with more than 2
disks.
The instructions assume that we are enabling mirroring on a newly installed, non-production machine. These restrictions are not strictly required, but obviously enabling mirroring of the system disk on a system already in production runs some risks. The system WILL need to be rebooted at least once when mirroring the system disk; if a non-system disk is being mirrored you can probably get away with just umounting and remounting the partitions being mirrored at the appropriate times. NOTE: all filesystems being mirrored must be mounted using the single-ply metadisk mirror before attaching the second submirror to the mirror metadevice; if new data written to the filesystem will only be written to one submirror, and disksuite will get very upset upon attempt to reboot (as the two submirrors are listed as being in sync but are not); if you do this with root will probably not even be able to get to single-user mode.
DISK1
and
DISK2
:
prtvtoc /dev/rdsk/DISK1 | fmthard -s - /dev/rdsk/DISK2
c0t0d0
and c0t1d0
, you would use
metadb -f -c3 -a /dev/dsk/c0t0d0s7
metadb -c3 -a /dev/dsk/c0t1d0s7
md.tab
file (found in /etc/opt/SUNWmd
on Solaris 2.7 systems, and /etc/lvm
on Solaris 8 and 9 systems);
this has the advantage of allowing comments and a more lasting record of what
was done (especially if save a copy in the glue config tree).
/var
) would be defined with:
/dev/md/dsk/d60 1 1 /dev/dsk/c0t0d0s5
/dev/md/dsk/d61 1 1 /dev/dsk/c0t1d0s5
-m
option and the
name of the metadevice corresponding to the disk/slice that currently has
data on it. The only submirror that should be mentioned in the mirror
metadevice definitions in the md.tab file should be the one refering to the
currently mounted physical device. Do not mention the other submirror in the
mirror definition or there can be data loss on the currently mounted slice
. Assuming we installed the system on the first disk from the
previous examples, the mirror metadevice for /var
(slice 5) would be
defined with:
/dev/md/dsk/d6 -m /dev/md/dsk/d60
md.tab
file does not actually define the metadevices,
but stores options to be used by the metainit
command when called
with insufficient arguments, much like /etc/vfstab
can be used to
store options for mount
. Because of the standard partitioning scheme
in use by glue, these md.tab
files are pretty standard, with usually
just the names of the physicsal devices for the two disks needing to be changed.
Review your md.tab file and make sure it is correct. In
particular, make sure the mirror metadevice definitions refer to the submirror
referring to the slice which has the good filesystem on it.
metainit -f SUBMIRROR_NAME
/var
slice would have its
submirror device initialized, retaining the current contents of /var
,
with the command:
metainit -f d60
-f
is required because the physical device referenced in the
md.tab
file for submirror d60
is currently mounted.
Similar commands should be issued for each slice to mirror.
metainit SUBMIRROR_NAME
/var
) with the command:
metainit d61
-f
flag is used in this case.
Similar commands should be issued for each slice to mirror.
metainit MIRROR_NAME
/var
would be
initialized with
metainit d6
d60
(because that is how d6
was defined in the md.tab
file).
Similar commands should be issued for each slice to mirror.
Note: it is important that the single submirror be the
submirror referring to the currently active/mounted disk/slice, otherwise
data loss may occur.
You may want to review your md.tab
file again
before issuing the commands to create the mirrors.
metastat
command to see that all the
submirrors and single-ply mirrors were set up correctly. Everything should be
indicating a state of "Okay". Mirror metadevices should list a single submirror
corresponding to the currently mounted device (if the other submirror is listed,
correct it NOW to avoid data loss), and submirrors should list
the physical device they are associated with and the mirror metadevice they
are attached to. The unattached submirrors (i.e. those referring to slices
not currently mounted) will show up as "Concat/Stripe" at this time.
If any thing looks wrong or a mistake was made, FIX IT NOW
to avoid data loss. You should be able to metadetach
the incorrect
mirror, and possibly metaclear
the problematic mirror and
submirrors, edit the md.tab
file to correct things,
and recreate the affected submirrors and mirror.
umount
, edit
vfstab
, and remount. But most likely a reboot will be required after
making the changes below.
/
) filesystem is being mirrored,
you MUST run the metaroot
command. Usage is
metaroot ROOT_MIRROR_METADEVICE
/etc/vfstab
entry for root, but more importantly it modifies
/etc/system
so that the kernel knows where the root filesystem is.
Failure to run this command might result in an inability to boot the system.
Using the standard Physics naming scheme, the root device on slice 0 will
get mirrored to the metadevice d1
, and so would want to issue the
command
metaroot d1
/etc/vfstab
file should list
/dev/md/dsk/d1
as the device to mount on /
. Also, the
text file /etc/system
should contain a new stanza with metadisk
related stuff in it, something like
* Begin MDD root info (do not edit)
forceload: misc/md_trans
forceload: misc/md_raid
forceload: misc/md_hotspares
forceload: misc/md_sp
forceload: misc/md_stripe
forceload: misc/md_mirror
forceload: drv/pcisch
forceload: drv/mpt
forceload: drv/sd
rootdev:/pseudo/md@0:0,1,blk
* End MDD root info (do not edit)
/etc/vfstab
to have the filesystem mounted using the
mirror metadevice. Yo can use the root partition as modified by metaroot as
a guide. Following our previous examples, the line for /var
would
be so,ething like:
/dev/md/dsk/d6 /dev/md/rdsk/d6 /var ufs 1 no logging
/
), /usr
, or other critical system filesystems, you
must reboot before proceeding further. The filesystems MUST
be remounted using the mirror metadevices before attaching the second
submirror to the mirror device, or serious problems (including inability to
boot even to single user mode) can occur.
devalias altboot /pci@1f,4000/scsi@3/disk@1,0
mount
command and make sure all filesystems to
be mirrored are listed as mounted under the metadisk mirror device, not
the physical device. Do not proceed any further
unless this is the case,
as attaching the second submirror while the physical device for the first
submirror is mounted will result in metadisk syncing the disks, but any
writes to the file system go to one disk only, thereby breaking the
synchronization. What is worse, is that metadisk thinks they are
synchronized, and will fail hard. You might not even be able to get into
single user on next reboot. Make sure all filesystems to be
mirrored are mounted with the metadisk mirror device before attaching
the other submirror. This generally means a reboot after editting
vfstab
as indicated in previous step.
metattach MIRROR SUBMIRROR2
SUBMIRROR2
to be attached to MIRROR
,
and will cause the newly attached submirror to be synchronized with the
previous submirror, copying information from the old submirror to the new one.
For the /var
filesystem in our example,
metattach d6 d61
. Repeat this for all filesystems to mirror.
Because the synchronization can take a while and keep the disks quite busy,
you may want to allow each slice to finish synchronizing before starting the
next on a production system (see the metastat
command below). On
non-production systems I usually get let them all sync in parallel.
metastat
to see how things are going. All the
mirrors you recently attached should be syncing up. This can take some time.
The new submirrors should now show up as "Submirrors" and not as
"Concat/Stripes". States for the newly attached submirrors will be
"Resyncing" but should eventually change to OK when synchronized.
dumpadm -d `
swap -l | tail -1 | awk '{print $1}'`
/dev/md/desk/d2
. You can verify this at a later point
by issuing the command dumpadm
without any arguments.
Failure to do this may cause serious problems if a crash dump ever
gets written, and may make system unbootable
/
),
you need to make the mirror disk bootable. On SPARC systems,
this can be done with the command
installboot /usr/platform/`
uname -i`
/lib/fs/ufs/bootblk /dev/rdsk/ROOT2
ROOT2
is the root slice of the mirrored disk. E.g.
c0t1d0s0
.
vfstab
file.) If you did not do it then, you can do it now, as
follows:
/dev/dsk
and extracting
everything following the /devices
part. E.g., if the mirrored
root disk is c0t1d0s0
, issue the command
ls -l /dev/dsk/c0t1d0s0
. This should return something like
benfranklin:~# ls -l /dev/dsk/c1t1d0s0
lrwxrwxrwx 1 root root 70 May 4 2004 /dev/dsk/c1t1d0s0 -> ../../devices/pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w21000004cf8a6403,0:a
pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w21000004cf8a6403,0:a
.
eeprom nvramrc
. If it returns something like data not available,
you can just go ahead. Otherwise you need to determine if the previous
definitions should be kept or not. If you want to wipe them out, just proceed
as if there were no previous definitions, otherwise you need to cut and paste
the previous definitions into the next command.
eeprom "nvramrc=OLDDEFS devalias mirror PHYSPATH
OLDDEFS
are any old definitions in the NVRAM that you wish
to keep, and PHYSPATH
is the physical path to the secondary boot
disk. For the above example, assuming no previous definitions exist (or want
to keep), you would have:
eeprom "nvramrc=devalias mirror /pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w21000004cf8a6403,0:a"
nvalias mirror /pci@8,600000/SUNW,qlc@4/fp@0,0/ssd@w21000004cf8a6403,0:a
show-disks
command,
and selecting the device you want, and then typing ^Y
(control-Y)
instead of the long device name in the nvalias
command).
eeprom "use-nvram?=true"
setenv use-nvramrc? true
eeprom "nvramrc"
devalias
set md:mirrored_root_flag=1
/etc/system
.
If you are primarily interested in a system that stays up as much as possible,
and will reboot successfully if it goes down after a disk failure, you want
this option set.