User Tools

Site Tools


linuxlvm
Linux LVM
How-to: Add new LV

Example is a full LV for a virtual guest

pvcreate /dev/emcpowera1
vgcreate -s 32M vg{guest_name} /dev/emcpowera1
lvcreate –l 100%VG -n lv{guest_name} vg{guest_name}

If the LV will be seen by multiple hosts (i.e. clustering or Xen/KVM). Do the following on the other nodes:

sfdisk -R /dev/emcpowerN

Where N is each PV added on the first node.

vgscan -v

This only needs to be done once after all of the sfdisk commands.

How-to: Find striping information about a Logical volume
lvdisplay -m /dev/vg00/lv01 | grep Type
How-to: Increase the filesystem/lvol size
Increase the logical volume size first: lvextend -L 20G /dev/vg00/lv01
Resize filesystem: resize2fs /dev/vg00/lv01 20G
If the above fails:
Make sure no one is using filesystem: fuser -vum /opt/appfiles
Unmount filesystem: umount /dev/vg00/lv01
Check filesystem: (with a force) fsck -f /dev/vg00/lv01
Resize filesystem: resize2fs /dev/vg00/lv01 20G
Remount filesystem: mount -a
How-to: Shrink the filesystem and logical volume
Check that filesystem is able to shrink: df -h {mountpoint}
Value for 'Used' must not be more than target to shrink filesystem to
Make sure no one is using filesystem: fuser -vum /opt/appfiles
Unmount filesystem: umount /dev/vg00/lv01
Check filesystem: (with a force) fsck -f /dev/vg00/lv01
Resize filesystem: resize2fs /dev/vg00/lv01 20G
Test LV resize: lvresize -L 5G -t /dev/vg00/lv01
If above has no errors, commit LV resize: lvresize -L 5G /dev/vg00/lv01
Remount filesystem: mount -a
LVM and Power Path

Edit /etc/lvm/lvm.conf filter for EMC SAN RHEL5:

filter = [ "a/sda[1-9$/", "r/sd.*/", "r/disk.*/", "r/ram.*/", "a/.*/" ]

RHEL4:

filter = [ "a/sda[1-9$/" "a/emcpower.*/" "r/.*/" "r|/dev/cdrom|" ]
EMC Clarion Disk offset

The following must be done to optimize LUN configuration for the EMC Clarion.

# fdisk /dev/emcpowera
n                # new partition
p                # primary partition
1                # partition number 1
<enter>                # accept default start=1
<enter>                # accept default end=<last block>
t                # change disk type
8e                # value for Linux LVM
x        # expert mode
b        # adjust starting block number
1        # choose partition 1
128        #    set it to 128, our stripe element size
w        # write the new partition
HA-LVM - Enable
  • Add the following to /etc/lvm/lvm.conf where vgroot is your root VG and hostname is the node name in /etc/cluster/cluster.conf
volume_list = [ "vgroot", "@hostname" 
  • Update initrd and reboot
mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)
HA-LVM - View

To view the LVM tags, where hostname matches one of the nodes in /etc/cluster/cluster.conf

lvs @hostname

Or to view all tags

vgs -o vg_name,vg_tags
HA-LVM - Troubleshooting
  • HA-LVM expects initrd to be newer than lvm.conf (see To Enable) so it will not tag a VG if that is not the case.
  • Well there are many circumstances when lvm.conf may have a newer date than initrd (i.e. you made some other edit to lvm.conf).
  • To “fix” this issue, simply touch initrd.
Viewing initrd

To see whether or not volume_list is enabled in initrd:

mkdir /root/tmp;cd /root/tmp
cp /boot/initrd-$(uname -r).img ./initrd.gz
gunzip initrd.gz
cpio -id < initrd
grep volume_list etc/lvm/lvm.conf
cd
rm -rf /root/tmp
Manually tagging a LV
vgchange --addtag {tag_name} {vg_name}
vgchange -v -ay {vg_name}
linuxlvm.txt · Last modified: 2017/11/10 01:09 by mark