Extend partition from VMWare in Oracle Linux – part 1


The client uses VMWare as virtualization platform for the Oracle Database VMs (yes, he is aware of the License implications).

The VM is running out of space in two partitions. The VMWare Admin extended the disks on their platform. Now I need to make this extension visible in Oracle Linux. This things we do once every 10 years, when versions, filesystems and tools already changed.

For this post in 2025, I’m using Oracle Linux 9, xfs filesystems. All operation are online, with databases running.

I divide this post in two parts:

Extend single partition of block device

oracle@vmware-vm01 MIG01C $ cat /etc/system-release 
Oracle Linux Server release 9.6

The partition tree is below, and I need to increase the /u02 from 100G to 300G. The disk is /dev/sdb

[root@vmware-vm02 ~]# lsblk 
NAME                             MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                                8:0    0   774G  0 disk 
├─sda1                             8:1    0   250M  0 part /boot/efi
├─sda2                             8:2    0     1G  0 part /boot
└─sda3                             8:3    0    77G  0 part 
  ├─ol_vmware-vm02-root          252:0    0    10G  0 lvm  /
  ├─ol_vmware-vm02-swap          252:1    0     4G  0 lvm  [SWAP]
  ├─ol_vmware-vm02-var_log_audit 252:2    0     1G  0 lvm  /var/log/audit
  ├─ol_vmware-vm02-u01           252:3    0    50G  0 lvm  /u01
  ├─ol_vmware-vm02-home          252:4    0     5G  0 lvm  /home
  ├─ol_vmware-vm02-var_log       252:5    0     2G  0 lvm  /var/log
  └─ol_vmware-vm02-var           252:6    0     5G  0 lvm  /var
sdb                                8:16   0   100G  0 disk 
└─sdb1                             8:17   0   100G  0 part 
  └─vg_u02-lv_u02                252:7    0   100G  0 lvm  /u02
sr0                               11:0    1 356.9M  0 rom  

The key point in VMWare provided disks, is to rescan the disk, so that it sees it was increased.

# Before scan it has 100G. Output is trimmed.
[root@vmware-vm02 ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors
...

# Scan disk
[root@vmware-vm02 ~]# echo 1>/sys/class/block/sdb/device/rescan

# Now it shows 300G
[root@vmware-vm02 ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 300 GiB, 322122547200 bytes, 629145600 sectors
Disk model: Virtual disk    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb8747b5e

Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1        2048 209715199 209713152  100G 83 Linux

# Also lsblk shows 300G for the disk
[root@vmware-vm02 ~]# lsblk /dev/sdb
NAME                             MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sdb                                8:16   0   300G  0 disk 
└─sdb1                             8:17   0   100G  0 part 
  └─vg_u02-lv_u02                252:7    0   100G  0 lvm  /u02

As there is only partition /u02 in this disk, I want to extend it to use the full disk. I used parted tool and the resizepart command with partition number and saying to use 100% of the space./

[root@vmware-vm02 ~]# parted /dev/sdb
GNU Parted 3.5
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 322GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  107GB  107GB  primary

(parted) help resizepart
  resizepart NUMBER END                    resize partition NUMBER

NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards.
        END is disk location, such as 4GB or 10%.  Negative value counts from the end of the disk.  For example, -1s specifies exactly the last sector.

(parted) resizepart 1 100%                                                

(parted) quit

Now I make it visible to the physical volume /dev/sdb1 with the pvresize. In lsblk now two lines are updated.

[root@vmware-vm02 ~]# pvresize /dev/sdb1
  Physical volume "/dev/sdb1" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

[root@vmware-vm02 ~]# pvdisplay /dev/sdb1
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg_u02
  PV Size               <300.00 GiB / not usable 2.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              76799
  Free PE               51200
  Allocated PE          25599
  PV UUID               2NMbpD-OYg0-ahYe-lRn1-Boig-eSu4-zTcoaU                      

[root@vmware-vm02 ~]# lsblk /dev/sdb
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sdb                 8:16   0  300G  0 disk 
└─sdb1              8:17   0  300G  0 part 
  └─vg_u02-lv_u02 252:7    0  100G  0 lvm  /u02

Then I need to extend the logical volume associated with /u02 using the lvextend. The filesystem is still 100G. I use df -Th to check what is the filesystem type (in the past was usually ext4, now they are mostly xfs):

[root@vmware-vm02 ~]# lvextend -l 100%VG /dev/mapper/vg_u02-lv_u02
  Size of logical volume vg_u02/lv_u02 changed from <100.00 GiB (25599 extents) to <300.00 GiB (76799 extents).
  Logical volume vg_u02/lv_u02 successfully resized.

[root@vmware-vm02 ~]# df -Th /u02
Filesystem                Type  Size  Used Avail Use% Mounted on
/dev/mapper/vg_u02-lv_u02 xfs   100G   92G  8.3G  92% /u02  

Finally I extend the filesytem using xfs_growfs:

[root@vmware-vm02 ~]# xfs_growfs /dev/mapper/vg_u02-lv_u02
meta-data=/dev/mapper/vg_u02-lv_u02 isize=512    agcount=4, agsize=6553344 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=0
         =                       exchange=0  
data     =                       bsize=4096   blocks=26213376, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1, parent=0
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 26213376 to 78642176

The /u02 partition is now 300G also for the OS:

[root@vmware-vm02 ~]# df -Th /u02
Filesystem                Type  Size  Used Avail Use% Mounted on
/dev/mapper/vg_u02-lv_u02 xfs   300G   94G  207G  32% /u02

Leave a comment

Your email address will not be published. Required fields are marked *