Pages

Monday, January 24, 2011

How to mirror root file system on x86 system

You can mirror root disk with Solaris Volume manager. This is useful to protect your root file system. Root file system (/) is a critical file system that need to be cared well. For eample you have a root disk with partition 0 is belong to root (/) file system. You can mirror this root disk to other disk with following steps:
  1. Check your root file system is mounted from your root disk. In this example you use c0d0s0 as your root filesystem.
    bash-3.00# df -k /
Filesystem size used avail capacity Mounted on
/dev/dsk/c0d0s0 14G 8.9G 5.4G 63% /
  1. Make the disk that will be used as second submirror tobe bootable.
    bash-3.00# fdisk -b /usr/lib/fs/ufs/mboot -n /dev/rdsk/c1d0s0
    bash-3.00# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1d0s0
  2. Create 2 metadevices that you will use as submirror. In this example you create d11 and d12.
    bash-3.00# metainit -f d11 1 1 c0d0s0
d11: Concat/Stripe is setup
bash-3.00# metainit d12 1 1 c1d0s0
d12: Concat/Stripe is setup
  1. Create the mirror. In this example you create mirror d1 use metadevice d11 as submirror
    bash-3.00# metainit d1 -m d11
d1: Mirror is setup
  1. Backup the affected file. Then set your mirror device d1 as your root filesystem. Check also that your root file system is now mounted from the mirror.
    bash-3.00# cp /etc/system /etc/system.bck
bash-3.00# cp /etc/vfstab /etc/vfstab.bck
bash-3.00# metaroot d1
bash-3.00# more /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
/dev/md/dsk/d1 /dev/md/rdsk/d1 / ufs 1 no -

  1. Reboot your system. Synchronize file systems before you reboot.
    bash-3.00# lockfs -a
    bash-3.00# init 6
  2. Verify that your system now using mirror d1 as root filesystem.
    bash-3.00# df -h /
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d1 14G 8.9G 5.4G 63% /
  1. Attach the second submirror d12 to the mirror.
    bash-3.00# metattach d1 d12
d1: submirror d12 is attached
  1. Check your mirror. Now it is resyncing

bash-3.00# metastat
d1: Mirror
Submirror 0: d11
State: Okay
Submirror 1: d12
State: Resyncing
Resync in progress: 4 % done
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 30732345 blocks (14 GB)

d11: Submirror of d1
State: Okay
Size: 30732345 blocks (14 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s0 0 No Okay Yes


d12: Submirror of d1
State: Resyncing
Size: 31391010 blocks (14 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c1d0s0 0 No Okay Yes


Device Relocation Information:
Device Reloc Device ID
c1d0 Yes id1,sd@SATA_____VBOX_HARDDISK____VB238eb2cf-1b6348b6
c0d0 Yes id1,cmdk@AVBOX_HARDDISK=VBceae357c-d2e0a4a0

  1. Edit GRUB entries to include the second submirror as boot device
    bash-3.00# vi /boot/grub/menu.lst
....
title alternate boot
root (hd1,0,a)
kernel /boot/multiboot
module /boot/x86.miniroot-safe

No comments:

Post a Comment