Friday, June 3, 2022

Using extended disk in a virtual machine

   

These are the steps to use the extended SCSI disk in a VM. The disk shows up in VM as device /dev/sdb mounted as /opt/app. It was extended from 1 TB to 2 TB.

 # Unmount the logical volume

  umount /opt/app

  # Create a new additional partition and change the system id to 8e. Use fdisk as shown below and chose to create a new primary partition. There is only one partition /dev/sdb1 to start with. New partition will be /dev/sdb2.

  fdisk /dev/sdb

  # Partprobe to reaload the prtition table into kernel

  partprobe

  # Create physical volume

  pvcreate /dev/sdb2

  # Find name of volume group to extend. In our case the name is localvg

  vgdisplay

  # Extend the volume group

  vgextend localvg /dev/sdb2

  # Find name of logical volume

  lvdisplay

  # Extend and resize the logical volume

  lvextend -r -l +100%FREE /dev/localvg/bbed92058c4903275172716dd4a26a15

  # Mount the logical volume

  mount /dev/localvg/bbed92058c4903275172716dd4a26a15 /opt/app