DbAppWeb.com

Menu
  • Home
  • Linux
  • HP-UX
  • macOS
  • Windows
  • Web Servers
  • App Servers
  • Storage

How to extend the size of the physical volume (PV) in Linux

September 8, 2023 DbAppWeb Admin

Problem

How to extend the size of the physical volume (PV) in Linux if disk space is available? It is required to avoid the creation of a new physical volume for increasing the size of the volume group.

[root@dbappweb ~]# df -HT
Filesystem             Type      Size  Used Avail Use% Mounted on
devtmpfs               devtmpfs  271G     0  271G   0% /dev
tmpfs                  tmpfs     271G     0  271G   0% /dev/shm
tmpfs                  tmpfs     271G   30M  271G   1% /run
tmpfs                  tmpfs     271G     0  271G   0% /sys/fs/cgroup
/dev/mapper/os_vg-root xfs        33G   95M   33G   1% /
/dev/mapper/os_vg-usr  xfs        24G  5.6G   19G  24% /usr
/dev/sda2              xfs       1.1G  238M  828M  23% /boot
/dev/sda1              vfat      1.1G   11M  1.1G   1% /boot/efi
/dev/mapper/os_vg-u02  xfs       108G   35M  108G   1% /u02
/dev/mapper/os_vg-home xfs        43G   40M   43G   1% /home
/dev/mapper/os_vg-var  xfs        24G  1.7G   22G   8% /var
/dev/mapper/os_vg-tmp  xfs        17G   35M   17G   1% /tmp
tmpfs                  tmpfs      55G     0   55G   0% /run/user/54322
tmpfs                  tmpfs      55G   33k   55G   1% /run/user/1000
tmpfs                  tmpfs      55G     0   55G   0% /run/user/0

 

Physical volume (PV) details show that the current size is 249GB.

[root@dbappweb ~]# pvs
  PV         VG    Fmt  Attr PSize   PFree
  /dev/sda3  os_vg lvm2 a--  249.00g 4.00m

 

Volume group (VG) details show that there is only 4MB of space is free which can be used to extend the size of logical volumes.

[root@dbappweb ~]# vgs
  VG    #PV #LV #SN Attr   VSize   VFree
  os_vg   1   7   0 wz--n- 249.00g 4.00m

 

Logical volume (LV) details show the list of all logical volumes with their VG and size.

[root@dbappweb ~]# lvs
  LV   VG    Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home os_vg -wi-ao----  40.00g
  root os_vg -wi-ao----  30.00g
  swap os_vg -wi-ao----  20.00g
  tmp  os_vg -wi-ao----  15.00g
  u02  os_vg -wi-ao---- 100.00g
  usr  os_vg -wi-ao----  22.00g
  var  os_vg -wi-ao----  22.00g

It can be seen from the above details that the physical volume and volume group only have 4MB of free space which means it is not possible to increase the size of any logical volume to more than 4MB.  To increase the size of the logical volumes, the size of the volume group needs to be increased and it can be achieved by either creating a new physical volume or by increasing the size of the existing physical volume.

 

Here, disk details show that the free space is available which can be used to create a new physical volume or extend the size of the existing physical volume.

[root@dbappweb ~]# fdisk -l /dev/sda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 959.1 GB, 959119884288 bytes, 1873281024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk label type: gpt
Disk identifier: 4110CA4F-81EB-44BC-922F-9ECC06F6E0E4


#         Start          End    Size  Type            Name
 1         2048      2099199      1G  EFI System      EFI System Partition
 2      2099200      4196351      1G  Microsoft basic
 3      4196352    526403584    249G  Linux LVM

Extending the size of the existing physical volume is the better way to increase the size of the volume group and logical volumes.

Solution

The size of the physical volume can be extended by using the command growpart, it will extend the size of the existing physical volume by all the available disk space.

[root@dbappweb ~]# growpart
growpart disk partition
   rewrite partition table so that partition takes up all the space it can
   options:
    -h | --help       print Usage and exit
         --fudge F    if part could be resized, but change would be
                      less than 'F' bytes, do not resize (default: 1048576)
    -N | --dry-run    only report what would be done, show new 'sfdisk -d'
    -v | --verbose    increase verbosity / debug
    -u | --update  R  update the the kernel partition table info after growing
                      this requires kernel support and 'partx --update'
                      R is one of:
                       - 'auto'  : [default] update partition if possible
                       - 'force' : try despite sanity checks (fail on failure)
                       - 'off'   : do not attempt
                       - 'on'    : fail if sanity checks indicate no support

   Example:
    - growpart /dev/sda 1
      Resize partition 1 on /dev/sda
must supply disk and partition-number

 

As above fdisk -l /dev/sda shows that disk /dev/sda has 3 partitions and partition number 3 can be extended from 249GB to the maximum available disk space by using the command growpart /dev/sda 3

[root@dbappweb ~]# growpart /dev/sda 3
CHANGED: partition=3 start=4196352 old: size=522207232 end=526403584 new: size=1869084638 end=1873280990

 

The partition size has been extended from 249GB to 891.3GB which can be verified by using the command fdisk

[root@dbappweb ~]# fdisk -l /dev/sda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 959.1 GB, 959119884288 bytes, 1873281024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk label type: gpt
Disk identifier: 4110CA4F-81EB-44BC-922F-9ECC06F6E0E4


#         Start          End    Size  Type            Name
 1         2048      2099199      1G  EFI System      EFI System Partition
 2      2099200      4196351      1G  Microsoft basic
 3      4196352   1873280989  891.3G  Linux LVM

 

Now, check the size of the physical volume (PV), it is still showing the old size 249G. It required to be resized.

[root@dbappweb ~]# pvs
  PV         VG    Fmt  Attr PSize   PFree
  /dev/sda3  os_vg lvm2 a--  249.00g 4.00m

 

The physical volume (PV) and volume group (VG) size will be increased after running the resize command for physical volume.

[root@dbappweb ~]# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
[root@dbappweb ~]# pvs
  PV         VG    Fmt  Attr PSize    PFree
  /dev/sda3  os_vg lvm2 a--  <891.25g <642.25g

Finally, the size of the physical volume (PV) and volume group (VG) both have been extended and details show the free disk space which can be used to increase the size of the logical volumes.

 

Related Posts

  • Create PV, VG, LV and format it in Linux when Multipath Enabled
  • How to Resize an Online Multipath Device in Linux
  • How to extend the size of Logical Volume (LV) in HP-UX
  • How to remove File System, LV and VG in HP-UX and Linux

Date: September 08, 2023

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
Prev Article
Tags:Linux RedHat Linux Sys Admin

Leave a Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Popular
  • Recent

Categories

  • Android (2)
  • Blogger (16)
  • Domain and Hosting (1)
  • Hardware Issues (7)
  • HP-UX (55)
  • HPE Data Protector (9)
  • IBM Lotus Notes (2)
  • IBM WebSphere Application Server (16)
  • Internet Tips & Tricks (15)
  • iOS (8)
  • JBoss/WildFly Application Server (2)
  • Linux (76)
  • macOS (15)
  • Microsoft Windows (31)
  • News and Updates (11)
  • Oracle Database (5)
  • SSL/TLS (1)
  • Storage Servers (23)
  • Tools/Softwares (1)
  • VMware ESXi (17)
  • Web Servers (14)
  • WordPress (5)

Archives

DbAppWeb.com

Solution of Database, Application and Web Server Problems

About DbAppWeb.com

One Stop Solution for Database Server, Application Server and Web Server Problems.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

DbAppWeb on Social Media

Copyright © 2025 DbAppWeb.com
Terms and Conditions   Theme by MyThemeShop.com