Ubuntu 24.04
Sponsored Link

Manage Physical Volumes2024/05/29

 

This is the basic operation of managing Physical Volumes.
It needs to create LVM type partition first.

[1] Create Physical Volume.
root@dlp:~#
pvcreate /dev/sdb1

  Physical volume "/dev/sdb1" successfully created
# to create with volume size explicitly, set like follows

root@dlp:~#
pvcreate --setphysicalvolumesize 50G /dev/sdb1

  Physical volume "/dev/sdb1" successfully created
[2] Display Physical Volumes.
root@dlp:~#
pvdisplay /dev/sdb1

  "/dev/sdb1" is a new physical volume of "<80.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               <80.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               z4DXMt-lLMM-POnC-KsDe-73LY-BHmP-dCQFYe
[3] Change size of Physical Volume.
# change to 50G

root@dlp:~#
pvresize --setphysicalvolumesize 50G /dev/sdb1

/dev/sdb1: Requested size 50.00 GiB is less than real size <80.00 GiB. Proceed?  [y/n]: y
  WARNING: /dev/sdb1: Pretending size is 104857600 not 167770112 sectors.
  Physical volume "/dev/sdb1" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

root@dlp:~#
pvdisplay /dev/sdb1

  "/dev/sdb1" is a new physical volume of "50.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               50.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               z4DXMt-lLMM-POnC-KsDe-73LY-BHmP-dCQFYe
[4] Display reports of Physical Volumes.
root@dlp:~#
pvs /dev/sdb1

  PV         VG Fmt  Attr PSize  PFree
  /dev/sdb1     lvm2 ---  50.00g 50.00g
[5] Scan Physical Volumes.
root@dlp:~#
pvscan

  PV /dev/vda3   VG ubuntu-vg       lvm2 [<78.00 GiB / 0    free]
  PV /dev/sdb1                      lvm2 [50.00 GiB]
  Total: 2 [<128.00 GiB] / in use: 1 [<78.00 GiB] / in no VG: 1 [50.00 GiB]
[6] Delete Physical Volume.
root@dlp:~#
pvremove /dev/sdb1

  Labels on physical volume "/dev/sdb1" successfully wiped.
root@dlp:~#
pvdisplay /dev/sdb1

  Failed to find physical volume "/dev/sdb1".
Matched Content