Skip to main content

Expand an existing Virtual Disk in Linux 7 Virtual Machine VM

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/sdd

Disk /dev/sdd: 161.1 GB, 161061273600 bytes, 314572800 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

 

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/sdd

P: /devices/pci0000:00/0000:00:15.0/0000:03:00.0/host0/target0:0:2/0:0:3:2/block/sdd

N: sdd

S: 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/sdd

E: 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/sdd


Disk /dev/sdd: 214.7 GB, 214748364800 bytes, 419430400 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

 

7) As I am using an LVM we need to increase. the PV size.


root@funebs122:/var/log# pvresize  /dev/sdd

  Physical volume "/dev/sdd" changed

  1 physical volume(s) resized / 0 physical volume(s) not resized

 

root@funebs122:/var/log# pvdisplay /dev/sdd

  --- Physical volume ---

  PV Name               /dev/sdd

  VG Name               vg01_funebs122

  PV Size               200.00 GiB / not usable 3.00 MiB

  Allocatable           yes

  PE Size               4.00 MiB

  Total PE              51199

  Free PE               12800

  Allocated PE          38399

  PV 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_funebs122

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               1

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               200.00 GiB

  PE Size               4.00 MiB

  Total PE              51199

  Alloc PE / Size       38399 / 150.00 GiB

  Free  PE / Size       12800 / 50.00 GiB

  VG 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/lvol0

  Size 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 /u01

Filesystem                     Size  Used Avail Use% Mounted on

/dev/mapper/vg01_funebs122-lvol0  200G  145G   56G  73% /u01




If you like please follow and comment

Comments

Popular posts from this blog

WebLogic migration to OCI using WDT tool

WebLogic migration to OCI using WDT tool Oracle WebLogic Deploy Tool (WDT) is an open-source project designed to simplify and streamline the management of Oracle WebLogic Server domains. With WDT, you can export configuration and application files from one WebLogic Server domain and import them into another, making it a highly effective tool for tasks like migrating on-premises WebLogic configurations to Oracle Cloud. This blog outlines a detailed step-by-step process for using WDT to migrate WebLogic resources and configurations. Supported WLS versions Why Use WDT for Migration? When moving Oracle WebLogic resources from an on-premises environment to Oracle Cloud (or another WebLogic Server), WDT provides an efficient and reliable approach to: Discover and export domain configurations and application binaries. Create reusable models and archives for deployment in a target domain. Key Pre-Requisites Source System: An Oracle WebLogic Server with pre-configured resources such as: Applica...

How to Validate TDE Wallet Password in Oracle Database

How to Validate TDE Wallet Password in Oracle Database Validating the Transparent Data Encryption (TDE) wallet password is crucial, especially when ensuring that the password is correct without using the OPEN or CLOSE commands in the database. This blog post explains a straightforward method to validate the TDE password using the mkstore utility. Steps to Validate TDE Wallet Password Follow these steps to validate the TDE wallet password: Step 1: Copy the Keystore/Wallet File Navigate to your existing TDE wallet directory. Copy only the ewallet.p12 file to a new directory. If a cwallet.sso file exists, do not copy it . The absence of cwallet.sso ensures that the wallet does not use auto-login, forcing the utility to prompt for the password. Step 2: Validate Using mkstore Use the mkstore utility to check the contents of the wallet file. The mkstore utility will prompt you for the TDE wallet password, allowing you to validate its correctness. Command Syntax To display the conten...

How to Create macOS Catalina ISO File

  How to Create macOS Catalina ISO File Please note these steps need to be performed on a Apple Mac System to generate an iso. Steps: 1) Download macOS Catalina From App Store or Apple download 2) Please note once you download it will be in dmg format. 3) Open Terminal in MAC.  from the top-right corner open up Spotlight.  Type in Terminal and hit Enter. 4)  Mount it to your macOS hdiutil attach /tmp/Catalina.dmg -noverify -mountpoint /Volumes/Catalina 5) Create macOS Catalina Installer sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/Catalina --nointeraction 6) Unmount Catalina Disk hdiutil detach /volumes/Install\ macOS\ Catalina 7) Convert the DMG file to an ISO file hdiutil convert /tmp/Catalina.dmg -format UDTO -o ~/Desktop/Catalina.cdr 8) Rename and Move to Desktop mv ~/Desktop/Catalina.cdr ~/Desktop/Catalina.iso Now we can use this iso on any system and install on virtual machines.