LVM & Mirror
中国惠普有限公司 支持服务事业部
Elements of LVM(逻辑卷管理器)
Logical Volume Manager Rules
一块物理硬盘(PV)只能属于一个卷组(VG)
一个VG里的最大逻辑卷(LV)数目是255
每个PV最大PE数目是65536,默认值是1016,可在创建VG时通过vgcreate –e 设定
每个VG中最大PV数目是255,默认值是16, 可在创建VG时通过
vgcreate –p 设定
Creating a Logical Volume with a File
System on a New Disk
2) 创建卷组所用目录
# mkdir /dev/vg01
Creating a Logical Volume with a File System on a New Disk
3) 创建卷组设备文件
# mknod /dev/vg01/group c 64 0x010000
Creating a Logical Volume with a File System on a New Disk
4) 创建卷组
Creating a Logical Volume with a File System on a New Disk
5) 创建大小为100M的逻辑卷lvtest
# lvcreate -L 100 –n lvtest vg01
Creating a Logical Volume with a File System on a New Disk
6) 创建文件系统
BAD BLOCK POOL
Newfs uses logical volume one's character
device file to create a 100 MB filesystem
in the space allocated by lvcreate.
Newfs creates a 'lost+found' directory
in the new filesystem.
# newfs /dev/vg01/rlvtest
Creating a Logical Volume with a File System on a New Disk
7) 创建挂起点
# mkdir /test
P V R A
BAD BLOCK POOL
NEW LVM DISK
V G R A
lost+found
ROOT DISK
Creating a Logical Volume with a File System on a New Disk
8) 执行挂起
# mount /dev/vg01/lvtest /test
# vi /etc/fstab
Creating a Logical Volume with a File System on a New Disk
9) 扩大逻辑卷
Creating a Logical Volume with a File System on a New Disk
# umount /test
# lvextend –L 100 /dev/vg01/lvtest
# extendfs /dev/vg01/rlvtest
# mount /dev/vg01/lvtest /test
Displaying LVM Information
For Physical Volumes
# pvdisplay [-v] /dev/dsk/cCtTdD
Displays information about
the physical volume(s)
specified
For Volume Groups
# vgdisplay [-v] /dev/vg*
Displays information about
all the volume groups
Displaying LVM Information
For Logical Volumes
# lvdisplay [-v] /dev/vg*/lvol*
Displays information about
all the logical volumes in all
the volume groups
Displaying LVM Information
lvlnboot -vShows definitions for
boot
root
swap
dump
Physical volumes in root volume group
Display Kernel Devices on
LVM and Bootable Disks
The contents of '/etc/lvmtab'
# strings /etc/lvmtab
Displays volume group to
physical volume
relationships
Displaying LVM Information
LVM Data Structure Backup
# vgcfgbackup vg01
LVM Data Structure Restore
# vgcfgrestore -n vg01 /dev/rdsk/c0t2d0
Disk 2 LVM structures corrupted
Mirror: One-Way Mirroring
# lvcreate -L 40 -m 1 /dev/vg01
# lvextend -m 1 /dev/vg01/lvol2
# lvextend -m 1 /dev/vg01/lvol2 /dev/dsk/c0t4d0
Split Mirrored LV
# lvsplit -s backup /dev/vg02/lvol1
Logical volume "/dev/vg02/lvol1backup" has been successfully created with lv number 5.
Logical volume "/dev/vg02/lvol1" has been successfully split.
Merge split LV
# lvmerge /dev/vg02/lvol1backup /dev/vg02/lvol1
Mirror a BOOT disk
pvcreate -B /dev/rdsk/c0t8d0
vgextend /dev/vg00 /dev/dsk/c0t8d0
mkboot /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol2 /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol3 /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol4 /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol5 /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol6 /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol7 /dev/dsk/c0t8d0
lvextend -m 1 /dev/vg00/lvol8 /dev/dsk/c0t8d0
mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/dsk/c0t5d0
mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/dsk/c0t8d0
lvlnboot -R
lvlnboot -b /dev/vg00/lvol1
lvlnboot -r /dev/vg00/lvol3
lvlnboot -s /dev/vg00/lvol2
lvlnboot -d /dev/vg00/lvol2
lvlnboot -R
Q & A