User Tools

Site Tools


notes:lvm

Various Information

8e is the partition type for Linux LVM if you get “Incorrect metadata area header checksum” check the filters in /etc/lvm.conf

LVM1 Extent Sizes

Only applies to LVM1

  • 4 4mB extents == 16mB
  • There is a kernel limit of 65,536 physical extents per logical volume
  • The -s option to vgcreate selects the extent size
Extent Size Max Logical Volume Size
4mB 256gB
8mB 512gB
16mB 1024gB
32mB 2048gB

Commands

pvcreate /dev/sda1
pvcreate /dev/sda2
vgcreate -s 32 vg /dev/sda1
vgextend vg /dev/sda2
lvcreate -L10G -nhome vg
lvextend -L+5G /dev/vg/home
mke2fs -j /dev/vg/home

Remove a physical volume

  • To move all logical extents off of /dev/md2 to other available drives
  • pvmove -v /dev/md2
  • vgreduce vg /dev/md2

Various commands

lvdisplay - Shows all logical volumes

On-Line Resizing ext3

To resize an ext3 volume online
To extend the /dev/vg/storage volume by 1Gigabyte
lvextend -L+1G /dev/vg/storage
and then resize it
resize2fs /dev/vg/storage

Creating a snapshot

/etc/init.d/dmeventd start
lvcreate -L 5G  -s -n vmsnap /dev/vg/storage
OriginalLogicalVolume[Path] [PhysicalVolumePath...]

Received the error below once when creating a snapshot

Had to start dmeventd
Unable to start dmeventd.
Unable to start dmeventd.
storage-snapStorage: event registration failed: No such process
storage/snapshot0: snapshot segment monitoring function failed.
Logical volume "snapStorage" created

To move logical partitions from one drive to another

Will need the dm_mirror module loaded

Create logical partitions on drive b

  pvcreate /dev/sda{1,2}
  vgextend storage /dev/sda{1,2}

Disable allocation on the old PV

pvchange  -x n /dev/sdb2

Move the extents over

  pvmove -v /dev/sdb2

vgreduce storage /dev/sdb2 vg

Troubleshooting

Power went out, and the mail server failed to start back up, one of the partitions had gotten lost, it showed in the partition table as free space, recreated the partition, rebooted and it worked.

Was also looking into doing

  • pvcreate –uuid uuid –restorefile /etc/lvm/backup/prime-vg prime /dev/sda6

If one of the partitions is down in a volume Group

  • vgdisplay –partial –verbose

To deactivate a VG, such as on an external drive

  • umount any logical volumes
  • deactivate any logical volumes
    • lvchange -a n /dev/server_backups/netware
  • deactivate volume group
    • vgchange -a n server_backups

Unplugged a usb drive

Was having problems after plugging it back in

  • vgchange -a n server_backups
  • vgchange -a y server_backups
  • vgscan
notes/lvm.txt · Last modified: by david