Thursday, October 30, 2008

Root (Boot Disc) Mirroring Using Solaris Volume Manager (SVM)

For added fail-safe for our servers, besides having good backups, is having our boot discs mirrored. The following steps were done using Solaris 10 on a sparc machine (V490).

Assumptions:
HDD0 - c0t0d0 (Primary Disc)
HDD1 - c0t1d0

Partitions of HDD0:
/ - c0t0d0s0
swap - c0t0d0s1
backup - c0t0d0s2 (this represents the whole disc)
/var - c0t0d0s3
/opt - c0t0d0s4
unassigned - c0t0d0s7 (this would be used to store our metadbs)

1. Start by making HDD1's partition table the same as HDD0:

# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2

2. Create atleast 2 (tough i prefer 3 which i will be using) state databases on each disc.

# metadb -afc 3 c0t0d0s7 c0t1d0s7

whereas:
-a = add state database
-f = force (this is needed for HDD0 which is mounted)
-c # = number of state databases in each slice

3. Initialize each disc.

HDD0
# metainit -f d10 1 1 c0t0d0s0
# metainit -f d11 1 1 c0t0d0s1
# metainit -f d13 1 1 c0t0d0s3
# metainit -f d14 1 1 c0t0d0s4

HDD1
# metainit -f d20 1 1 c0t1d0s0
# metainit -f d21 1 1 c0t1d0s1
# metainit -f d23 1 1 c0t1d0s3
# metainit -f d24 1 1 c0t1d0s4

4. Initialize the mirrors.

# metainit d0 -m d10
# metainit d1 -m d11
# metainit d3 -m d13
# metainit d4 -m d14

5. Metaroot and editing of /etc/vfstab to boot to our mirror.

# cat /etc/vfstab (to check vfstab before metaroot)
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /var ufs 1 no -
/dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /opt ufs 1 no -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -

# metaroot d0 (only use this for the root slice)

# cat /etc/vfstab (to check vfstab after metaroot)
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /var ufs 1 no -
/dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /opt ufs 1 no -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -


# vi /etc/vfstab (to edit the vfstab to boot to our mirror)
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/md/dsk/d1 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d3 /dev/md/rdsk/d3 /var ufs 1 no -
/dev/md/dsk/d4 /dev/md/rdsk/d4 /opt ufs 1 no -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -

6. Reboot the system

# lockfs -fa
# shutdown -y -g0 -i6

7. Attach the submirrors to the mirror.

# metattach d0 d20
# metattach d1 d21
# metattach d3 d23
# metattach d4 d24

* to monitor the progress of the syncing process

# while true; do metastat | grep %; sleep 3; clear; done

8. Change the core dump directory

# dumpadm (before changing)
Dump content: kernel pages
Dump device: /dev/dsk/c0t0d0s1 (swap)
Savecore directory: /var/crash/e3500
Savecore enabled: yes
# dumpadm -d swap
Dump content: kernel pages
Dump device: /dev/md/dsk/d1 (swap)
Savecore directory: /var/crash/e250
Savecore enabled: yes

9. Update the boot-device parameter to boot to either HDD0 or HDD1

Check the physical device path of both disc

# ls -l /dev/dsk/c0t?d0s0
lrwxrwxrwx 1 root root 41 Jun 5 16:49 /dev/dsk/c0t0d0s0 -> ../../devices/pci@1f,4000/scsi@3/sd@0,0:a
lrwxrwxrwx 1 root root 41 Jun 5 16:49 /dev/dsk/c0t1d0s0 -> ../../devices/pci@1f,4000/scsi@3/sd@1,0:a

Change the major name (in this case "sd") to disk for the boot-device.
Setting the boot-device can be done on the Solaris or the Open Boot (ok) prompt.

Solaris

# eeprom "nvramrc=devalias mirror /pci@1f,4000/scsi@3/disk@1,0:a"
# eeprom "use-nvramrc?=true"
# eeprom boot-device
boot-device=disk net
# eeprom "boot-device=disk mirror net"

Open Boot (ok) prompt

ok nvalias mirror /pci@1f,4000/scsi@3/disk@1,0:a
ok printenv boot-device
boot-device disk net
ok setenv boot-device disk mirror net

10. Lastly, because of the behavior of SVM (the rule half +1 stae database, so we could boot into the OS) we need to add a parameter on /etc/system

# echo "set md:mirrored_root_flag=1" >> /etc/system

You could also opt to add some tuning parameters that could speedup the process of syncing between drives.
This sets the size of the buffer used for resynchronizing RAID 1 volumes (mirrors) as the number of 512-byte blocks in the buffer. Setting larger values can increase resynchronization speed.

# echo "set md_mirror:md_resync_bufsz=1024" >> /etc/system (You could change the default value 1024 from
128 to 2048.)

Wednesday, October 29, 2008

Creating ISO File in Solaris

As I have stated on how to mount ISO files in Solaris, here is a follow up on how to create an ISO file under Solaris.

# mkisofs -l -L -r -o /some/folder/your-image.iso /the/directory/you/want/to/image/

whereas the parameters used are as follows:

-l Allow full 31 character filenames
-L This option will get POSIX.1-2001 semantics with mkisofs-2.02.(but you may use -allow-leading-dots)
-r This is like the -R option, but file ownership and modes are set to more useful values. The uid and gid are set to zero, because they are usually only useful on the author's system, and not useful to the client
-o filename is the name of the file to which the iso9660 filesystem image should be written.

Its been a while since I have written an article. Hope to have more time to write more articles.