此文章说明如何使用Logical Storage Manager (LSM)对引导区创建一个镜像卷。操作系统版本需要5.0以上
并且只限于使用单机系统。
步骤1:将advfs或者ufs分区转换为lsm卷
1. 以root用户登陆
2. 确定系统的引导盘和swap分区
# consvar -l
Output similar to the following is displayed:
auto_action = HALT
boot_dev = dsk0
bootdef_dev = dsk0
booted_dev = dsk0
...
# swapon -s
Output similar to the following is displayed:
Swap partition /dev/disk/dsk0b (default swap):
Allocated space: 25600 pages (200MB)
In-use space: 1018 pages ( 3%)
Free space: 24582 pages ( 96%)
3. 输入disklabel命令察看分区状况
# disklabel dsk0
Output similar to the following is displayed:
...
8 partitions:
# size offset fstype [fsize bsize cpg] # NOTE: values not exact
a: 262144 0 AdvFS # (Cyl. 0 - 115*)
b: 262144 262144 swap # (Cyl. 115*- 231*)
c: 8380080 0 unused 0 0 # (Cyl. 0 - 3707)
d: 4096 8375984 unused 0 0 # (Cyl. 3706*- 3707)
e: 2618597 3142885 unused 0 0 # (Cyl. 1390*- 2549*)
f: 2614502 5761482 unused 0 0 # (Cyl. 2549*- 3706*)
g: 1433600 524288 AdvFS # (Cyl. 231*- 866*)
h: 6418096 1957888 unused 0 0 # (Cyl. 866*- 3706*)
4.如果swap分区在不同的盘上。重复第3步。特别注意盘的名字
5。输入volencap命令。例:
# volencap dsk0 dsk4
Output similar to the following is displayed:
Setting up encapsulation for dsk0.
- Creating simple disk dsk0d for config area (privlen=4096).
- Creating nopriv disk dsk0a for rootvol.
- Creating nopriv disk dsk0b.
- Creating nopriv disk dsk0g.
Setting up encapsulation for dsk4.
- Creating simple disk dsk4h for config area (privlen=4096).
- Creating nopriv disk dsk4b for swapvol.
The following disks are queued up for encapsulation or use by LSM:
dsk0d dsk0a dsk0b dsk0g dsk4h dsk4b
You must now run /sbin/volreconfig to perform actual encapsulations.
6. If appropriate, send a warning to your user community to alert them of
the impending shutdown of the system.
When there are no users on the system, proceed with step 7.
7. Enter the volreconfig command to complete the encapsulation
process. Enter now when prompted to shut down the system:
# volreconfig
Output similar to the following is displayed:
The system will need to be rebooted in order to continue with
LSM volume encapsulation of:
dsk0d dsk0a dsk0b dsk0g
dsk4h dsk4b
Would you like to either quit and defer encapsulation until later
or commence system shutdown now? Enter either ’quit’ or time to be
used with the shutdown(8) command (e.g., quit,
now, 1, 5): [quit] now
系统将重新启动
步骤2. 创建引导区和swap的镜像卷
在完成第一步后,第二步将引导分区和swap作为镜像卷。这个过程将会花费几分钟。
*如果swap分区在引导盘上。输入
# volrootmir -a target_disk(目标盘)
*如果swap分区在不同的盘上
# volrootmir -a swap=swap_target_disk boot_target_disk
具体请参考volrootmir手册
确认成功
当完成上述两个步骤之后。请输入命令。确认操作成功
显示当前卷的信息
# volprint -pt
PL NAME VOLUME KSTATE STATE LENGTH LAYOUT NCOL/WID MODE
pl rootvol-01 rootvol ENABLED ACTIVE 262144 CONCAT - RW
pl rootvol-02 rootvol ENABLED ACTIVE 262144 CONCAT - RW
pl swapvol-01 swapvol ENABLED ACTIVE 333824 CONCAT - RW
pl swapvol-02 swapvol ENABLED ACTIVE 333824 CONCAT - RW
pl vol-dsk0g-01 vol-dsk0g ENABLED ACTIVE 1450796 CONCAT - RW
pl vol-dsk0g-02 vol-dsk0g ENABLED ACTIVE 1450796 CONCAT - RW
确定引导盘信息
# consvar -l
Output similar to the following is displayed:
auto_action = HALT
boot_dev = dsk0,dsk4
bootdef_dev = dsk0,dsk4
booted_dev = dsk0
...
察看advfs域信息(使用advfs分区)
# ls -R /etc/fdmns/*
/etc/fdmns/root_domain:
rootdg.rootvol
/etc/fdmns/usr_domain:
rootdg.vol-dsk0g
察看ufs分区
# mount
/dev/vol/rootdg/rootvol on / type ufs (rw)
/dev/vol/rootdg/vol-dsk0g on /usr type ufs (rw)
/proc on /proc type procfs (rw)
察看swap分区
# swapon -s
Swap partition /dev/vol/rootdg/swapvol (default swap):
Allocated space: 25600 pages (200MB)
In-use space: 426 pages ( 1%)
Free space: 25174 pages ( 98%)
Total swap allocation:
Allocated space: 25600 pages (200.00MB)
Reserved space: 9015 pages ( 35%)
In-use space: 426 pages ( 1%)
Available space: 16585 pages ( 64%)
*以下说明当不需要使用镜像卷或者不想使用lsm的步骤*
1.显示当前卷
# volprint -htq
v rootvol root ENABLED ACTIVE 262145 ROUND -
pl rootvol-01 rootvol ENABLED ACTIVE 262145 CONCAT - RW
sd root01-01p rootvol-01 root01 0 16 0 dsk0a ENA
sd root01-01 rootvol-01 root01 16 262129 16 dsk0a ENA
pl rootvol-02 rootvol ENABLED ACTIVE 262145 CONCAT - RW
sd root02-02p rootvol-02 root02 0 16 0 dsk4a ENA
sd root02-02 rootvol-02 root02 16 262129 16 dsk4a ENA
v swapvol swap ENABLED ACTIVE 409600 ROUND -
pl swapvol-01 swapvol ENABLED ACTIVE 409600 CONCAT - RW
sd swap01-01 swapvol-01 swap01 0 409600 0 dsk0b ENA
pl swapvol-02 swapvol ENABLED ACTIVE 409600 CONCAT - RW
sd swap02-02 swapvol-02 swap02 0 409600 0 dsk4b ENA
v vol-dsk0g fsgen ENABLED ACTIVE 1375019 SELECT -
pl vol-dsk0g-01 vol-dsk0g ENABLED ACTIVE 1375019 CONCAT - RW
sd dsk0g-01 vol-dsk0g-01 dsk0g-AdvFS 0 1375019 0 dsk0g ENA
pl vol-dsk0g-02 vol-dsk0g ENABLED ACTIVE 1375019 CONCAT - RW
sd dsk4g-01 vol-dsk0g-02 dsk4g-AdvFS 0 1375019 0 dsk4g ENA
PL NAME VOLUME KSTATE STATE LENGTH LAYOUT NCOL/WID MODE
2.移除镜像的plex.
# volplex -o rm dis rootvol-02
# volplex -o rm dis swapvol-02
# volplex -o rm dis vol-dsk0g-02
3.察看移除后的卷
# volprint -htq
...
v rootvol root ENABLED ACTIVE 262145 ROUND -
pl rootvol-01 rootvol ENABLED ACTIVE 262145 CONCAT - RW
sd root01-01p rootvol-01 root01 0 16 0 dsk0a ENA
sd root01-01 rootvol-01 root01 16 262129 16 dsk0a ENA
v swapvol swap ENABLED ACTIVE 409600 ROUND -
pl swapvol-01 swapvol ENABLED ACTIVE 409600 CONCAT - RW
sd swap01-01 swapvol-01 swap01 0 409600 0 dsk0b ENA
v vol-dsk0g fsgen ENABLED ACTIVE 1375019 SELECT -
pl vol-dsk0g-01 vol-dsk0g ENABLED ACTIVE 1375019 CONCAT - RW
sd dsk0g-01 vol-dsk0g-01 dsk0g-AdvFS 0 1375019 0 dsk0g ENA
4.输入volunroot命令恢复成为原始分区(advfs或者ufs).
# volunroot -a
This operation will convert the following file systems on the
system/swap disk dsk0 from LSM volumes to regular disk partitions:
Replace volume rootvol with dsk0a.
Replace volume swapvol with dsk0b.
Replace volume vol-dsk0g with dsk0g.
This operation will require a system reboot. If you choose to
continue with this operation, your system files will be updated
to discontinue the use of the above listed LSM volumes.
/sbin/volreconfig should be present in /etc/inittab to remove
the named volumes during system reboot.
Would you like to either quit and defer volunroot until later
or commence system shutdown now? Enter either ’quit’ or time to be
used with the shutdown(8) command (e.g., quit, now, 1, 5): [quit] now
重新启动系统。操作完成
这种方法适用于系统已经做好并且没有硬raid存在的情况,在进行操作以前需要备份系统和数据。
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/