CentOS 8
Sponsored Link

LVM : Manage Phisical Volumes2020/02/07

 
This is the basic operation of managing Phisical Volumes.
[1] If target disk is a new installed disk, create a partition and set LVM before managing Phisical Volumes.
For the example below, it creates GPT type partiton on the new disk [sdb] and set LVM to it.
[root@dlp ~]#
parted --script /dev/sdb "mklabel gpt"

[root@dlp ~]#
parted --script /dev/sdb "mkpart 'Linux LVM' 0% 100%"

[root@dlp ~]#
parted --script /dev/sdb "set 1 lvm on"

[2] Create Phisical Volumes.
[root@dlp ~]#
pvcreate /dev/sdb1

  Physical volume "/dev/sdb1" successfully created.

# specify like follows if you'd like to specify volume size

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

[2] Display Phisical Volumes.
[root@dlp ~]#
pvdisplay /dev/sdb1

  --- 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               VydC4s-EElC-hC6G-WXk2-bgrq-FDYa-lOJm6N
[3] Change size of Phisical Volumes.
# 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 167768064 sectors.
  Physical volume "/dev/sdb1" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

[root@dlp ~]#
pvdisplay /dev/sdb1

  --- 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               VydC4s-EElC-hC6G-WXk2-bgrq-FDYa-lOJm6N
[4] Display reports of Phisical Volumes.
[root@dlp ~]#
pvs /dev/sdb1

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

  PV /dev/sda2   VG cl              lvm2 [<29.00 GiB / 0    free]
  PV /dev/sdb1                      lvm2 [80.00 GiB]
  Total: 2 [<109.00 GiB] / in use: 1 [<29.00 GiB] / in no VG: 1 [80.00 GiB]
[6] Delete Phisical Volumes.
[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