Resizing a Linux Disk

From Observer GigaFlow Support | VIAVI Solutions Inc.
Jump to: navigation, search

Reference https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk/ Increase disk size in VMWare

Find SCSI identifier

ls /sys/class/scsi_device/

Output:

32:0:0:0

Rescan SCSI to pick up new disk size (changing id 32:0:0:0 to what you see)

echo 1 > /sys/class/scsi_device/32\:0\:0\:0/device/rescan

Check disk layout

fdisk -l

Output

Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c3b22
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      489471      243712   83  Linux
/dev/sda2          489472    41943039    20726784   8e  Linux LVM

Use fdisk to add partition for new space

fdisk /dev/sda

Use 'n' to create new partition, 'p' for primary, '3' for partition number (check its free), press 'enter' to use all available space. Press 't' to change partition type, '3' to edit the new partition, '8e' as the new type, 'w' to write to disk.

Next run the following to make the parition available.

partprobe -s
partx -a /dev/sda3

Increasing the volume

pvcreate /dev/sda3
vgextend cl /dev/sda3
lvextend /dev/cl/opt /dev/sda3
xfs_growfs /dev/mapper/cl-opt

Checking the disk size(s)

pvdisplay
lvdisplay
fdisk -l
xfs_info /dev/cl/opt
df -h