Expand an existing Disk in Linux 7 Virtual Machine VM
In this post I am going to share how to extend an existing disk and increase its size. This whole process is online and no downtime involved.
Steps:
1) Identify the disk which needs to be extended.
root@funebs122:~# df/dev/mapper/vg01_funebs122-lvol0 157205508 151190476 6015032 97% /u01
lsblk
root@funebs122:/var/log# fdisk -l /dev/sddDisk /dev/sdd: 161.1 GB, 161061273600 bytes, 314572800 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
2) Identify the SCSI ID using below command for the disk. I have highlighted the ID.
root@funebs122:/var/log# udevadm info --query=all --name=/dev/sddP: /devices/pci0000:00/0000:00:15.0/0000:03:00.0/host0/ target0:0:2/0:0:3:2/block/sdd N: sddS: disk/by-id/lvm-pv-uuid-gasyg52-bIv2-t1Yr-gs64-ntvY- 6yz8-jhas67 S: disk/by-path/pci-0000:03:00.0-scsi-0:0:3:2 E: DEVLINKS=/dev/disk/by-id/lvm-pv-uuid-gasyg52-bIv2-t1Yr- gs64-ntvY-6yz8-jhas67 /dev/disk/by-path/pci-0000:03: 00.0-scsi-0:0:3:2 E: DEVNAME=/dev/sddE: DEVPATH=/devices/pci0000:00/0000:00:15.0/0000:03:00.0/ host0/target0:0:2/0:0:3:2/ block/sdd
3) Verify the SCSI devices
root@funebs122:/var/log# ls /sys/class/scsi_device/0:0:0:0 0:0:1:0 0:0:3:2 3:0:0:0
4) Extend the disk from the VM disk and resize. This can be done from your system Admin if you don't have access.
5) Rescan the disk after the increase at VM level.
root@funebs122:/var/log# echo 1 > /sys/class/scsi_device/0\:0\:2\:0/device/rescan
6) Check the new size of the disk
root@funebs122:/var/log# fdisk -l /dev/sddDisk /dev/sdd: 214.7 GB, 214748364800 bytes, 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
7) As I am using an LVM we need to increase. the PV size.
root@funebs122:/var/log# pvresize /dev/sddPhysical volume "/dev/sdd" changed1 physical volume(s) resized / 0 physical volume(s) not resized
root@funebs122:/var/log# pvdisplay /dev/sdd--- Physical volume ---PV Name /dev/sddVG Name vg01_funebs122PV Size 200.00 GiB / not usable 3.00 MiBAllocatable yesPE Size 4.00 MiBTotal PE 51199Free PE 12800Allocated PE 38399PV UUID PZzCCd-bIv2-t1Yr-0Ch7-ntvY-6yz8-7dSYoB
8) Now Validate the VG free allocated space. It should show the amount of free space what we have increased in disk.
root@funebs122:/var/log# vgdisplay vg01_funebs122--- Volume group ---VG Name vg01_funebs122System IDFormat lvm2Metadata Areas 1Metadata Sequence No 3VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 1Act PV 1VG Size 200.00 GiBPE Size 4.00 MiBTotal PE 51199Alloc PE / Size 38399 / 150.00 GiBFree PE / Size 12800 / 50.00 GiBVG UUID SBbrwc-Ym4P-1I6d-NYrr-ygow-hRTU-MkMPLV
9) Check the file system type of the Mount
root@funebs122:/var/log# grep u01 /etc/fstab/dev/vg01_funebs122/lvol0 /u01 xfs defaults 1 2
10) Extend the LVM by 50 GB
root@funebs122:/var/log# lvextend -L +50g /dev/vg01_funebs122/lvol0Size of logical volume vg01_funebs122/lvol0 changed from 150.00 GiB (38399 extents) to 200.00 GiB (51199 extents).Logical volume vg01_funebs122/lvol0 successfully resized.
11) Expand the filesystem
root@funebs122:/var/log# xfs_growfs /dev/vg01_funebs122/lvol0
meta-data=/dev/mapper/vg01_ funebs122-lvol0 isize=256 agcount=4, agsize=9830144 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=39320576, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=19199, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 39320576 to 52427776
12) Validate the Mount point size
root@funebs122:/var/log# df -h /u01Filesystem Size Used Avail Use% Mounted on/dev/mapper/vg01_funebs122-lvol0 200G 145G 56G 73% /u01
Post a Comment
Post a Comment