Wednesday, July 20, 2011

Setting up the first LVM partition

Most of the LVM setups I have created have been done by the OS installer. I wanted to add more disk space to a server that did not have any LVM partitions setup. Below are the steps that I took:
  • added the hard disk (it was a virtual hard disk in this case)
  • created a partition and assigned it the lvm partition type id using fdisk
  • created the physical volume
    pvcreate /dev/sdb1
  • created a volume group called system with the earlier created physical volume:
    vgcreate system /dev/sdb1
  • created a logical volume to take up all the free space
    lvcreate -n storage -l 100%FREE system
  • created an ext3 file system on the logical volume
    mkfs.ext3 /dev/system/storage
  • Made an entry in /etc/fstab
    /dev/system/storage /storage ext3 defaults 1 2

1 comment:

  1. To add space to an existing lvm partition:
    pvcreate /dev/sdb

    vgextend VolGroup0 /dev/sdb

    lvextend -l +100%FREE /dev/VolGroup0/LogVol00

    resize2fs /dev/VolGroup0/LogVol00

    ReplyDelete