Search This Blog

Extend a Linux LVM Volume on a VM - Part 3

This is the part 3 of extending a Linux LVM volume. see part 1 and part 2.

This part 3 is similar to part 2 when the partition as a PV. Instead of creating a new partition on the free disk space (like in part 2), delete the last partition on the disk and recreate it. This is useful when all the primary partitions (1 - 4) are already in use.

Extend a LVM when the partition as a PV

  1. Increase the VM’s hard disk size in vSphere Client

    • If there is a VM snapshot on the disk, its size cannot be changed. Remove all the snapshots first
    • After increasing the disk size, take a snapshot as the backup
  2. Rescan the SCSI bus to verify the OS see the new space on the disk
    • ls /sys/class/scsi_host/
    • echo “- - -“ > /sys/class/scsci_host/<host_name>/scan
    • tail -f /var/log/message
    • or
    • ls /sys/class/scsi_disk/
    • each ‘1’ > /sys/class/scsi_disk/<0\:0\:0\:0>/device/rescan
    • tail -f /var/log/message
    • fdisk -l
  3. Prepare the disk partition
    • fdisk -l
    • fdisk </dev/sdb>
    • p - print the partition table, note the last partition number in use
    • d - delete parition
    • p - primary partition
    • <X> - partition number, enter the last partition number from the previous p - print the partition table command 
    • n - add a new partition
    • p - primary partition
    • <X> - partition number, enter the partition number was deleted in the previous step 
    • default - the begining of the cylinder in the original partition
    • default - the last of the free cylinder
    • t - change a partition’s system id
    • <X> - partition number, enter the partition number was recreated in the previous step
    • 8e - Linux LVM
    • w - write table to disk and exit
    • fdisk -l to verify the new partition size
  4. Update partition table changes to kernel
    • reboot
    • or partprobe </dev/sdb>
    • Update (04/18/2016): In RHEL 6, partprobe will only trigger the OS to update the partitions on a disk that none of its partitions are in use (e.g. mounted). If any partition on a disk is in use, partprobe will not trigger the OS to update partition in the system because it it considered unsafe in some situations. So a reboot is required. see “How to use a new partition in RHEL6 without reboot?”
  5. Resize the PV
    • pvresize </dev/sdb3>
  6. Verifty the VG automatically sees the new space 
    • vgs
  7. Extend the LV
    • lvextend -l +100%FREE</dev/volume_group_name>/<logical_volume_name>
    • or lvextend -L+<size> /dev/<volume_group_name>/<logical_volume_name>
    • lvs
  8. Resize the file system
    • resize2fs /dev/<volume_group_name>/<logical_volume_name>
    • df -h
  9. Remove the VM snapshot once confirming the data intact

No comments:

Post a Comment

Use WinSCP to Transfer Files in vCSA 6.7

This is a quick update on my previous post “ Use WinSCP to Transfer Files in vCSA 6.5 ”. When I try the same SFTP server setting in vCSA 6.7...