--------------------------------------
实施之前做好规划,规划如下:
--根分区
d0 d10 d20 / s0
--VAR分区
d1 d11 d21 /var s1
--SWAP分区
d2 d12 d22 swap s3
--export/home分区
d3 d13 d23 /export/home s4
--/opt分区
d4 d14 d24 /opt s5
d0,d1,d2,d3,d4为对应各个分区的metadevice名字;d10等是每个metadevice对应的子镜像
--------------------------------------
一、先用format和df -k查看一下磁盘的情况0号盘是c1t0d0,1号盘是c1t1d0
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf585b,0
1. c1t1d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf787a,0
Specify disk (enter its number): 1
selecting c1t1d0
[disk formatted]
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!
quit
format> quit
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf585b,0
1. c1t1d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf787a,0
Specify disk (enter its number): 0
selecting c1t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.
/dev/dsk/c1t0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c1t0d0s1 is currently mounted on /var. Please see umount(1M).
/dev/dsk/c1t0d0s3 is currently used by swap. Please see swap(1M).
/dev/dsk/c1t0d0s4 is currently mounted on /export/home. Please see umount(1M).
/dev/dsk/c1t0d0s5 is currently mounted on /opt. Please see umount(1M).
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!
quit
format> quit
# df -k
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s0 20174017 4058187 15914090 21% /
/devices 0 0 0 0% /devices
ctfs 0 0 0 0% /system/contract
proc 0 0 0 0% /proc
mnttab 0 0 0 0% /etc/mnttab
swap 23318320 1032 23317288 1% /etc/svc/volatile
objfs 0 0 0 0% /system/object
fd 0 0 0 0% /dev/fd
/dev/dsk/c1t0d0s1 698295 104196 538236 17% /var
swap 23317608 320 23317288 1% /tmp
swap 23317336 48 23317288 1% /var/run
/dev/dsk/c1d0t0s5 60509964 323494 59581371 1% /opt
/dev/dsk/c1d0t0s4 43194138 42945 42719252 1% /export/home
二、备份一下/etc/vfstab和/etc/system文件,以备不时之需
#cp /etc/vfstab /etc/vfstab.bak
#cp /etc/system /etc/system.bak
三、磁盘分区同步(使两块盘分区大小一样)
# prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2
fmthard: New volume table of contents now in place.
四、制作metadb
# metadb -a -f -c 3 c1t0d0s7 c1t1d0s7
五、做根分区的两路子镜像
# metainit -f d10 1 1 c1t0d0s0
d10: Concat/Stripe is setup
# metainit d20 1 1 c1t1d0s0
d20: Concat/Stripe is setup
六、制作根分区的镜像盘
# metainit d0 -m d10
d0: Mirror is setup
七、修改vfstab文件中关于根分区的项目
-----------------------------------------------------------------------------------
# more /etc/vfstab
#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/c1t0d0s3 - - swap - no -
/dev/dsk/c1t0d0s0 /dev/rdsk/c1t0d0s0 / ufs 1 no -
/dev/dsk/c1t0d0s1 /dev/rdsk/c1t0d0s1 /var ufs 1 no -
/dev/dsk/c1t0d0s4 /dev/rdsk/c1t0d0s4 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
-----------------------------------------------------------------------------------
# metaroot d0
# lockfs
八、改完后重启
#reboot
九、做/var分区的两路子镜像和/var分区的镜象盘
# metainit -f d11 1 1 c1t0d0s1
d11: Concat/Stripe is setup
# metainit d21 1 1 c1t1d0s1
d21: Concat/Stripe is setup
# metainit d1 -m d11
d1: Mirror is setup
十、修改vfstab文件中关于/var分区的项目
# vi /etc/vfstab
"/etc/vfstab" 14 lines, 525 characters
#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/c1t0d0s3 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/dsk/c1t0d0s4 /dev/rdsk/c1t0d0s4 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 519 characters
十二、重启系统
#reboot
十三、做swap分区的两路子镜像和swap分区的镜象盘
# metainit -f d12 1 1 c1t0d0s3
d12: Concat/Stripe is setup
# metainit d22 1 1 c1t1d0s3
d22: Concat/Stripe is setup
# metainit d2 -m d12
d2: Mirror is setup
十四、修改vfstab文件中关于swap分区的项目
# vi /etc/vfstab
"/etc/vfstab" 14 lines, 519 characters
#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/d2 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/dsk/c1t0d0s4 /dev/rdsk/c1t0d0s4 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 516 characters
十五、重启系统
#reboot
十六、做/export/home分区的两路子镜像和/export/home分区的镜象盘
# metainit -f d13 1 1 c1t0d0s4
d13: Concat/Stripe is setup
# metainit d23 1 1 c1t1d0s4
d23: Concat/Stripe is setup
# metainit d3 -m d13
d3: Mirror is setup
十七、修改vfstab文件中关于/export/home分区的项目
# vi /etc/vfstab
"/etc/vfstab" 14 lines, 516 characters
#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/d2 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/md/dsk/d3 /dev/md/rdsk/d3 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 510 characters
十八、重启系统
#reboot
-------------------------------------------------------
注意:
做到这步时,我犯了一个错误,用solaris的话来说,是fatal的,我vi时把本该写成/dev/md/dsk/d3 /dev/md/rdsk/d3 /export/home的却写成了/dev/md/dsk/d4 /dev/md/rdsk/d4 /export/home,因为/export/home是在s4分区,我习惯性的把s4对应成了d4了,结果重启后检查文件系统时就启不来了。于是查资料,解决过程如下:
现在使用的是完整的机器,也就是说有鼠标键盘和显示器,默认显示输出也是SUN显示器,而不是终端了。
先接上串口线连到终端上来,打开超级终端,此时我发现专用的键盘不起作用了,由于默认显示输出是SUN显示器,在超级终端上是看不到输出,但超级终端上的键盘是起作用的(这两个键盘和显示器的关系让我出了一身冷汗),于是我在超级终端的键盘上按CTRL+BREAK进入OK状态,通过SUN显示器可以看到,然后把SOLARIS的启动盘插入光驱并在OK状态下输入boot cdrom -s,用光盘单用户启动,就不加载文件系统了。系统起来后,用fsck检查一遍根分区,命令为fsck -y /dev/rdsk/c1t0d0s0,很快检查完了,再挂载到临时文件系统上,命令为mount -F ufs /dev/rdsk/c1t0d0s0 /mnt,由于要用vi来修改/etc/vfstab文件,所以还要设置一下环境变量,(TERM=vt100; export TERM),这样就可以vi /etc/vfstab了,改的时候我发现终端键盘的方向键不能用,只好用H,J,K,L来控制方向了,看来掌握方向是多么的重要啊,改完保存后,把文件系统卸载下来,命令为umount /mnt,reboot重启机器,正常了。
-------------------------------------------------------
十九、做/opt分区的两路子镜像和/opt分区的镜象盘
# metainit -f d14 1 1 c1t0d0s5
d14: Concat/Stripe is setup
# metainit d24 1 1 c1t1d0s5
d24: Concat/Stripe is setup
# metainit d4 -m d14
d4: Mirror is setup
二十、修改vfstab文件中关于/opt分区的项目
# vi /etc/vfstab
"/etc/vfstab" 14 lines, 510 characters
#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/d2 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/md/dsk/d3 /dev/md/rdsk/d3 /export/home ufs 2 yes -
/dev/md/dsk/d4 /dev/md/rdsk/d4 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 504 characters
二十一、重启系统
#reboot
二十二、将另外一路子镜像盘加入到镜像盘中
# metattach d0 d20
d0: submirror d20 is attached
# metattach d1 d21
d1: submirror d21 is attached
# metattach d2 d22
d2: submirror d22 is attached
# metattach d3 d23
d3: submirror d23 is attached
# metattach d4 d24
d4: submirror d24 is attached
二十三、查看镜象同步状态
# metastat | grep %
Resync in progress: 0 % done
Resync in progress: 0 % done
Resync in progress: 27 % done
Resync in progress: 0 % done
Resync in progress: 0 % done
# metastat | grep %
Resync in progress: 22 % done
Resync in progress: 58 % done
Resync in progress: 56 % done
Resync in progress: 5 % done
# metastat | grep %
Resync in progress: 39 % done
Resync in progress: 94 % done
Resync in progress: 9 % done
二十四、同步完之后记得打补丁