Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This being said, there are a number of huge advantages to extend your Diskspace via LVM over other means (e.G. you do not have to split up your storage voer over several logical mountpoints) and this has proven to be reliable, scalable and fast.

...

Make Disk visible to the OVA


  • Prior to proceeding, you must identify the current LVM configuration and number of existing primary partitions.
    • If you already have 4 primary partitions (sda1, sda2, sda3, sda4), you will need to add the additional space as a new disk (sdb X).
    • If you don't have 4 primary partitions, you may add a new partition to the existing.


  • SSH into the CentOS OVA and sudo to root (unless you are already root)

    Code Block
    languagebash
    themeEmacs
    sudo su -i 
    

List the block device to see the newly assigned vSphere hard disk.

...

  • Format the disk partition. Get the device name from the previous lsblk output

    Code Block
    languagebash
    themeEmacs
    fdisk /dev/sdb
    n (new partition)
    p (primary)
    (Press ENTER) (Use default partition number)
    (Press ENTER) (Use default first sector)
    (Press ENTER) (Use default last sector)
    
    t (change the partition type)
    8e (Linux LVM)
    
    w (write)
    

    in order to see this partition, read the partition table with "partprobe" (or reboot which is less elegant but just as effective)


  • If an GPT ERROR appears at the end of the fdisk dialogue or after using partprobe: "Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?", do the following command wirth parted:

Image Added

Create the Physical Volume for LVM

...

first check for the group with "vgs" then "vgextend centos" then check again:


now extend the

...

Logical Volume (lv)

first check for the Volume with "vgslvs" then "lvextend" then check again:

...

now in order to actually use the additional space we need to resize the filesystem.
first check the existing file system

then actually resize  the file system - for newer systems it's recommended to use "xfs_growfs /dev/mapper/centos-root".
Image Added

Otherwise, use:


and check again:

Voila!


In essence

  1. Increase Diskspace (physically or on the Hypervisor Layer)
  2. Reboot or rescan for disks
  3. create a new Partition that is compatible to LVM
  4. re-read Partition table either via reboot or command "partprobe"
  5. Initialise a new PV with pvcreate
  6. Increase  the VG with vgextend
  7. Increase  the LV with lvextend
  8. Increase the Filesystem with resize2fs

In case of an extension of an existing partition:

Following above example, if sda would have received an additional 200GB instead of integrating a different (sdb) partition.

  1. Increase Diskspace (physically or on the Hypervisor Layer)
  2. Reboot or rescan for disks
  3. Use lsblk to identify which partition got increased
  4. identify the free space in the partition
    1. parted /dev/sda print free
  5. Increase the last partition, if it fits the filesystem. Use:
    1. parted /dev/sda
    2. resizepart
    3. insert which partition should be resized/increased, in the above case, it would be "3" for sda3.
    4. insert new volume End, as seen via step 4a, where the End of the Free space, should be the new End for partition 3.
  6. pvresize /dev/sda3 or resizefs /dev/sda3
  7. Increase  the LV as seen above
  8. resize filesystem