HP-UX Step to setting up a disk under LVM control and useful command

** Myself
Step to setting up a disk under LVM control
1. build PV
#pvcreate /dev/rdsk/c0t5d0
-B make physical volume bootable
-f force overwrite of file system on disk
2. build VG
#cd /dev
#mkdir vg01
#cd vg01
#mknod group c 64 0x010000
#vgcreate /dev/vg01 /dev/dsk/c0t5d0
-s PE_Size size for PE and therefore LE
-e EXENT_Num maximum number of physical extents per volume
-p DISK_Num maximum number of physical disk per volume group
3. build LV
( ถ้ามีหลาย disk array group (เช่น storage XP หรือ EVA 2 ตัวมองตัวละ 1 array group ต่อ storage ให้ใส่ –D เพื่อ distribute file )
( if multiple disk array group example storage XP and EVA 2 Please be use one array group per storage and option –D for distribute file system)
#lvcreate –L 100 /dev/vg01
-l extents
-L size
-n name(logical volumn)
4. using LV , Create file system
#newfs –F hfs /dev/vg01/rlvol1
#mount –F hfs /dev/vg01/lvol1 /database
Or
#newfs –F vxfs –o largefile /dev/vg01/rlvol1
#mount /dev/vg01/lvol1 /database
Or
Create swap
# lvcreate -L 10240 -n lvswap1 vg00
# /etc/fstab
/dev/vg00/lvswap1 . swap defaults 0 0
#swapon /dev/vg01/lvswap1
(from lvcreate –n swaplv)
Extending a VG
1. #pvcreate /dev/rdsk/c0t3d0
2. #vgextend /dev/vg01 /dev/dsk/c0t3d0
Extending existing LV
#lvextend –L 300 /dev/vg01/lvol1
or
#lvextend –L 300 /dev/vg01/lvol1 /dev/dsk/c0t13d0
extending LV will not make the space available for file system. You must update the file system.
Extending file system
1. #umount /dev/vg01/lvol1
2. #extendfs –F hfs /dev/vg01/rlvol1
Or
#fsadm –F vxfs –b 300m /mount_point
Reduce LV space
#lvreduce –L 200 /dev/vg01/lvol1

Removing LV

#lvremove /dev/vg01/lvol1
Removing PV from VG
#vgreduce /dev/vg01 /dev/dsk/c0t3d0
(อาจใช้ตอนที่เราcreate vg แล้วใส่ minor number ผิดแล้วต้องการ mknod ใหม่แต่ไม่ต้องทำPV ใหม่)
(Use for create vg with wrong number of minor number then new make new node mknod which not create New PV)
Removing VG
#vgremove /dev/vg01
Backing up VG
#vgcfgbackup –f file /dev/vg01
(command นี้จะเก็บ file ใน file system แต่ไม่เก็บ structure ของ VG
การ backup วิธีนี้จะได้ไฟล์ /etc/lvmconf/vg01.conf มา ถ้ามีการเปลี่ยนแปลง disk ใน VG ก็ต้อง restore configuration ก่อน restore file)
command use for collect file system without VG structure
for this method will backup to /etc/lvmconf/vg01.conf in case change disk in Volume VG need to restore configuration file before restore file system
Recovering VG
#vgcfgrestore
Preview & Repair /etc/lvmtab
#vgscan –pv
Repair the failed disk
#vgchange –a y –q y
Mirroring
#lvcreate [–m copies] [-L size in MB] VG
#lvextend [-m copies] LV PV
#lvreduce [-m copies] LV PV
-m = 0, 1, 2, …
0 = ไม่มี Mirror
1 = single mirror
2 = double mirror
Synchronization
#lvsync LV
#vgsync VG
Mirroring boot volumes
1. Create PV with boot area reserved
#pvcreate –B /dev/rdsk/c1t6d0
2. Add the PV to root VG

#vgextend /dev/vg00 /dev/dsk/c1t6d0
3. Use mkboot to place the boot utilities in the boot area and add the AUTO file
#mkboot /dev/rdsk/c1t6d0
#mkboot –a “hpux -lq” /dev/rdsk/c1t6d0
4. Use mkboot to update the AUTO file on the primary boot disk
#mkboot –a “hpux -lq” /dev/rdsk/c0t6d0
5. Mirror the stand, root and swap logical volumes
#lvextend –m 1 /dev/vg00/lvol1 /dev/dsk/c1t6d0
#lvextend –m 1 /dev/vg00/lvol2 /dev/dsk/c1t6d0
#lvextend –m 1 /dev/vg00/lvol3 /dev/dsk/c1t6d0
Activate Disk (PV)
#vgchange –a y vg01

0 comments:

Loading