Tuesday 12 March 2013

HP-UX LVM Cheat Sheet


Logical Volume Manager is a disk management subsystem that allows you to manage physical disks as logical volumes.
The following terms are used when working with LVM:
VolumeA volume is a device used for a filesystem, swap or raw data. Without LVM a volume would be a disk partition or the whole disk
Physical VolumeA physical volume is the disk itself. An entire disk must be initialised if it is to be used by LVM.
Volume GroupA volume Group is a collection of volumes that are managaed by LVM. Each disk must only belong to one group however a volume group many contain many disks.
Logical VolumeThis is the space that is defined within a volume group. The volume group is divided into smaller logical volumes which in turn become the filesystems. A volume group may contain one or many logical volumes. Logical volumes can be grown or shrunk. A logical volume is a set of logical extents
Physical ExtentA physical extent is a set of contiguous disk blocks on a physical volume. The default size of an extent is 4MB but this can be adjusted when initialising the disk. Normally a physical extent will have a one to one relationship with logical extents.
Logical ExtentA logical volume is a set of logical extents. Logical extents and pyhsical extents are the same size in a volume. A logical extent is a direct mapping to a pyhsical extent.
/etc/lvmtabThis file has in it the device file associated with each disk in a volume group. /sbin/lvmrc starts each volume group by reading the contents of this file at boot time.This file can be rebuilt using the command vgscan. The file is a binary file and can be read using Strings.
PV LinksPhysical Volume Links (PV Links) provide dual SCSI or FL links to the same disk. This basically means multipathing to a disk.
Boot Disk Components
LIF Directory*Contains a list of other disks in the volume group and whether or not they are bootable
PVRAContains imports PV-related information such as:
  • PV ID number
  • VG ID number
  • PE Size
  • PV size
  • bad block directory
This is created when pcreate is run
BDRA*Specifies where the root filesystem is found
LIF*Contains ISL, HPUX, AUTO, LABEL that are LIF files. These are put there when the mkboot and lvlnboot commands are run.
VGRAContain volume group description area (VGDA) and volume group status area (VGSA)
Physical ExtentsPhysical extents for the file system, swap, etc
Bad Block PoolProvides alternate locations for bad blocks
* Boot disk Only
Disk Mirroring
Disk Mirroring is preformed by the sftware package MirrorDisk/UK, the product requires a license from HP. Logical volumes can be mirror one or more times, in other words the logical extent is mapped to one or more physical extents. There is a mirror policy called strict which can be set to one of the following:
nwhen set means that mirrored copies of a logical extent can share the same physical volume. This means that your original and mirrored data may be on the same physical disk
ywhen set means that mirrored copies of a logical extent cannot share the same physical volume. This means that your original and mirrored data will not share the physical disk
gMirrored data will not be on the same physical volume group (PVG) as the original data. This policay is called a PVG-strict allocation policy.
Physical Volume Commands
pvchangeAllows you to change a physical volume is some way. for an example you can allow or disallow adding extents to this physical volume.
pvcreateIs used to create a physical volume that will be part of a volume group.
pvdisplayshows information about a physical volumes you specify
pvmoveyou can move extents from one physical volume to other physical volumes.
mknodthis command is used to create th major/minors numbers of a volume group
Volume Group Commands
vgcfgbackupused to save the configuration of a volume group.
vgcfgrestoreused to restore the configuration of a volume group.
vgchangemakes a volume active or in-active
vgcreateyou can create a volume group and specify all of its parameters.
vgdisplaydisplay information related to a volume group
vgexportremove a volume group from the system, but does not modify the logical volume information on the physical volumes. You can then import the volume group onto another system i.e in a cluster environment.
vgextendPhysical volumes can be added to a volume group by specifying the physical volume to be added to the volume group.
vgimportused to import a volume group from another system
vgreducereduce the volume group by removing th specified physical volume.
vgremoveremove the volume group completely from the system
vgscanrebuild the /etc/lvmtab file
vgsyncwhen a volume group become stale you can resync that volume which resync's all the physical extents in each mirrored logical volume in the volume group.
Logical Volume Commands
lvcreatecreate a new logical volume.
lvchangechange the logical volume in some way
lvdisplaydisplay information on a specified logical volume
lvextendincrease the number of physical extents to a logical volume. You will need to use the extendfs after extending a logical volume.
extendfsexpands the filesystem within the logical volume. You would use fsadm if you have OnlineJFS installed.
mkbootplaces boot utilities in boot area
lvlnbootuse this to sepup a logical volume to be a root, boot, primary swap or dump volume. This can be undo with lvrmboot.
lvsplit or lvmergeare used to split or merge a logical volume that is mirrored
lvmmigrateprepares a root filesystem in a disk partition for migration to a logical volume. You would use this if you had a partition to convert to a logical volume
lvreducedecrease the number of physical extents allocated to a logical volume
lvremoveremove a logical volume from the volume group
lvrmbootif you don't want a logical volume to be root, boot, primary swap or a dump device.
lvsyncwhen a logical volume becomes stale you can resync the logical volume
newfsplace a new flesystem on a logical volume
JFS and OnlineJFS Commands
fsckcheck/repair the integrity of a filesystem
fsadmpeforms a number of tasks when using a OnlineJFS sch as dfragmentation, resizing, online backup, etc
Commonly used LVM procedures
Create a new volume group, logical volume and filesystempvcreate /dev/rdsk/c0t1d0
mkdir /dev/vg01
mknod /dev/vg01/group c 64 0x010000
vgcreate /dev/vg01 /dev/dsk/c0t1d0
lvcreate -L 2000 /dev/vg01
newfs -F vxfs -o largefiles /dev/vg01/rlvol1
mkdir /ora_data01
mount /dev/vg01/lvol1 /ora_data01 
Create a stripped filesystemlvcreate -i 3 -I 32 -L 24 -n lvol1 /dev/vg01
-i number of stripes
-I stripe size of 32KB
-L size of the volume
Mirror root and swap diskpvcreate -B /dev/rdsk/c0t6d0
vgextend /dev/vg00 /dev/dsk/c0t6d0
mkboot /dev/rdsk/c0t6d0
mkboot -a "hpux -lq" /dev/rdsk/c0t6d0
mkboot -a "hpux -lq" /dev/rdsk/<primary disk>
lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c0t6d0
lvextend -m 1 /dev/vg00/lvol2 /dev/dsk/c0t6d0
lvextend -m 1 /dev/vg00/lvol3 /dev/dsk/c0t6d0
lvextend ........all other volumes on primary disk
setboot -a 8/8.6.0
replace a non-mirrored disklvreduce -m 0 -A n /dev/vg01/lvol1 /dev/dsk/cxtxdx
vgreduce vg01 /de/dsk/cxtxdx
or
pvchange -a N /dev/dsk/cxtxdx (if you have online replacement disks)
vgcfgrestore -n /dev/vgXX /dev/rdsk/cxtxdx
vgchange -a y /dev/vgXX
newfs -F <fstype> /dev/vgXX/rlvolx
mount <mountpoint>
Notes:
Make sure you have /etc/lvmconf/vgXX.conf
vgcfgbackup is run automatically
Defective disk was not mirrored before it failed
replace a mirrored diskvgcfgrestore -n /dev/vgXX /dev/rdsk/cxtxdx
vgchange -a y /dev/vgXX
vgsync /dev/vgXX
Notes:
Defective disk was mirrored before it failed
replace mirrored boot diskvgcfgrestore -n /dev/vg00 /dev/rdsk/cxtxdx
vgchange -a y /dev/vg00
vgsync /dev/vg00
mkboot /dev/rdsk/cxtxdx
mkboot -a "hpux -lq" /dev/rdsk/cxtxdx
shutdown -r -y 0
Notes:
Confirm that you have /etc/lvmconf/vg00.conf
Defective disk was mirrored before it failed
export and import a volume groupSystem One:
vgchange -a n /dev/vg01
vgexport -v -m /tmp/mapfile -s /dev/vg01
rcp /tmp/mapfile <system 2>:/tmp/mapfile
System two:
mkdir /dev/vg01
mknod /dev/vg01/group c 64 0xyy0000
vgimport -v -m /tmp/mapfile -s /dev/vg01
vgchange -a y /dev/vg01
mkdir /ora_data01
mount /dev/vg01/ora_data01 /ora_data01
extend VxFS file ssytem using onlineJFSlvextend -L 800 /dev/vg01/lvol1
fsadm -F vxfs -b 800M /ora_data01
change a logical volume to support largefilesfsadm -F vxfs -o largefiles /dev/vg01/rlvol1
display the boot arealifls -Clv /dev/dsk/c0t6d0
display boot informationlvlnboot -v /dev/vg00
display all disks in the systemioscan -funC disk
make a dump devicelvchange -C y /dev/vg00/dump (makes it contiguous)
lvlnboot -d /dev/vg00/dump
display dump deviceslvlnboot -v


Courtesy by datadisk.co.uk

No comments:

Post a Comment