LVM: Decrease/shrink size of a physical volume by deallocating free space from removed logical volume

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have the following LVM partition:



# df -h

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/data-root 5.3G 4.2G 864M 84% /
...
/dev/mapper/data-install 6.8G 5.7G 783M 89% /install

# vgs
VG #PV #LV #SN Attr VSize VFree
data 1 2 0 wz--n- <12.50g 0

# vgdisplay
--- Volume group ---
VG Name data
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <12.50 GiB
PE Size 4.00 MiB
Total PE 3199
Alloc PE / Size 3199 / <12.50 GiB
Free PE / Size 0 / 0
VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 data lvm2 a-- <12.50g 0

# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name data
PV Size <12.50 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 3199
Free PE 0
Allocated PE 3199
PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3

# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
install data -wi-ao---- 7.00g
root data -wi-ao---- <5.50g


# lvdisplay
--- Logical volume ---
LV Path /dev/data/install
LV Name install
VG Name data
LV UUID ZXQmp5-L17b-eQyS-g3An-msk7-Jqso-MTaTIw
LV Write Access read/write
LV Creation host, time localhost, 2018-09-28 14:42:43 +0000
LV Status available
open 1
LV Size 7.00 GiB
Current LE 1792
Segments 1
Allocation inherit
Read ahead sectors aut
- currently set to 8192
Block device 253:1



--- Logical volume ---
LV Path /dev/data/root
LV Name root
VG Name data
LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
LV Write Access read/write
LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
LV Status available
# open 1
LV Size <5.50 GiB
Current LE 1407
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0


I am removing one of the logical volumes:



# umount /install
# lvremove /dev/data/install
# sed -i 'N;//dev/mapper/data-install/s#/dev/mapper/data-install.*n##' /etc/fstab


After the removal:



# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/data-root 5.3G 4.2G 867M 84% /
...


# vgs
VG #PV #LV #SN Attr VSize VFre
data 1 1 0 wz--n- <12.50g 7.00g


# vgdisplay
--- Volume group ---
VG Name data
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
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 <12.50 GiB
PE Size 4.00 MiB
Total PE 3199
Alloc PE / Size 1407 / <5.50 GiB
Free PE / Size 1792 / 7.00 GiB
VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 data lvm2 a-- <12.50g 7.00g


# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name data
PV Size <12.50 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 3199
Free PE 1792
Allocated PE 1407
PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3


# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root data -wi-ao---- <5.50g


# lvdisplay
--- Logical volume ---
LV Path /dev/data/root
LV Name root
VG Name data
LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
LV Write Access read/write
LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
LV Status available
# open 1
LV Size <5.50 GiB
Current LE 1407
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0


How can I shrink the physical volume, volume group and finally the partition altogether by what amounts to the free space after removing the logical volume? Preferably that should be done specifying relative values (to pvresize?) or something similar to lvextend -l 100%FREE <lvolume>. Also I would like to accomplish this using the command line alone (no GUI). It is also worth noting that the root/system logical volume is active and in use at all times.










share|improve this question









New contributor




SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    0
    down vote

    favorite












    I have the following LVM partition:



    # df -h

    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/data-root 5.3G 4.2G 864M 84% /
    ...
    /dev/mapper/data-install 6.8G 5.7G 783M 89% /install

    # vgs
    VG #PV #LV #SN Attr VSize VFree
    data 1 2 0 wz--n- <12.50g 0

    # vgdisplay
    --- Volume group ---
    VG Name data
    System ID
    Format lvm2
    Metadata Areas 1
    Metadata Sequence No 3
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 2
    Open LV 2
    Max PV 0
    Cur PV 1
    Act PV 1
    VG Size <12.50 GiB
    PE Size 4.00 MiB
    Total PE 3199
    Alloc PE / Size 3199 / <12.50 GiB
    Free PE / Size 0 / 0
    VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


    # pvs
    PV VG Fmt Attr PSize PFree
    /dev/sda2 data lvm2 a-- <12.50g 0

    # pvdisplay
    --- Physical volume ---
    PV Name /dev/sda2
    VG Name data
    PV Size <12.50 GiB / not usable 3.00 MiB
    Allocatable yes (but full)
    PE Size 4.00 MiB
    Total PE 3199
    Free PE 0
    Allocated PE 3199
    PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3

    # lvs
    LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
    install data -wi-ao---- 7.00g
    root data -wi-ao---- <5.50g


    # lvdisplay
    --- Logical volume ---
    LV Path /dev/data/install
    LV Name install
    VG Name data
    LV UUID ZXQmp5-L17b-eQyS-g3An-msk7-Jqso-MTaTIw
    LV Write Access read/write
    LV Creation host, time localhost, 2018-09-28 14:42:43 +0000
    LV Status available
    open 1
    LV Size 7.00 GiB
    Current LE 1792
    Segments 1
    Allocation inherit
    Read ahead sectors aut
    - currently set to 8192
    Block device 253:1



    --- Logical volume ---
    LV Path /dev/data/root
    LV Name root
    VG Name data
    LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
    LV Write Access read/write
    LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
    LV Status available
    # open 1
    LV Size <5.50 GiB
    Current LE 1407
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    - currently set to 8192
    Block device 253:0


    I am removing one of the logical volumes:



    # umount /install
    # lvremove /dev/data/install
    # sed -i 'N;//dev/mapper/data-install/s#/dev/mapper/data-install.*n##' /etc/fstab


    After the removal:



    # df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/data-root 5.3G 4.2G 867M 84% /
    ...


    # vgs
    VG #PV #LV #SN Attr VSize VFre
    data 1 1 0 wz--n- <12.50g 7.00g


    # vgdisplay
    --- Volume group ---
    VG Name data
    System ID
    Format lvm2
    Metadata Areas 1
    Metadata Sequence No 4
    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 <12.50 GiB
    PE Size 4.00 MiB
    Total PE 3199
    Alloc PE / Size 1407 / <5.50 GiB
    Free PE / Size 1792 / 7.00 GiB
    VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


    # pvs
    PV VG Fmt Attr PSize PFree
    /dev/sda2 data lvm2 a-- <12.50g 7.00g


    # pvdisplay
    --- Physical volume ---
    PV Name /dev/sda2
    VG Name data
    PV Size <12.50 GiB / not usable 3.00 MiB
    Allocatable yes
    PE Size 4.00 MiB
    Total PE 3199
    Free PE 1792
    Allocated PE 1407
    PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3


    # lvs
    LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
    root data -wi-ao---- <5.50g


    # lvdisplay
    --- Logical volume ---
    LV Path /dev/data/root
    LV Name root
    VG Name data
    LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
    LV Write Access read/write
    LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
    LV Status available
    # open 1
    LV Size <5.50 GiB
    Current LE 1407
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    - currently set to 8192
    Block device 253:0


    How can I shrink the physical volume, volume group and finally the partition altogether by what amounts to the free space after removing the logical volume? Preferably that should be done specifying relative values (to pvresize?) or something similar to lvextend -l 100%FREE <lvolume>. Also I would like to accomplish this using the command line alone (no GUI). It is also worth noting that the root/system logical volume is active and in use at all times.










    share|improve this question









    New contributor




    SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have the following LVM partition:



      # df -h

      Filesystem Size Used Avail Use% Mounted on
      /dev/mapper/data-root 5.3G 4.2G 864M 84% /
      ...
      /dev/mapper/data-install 6.8G 5.7G 783M 89% /install

      # vgs
      VG #PV #LV #SN Attr VSize VFree
      data 1 2 0 wz--n- <12.50g 0

      # vgdisplay
      --- Volume group ---
      VG Name data
      System ID
      Format lvm2
      Metadata Areas 1
      Metadata Sequence No 3
      VG Access read/write
      VG Status resizable
      MAX LV 0
      Cur LV 2
      Open LV 2
      Max PV 0
      Cur PV 1
      Act PV 1
      VG Size <12.50 GiB
      PE Size 4.00 MiB
      Total PE 3199
      Alloc PE / Size 3199 / <12.50 GiB
      Free PE / Size 0 / 0
      VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


      # pvs
      PV VG Fmt Attr PSize PFree
      /dev/sda2 data lvm2 a-- <12.50g 0

      # pvdisplay
      --- Physical volume ---
      PV Name /dev/sda2
      VG Name data
      PV Size <12.50 GiB / not usable 3.00 MiB
      Allocatable yes (but full)
      PE Size 4.00 MiB
      Total PE 3199
      Free PE 0
      Allocated PE 3199
      PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3

      # lvs
      LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
      install data -wi-ao---- 7.00g
      root data -wi-ao---- <5.50g


      # lvdisplay
      --- Logical volume ---
      LV Path /dev/data/install
      LV Name install
      VG Name data
      LV UUID ZXQmp5-L17b-eQyS-g3An-msk7-Jqso-MTaTIw
      LV Write Access read/write
      LV Creation host, time localhost, 2018-09-28 14:42:43 +0000
      LV Status available
      open 1
      LV Size 7.00 GiB
      Current LE 1792
      Segments 1
      Allocation inherit
      Read ahead sectors aut
      - currently set to 8192
      Block device 253:1



      --- Logical volume ---
      LV Path /dev/data/root
      LV Name root
      VG Name data
      LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
      LV Write Access read/write
      LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
      LV Status available
      # open 1
      LV Size <5.50 GiB
      Current LE 1407
      Segments 1
      Allocation inherit
      Read ahead sectors auto
      - currently set to 8192
      Block device 253:0


      I am removing one of the logical volumes:



      # umount /install
      # lvremove /dev/data/install
      # sed -i 'N;//dev/mapper/data-install/s#/dev/mapper/data-install.*n##' /etc/fstab


      After the removal:



      # df -h
      Filesystem Size Used Avail Use% Mounted on
      /dev/mapper/data-root 5.3G 4.2G 867M 84% /
      ...


      # vgs
      VG #PV #LV #SN Attr VSize VFre
      data 1 1 0 wz--n- <12.50g 7.00g


      # vgdisplay
      --- Volume group ---
      VG Name data
      System ID
      Format lvm2
      Metadata Areas 1
      Metadata Sequence No 4
      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 <12.50 GiB
      PE Size 4.00 MiB
      Total PE 3199
      Alloc PE / Size 1407 / <5.50 GiB
      Free PE / Size 1792 / 7.00 GiB
      VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


      # pvs
      PV VG Fmt Attr PSize PFree
      /dev/sda2 data lvm2 a-- <12.50g 7.00g


      # pvdisplay
      --- Physical volume ---
      PV Name /dev/sda2
      VG Name data
      PV Size <12.50 GiB / not usable 3.00 MiB
      Allocatable yes
      PE Size 4.00 MiB
      Total PE 3199
      Free PE 1792
      Allocated PE 1407
      PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3


      # lvs
      LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
      root data -wi-ao---- <5.50g


      # lvdisplay
      --- Logical volume ---
      LV Path /dev/data/root
      LV Name root
      VG Name data
      LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
      LV Write Access read/write
      LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
      LV Status available
      # open 1
      LV Size <5.50 GiB
      Current LE 1407
      Segments 1
      Allocation inherit
      Read ahead sectors auto
      - currently set to 8192
      Block device 253:0


      How can I shrink the physical volume, volume group and finally the partition altogether by what amounts to the free space after removing the logical volume? Preferably that should be done specifying relative values (to pvresize?) or something similar to lvextend -l 100%FREE <lvolume>. Also I would like to accomplish this using the command line alone (no GUI). It is also worth noting that the root/system logical volume is active and in use at all times.










      share|improve this question









      New contributor




      SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have the following LVM partition:



      # df -h

      Filesystem Size Used Avail Use% Mounted on
      /dev/mapper/data-root 5.3G 4.2G 864M 84% /
      ...
      /dev/mapper/data-install 6.8G 5.7G 783M 89% /install

      # vgs
      VG #PV #LV #SN Attr VSize VFree
      data 1 2 0 wz--n- <12.50g 0

      # vgdisplay
      --- Volume group ---
      VG Name data
      System ID
      Format lvm2
      Metadata Areas 1
      Metadata Sequence No 3
      VG Access read/write
      VG Status resizable
      MAX LV 0
      Cur LV 2
      Open LV 2
      Max PV 0
      Cur PV 1
      Act PV 1
      VG Size <12.50 GiB
      PE Size 4.00 MiB
      Total PE 3199
      Alloc PE / Size 3199 / <12.50 GiB
      Free PE / Size 0 / 0
      VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


      # pvs
      PV VG Fmt Attr PSize PFree
      /dev/sda2 data lvm2 a-- <12.50g 0

      # pvdisplay
      --- Physical volume ---
      PV Name /dev/sda2
      VG Name data
      PV Size <12.50 GiB / not usable 3.00 MiB
      Allocatable yes (but full)
      PE Size 4.00 MiB
      Total PE 3199
      Free PE 0
      Allocated PE 3199
      PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3

      # lvs
      LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
      install data -wi-ao---- 7.00g
      root data -wi-ao---- <5.50g


      # lvdisplay
      --- Logical volume ---
      LV Path /dev/data/install
      LV Name install
      VG Name data
      LV UUID ZXQmp5-L17b-eQyS-g3An-msk7-Jqso-MTaTIw
      LV Write Access read/write
      LV Creation host, time localhost, 2018-09-28 14:42:43 +0000
      LV Status available
      open 1
      LV Size 7.00 GiB
      Current LE 1792
      Segments 1
      Allocation inherit
      Read ahead sectors aut
      - currently set to 8192
      Block device 253:1



      --- Logical volume ---
      LV Path /dev/data/root
      LV Name root
      VG Name data
      LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
      LV Write Access read/write
      LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
      LV Status available
      # open 1
      LV Size <5.50 GiB
      Current LE 1407
      Segments 1
      Allocation inherit
      Read ahead sectors auto
      - currently set to 8192
      Block device 253:0


      I am removing one of the logical volumes:



      # umount /install
      # lvremove /dev/data/install
      # sed -i 'N;//dev/mapper/data-install/s#/dev/mapper/data-install.*n##' /etc/fstab


      After the removal:



      # df -h
      Filesystem Size Used Avail Use% Mounted on
      /dev/mapper/data-root 5.3G 4.2G 867M 84% /
      ...


      # vgs
      VG #PV #LV #SN Attr VSize VFre
      data 1 1 0 wz--n- <12.50g 7.00g


      # vgdisplay
      --- Volume group ---
      VG Name data
      System ID
      Format lvm2
      Metadata Areas 1
      Metadata Sequence No 4
      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 <12.50 GiB
      PE Size 4.00 MiB
      Total PE 3199
      Alloc PE / Size 1407 / <5.50 GiB
      Free PE / Size 1792 / 7.00 GiB
      VG UUID jSACsC-wGwy-ki0w-nSCn-kxMy-bLOV-dVN68E


      # pvs
      PV VG Fmt Attr PSize PFree
      /dev/sda2 data lvm2 a-- <12.50g 7.00g


      # pvdisplay
      --- Physical volume ---
      PV Name /dev/sda2
      VG Name data
      PV Size <12.50 GiB / not usable 3.00 MiB
      Allocatable yes
      PE Size 4.00 MiB
      Total PE 3199
      Free PE 1792
      Allocated PE 1407
      PV UUID CPggVR-sUXw-4gfw-lb2v-cq0j-M5ey-Ct7td3


      # lvs
      LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
      root data -wi-ao---- <5.50g


      # lvdisplay
      --- Logical volume ---
      LV Path /dev/data/root
      LV Name root
      VG Name data
      LV UUID i3eMbC-rcm1-H2Gm-JJeF-jRxO-nL9h-toHSHQ
      LV Write Access read/write
      LV Creation host, time localhost, 2018-09-28 14:42:55 +0000
      LV Status available
      # open 1
      LV Size <5.50 GiB
      Current LE 1407
      Segments 1
      Allocation inherit
      Read ahead sectors auto
      - currently set to 8192
      Block device 253:0


      How can I shrink the physical volume, volume group and finally the partition altogether by what amounts to the free space after removing the logical volume? Preferably that should be done specifying relative values (to pvresize?) or something similar to lvextend -l 100%FREE <lvolume>. Also I would like to accomplish this using the command line alone (no GUI). It is also worth noting that the root/system logical volume is active and in use at all times.







      lvm






      share|improve this question









      New contributor




      SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited Oct 4 at 8:37





















      New contributor




      SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Oct 3 at 22:46









      SaveMeTenMinutes

      13




      13




      New contributor




      SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      SaveMeTenMinutes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Well, pvresize doesn't have an option for relative values like lvextend does, so you need to specify the exact size you want. Here's what you can do:



          1. Shrink physical volume: pvresize --setphysicalvolumesize 5.5G /dev/sda2

          2. Shrink the partition with the tool of your choice. If you want to script it you can use parted. Make the partition a little bit bigger than 5.5G to account for any differences in how the size in bytes is calculated, or ensure you're using the same unit in both tools.

          3. If the units differed between the tools, expand the physical volume to consume the entire partition: pvresize /dev/sda2





          share|improve this answer




















          • # pvresize --setphysicalvolumesize 5.5G /dev/sda2⤶/dev/sda2: Requested size 5.50 GiB is less than real size <12.50 GiB. Proceed? [y/n]: y⤶WARNING: /dev/sda2: Pretending size is 11534336 not 26212352 sectors.⤶/dev/sda2: cannot resize to 1407 extents as later ones are allocated.⤶0 physical volume(s) resized / 1 physical volume(s) not resized
            – SaveMeTenMinutes
            Oct 4 at 9:29










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          SaveMeTenMinutes is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473105%2flvm-decrease-shrink-size-of-a-physical-volume-by-deallocating-free-space-from-r%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Well, pvresize doesn't have an option for relative values like lvextend does, so you need to specify the exact size you want. Here's what you can do:



          1. Shrink physical volume: pvresize --setphysicalvolumesize 5.5G /dev/sda2

          2. Shrink the partition with the tool of your choice. If you want to script it you can use parted. Make the partition a little bit bigger than 5.5G to account for any differences in how the size in bytes is calculated, or ensure you're using the same unit in both tools.

          3. If the units differed between the tools, expand the physical volume to consume the entire partition: pvresize /dev/sda2





          share|improve this answer




















          • # pvresize --setphysicalvolumesize 5.5G /dev/sda2⤶/dev/sda2: Requested size 5.50 GiB is less than real size <12.50 GiB. Proceed? [y/n]: y⤶WARNING: /dev/sda2: Pretending size is 11534336 not 26212352 sectors.⤶/dev/sda2: cannot resize to 1407 extents as later ones are allocated.⤶0 physical volume(s) resized / 1 physical volume(s) not resized
            – SaveMeTenMinutes
            Oct 4 at 9:29














          up vote
          0
          down vote













          Well, pvresize doesn't have an option for relative values like lvextend does, so you need to specify the exact size you want. Here's what you can do:



          1. Shrink physical volume: pvresize --setphysicalvolumesize 5.5G /dev/sda2

          2. Shrink the partition with the tool of your choice. If you want to script it you can use parted. Make the partition a little bit bigger than 5.5G to account for any differences in how the size in bytes is calculated, or ensure you're using the same unit in both tools.

          3. If the units differed between the tools, expand the physical volume to consume the entire partition: pvresize /dev/sda2





          share|improve this answer




















          • # pvresize --setphysicalvolumesize 5.5G /dev/sda2⤶/dev/sda2: Requested size 5.50 GiB is less than real size <12.50 GiB. Proceed? [y/n]: y⤶WARNING: /dev/sda2: Pretending size is 11534336 not 26212352 sectors.⤶/dev/sda2: cannot resize to 1407 extents as later ones are allocated.⤶0 physical volume(s) resized / 1 physical volume(s) not resized
            – SaveMeTenMinutes
            Oct 4 at 9:29












          up vote
          0
          down vote










          up vote
          0
          down vote









          Well, pvresize doesn't have an option for relative values like lvextend does, so you need to specify the exact size you want. Here's what you can do:



          1. Shrink physical volume: pvresize --setphysicalvolumesize 5.5G /dev/sda2

          2. Shrink the partition with the tool of your choice. If you want to script it you can use parted. Make the partition a little bit bigger than 5.5G to account for any differences in how the size in bytes is calculated, or ensure you're using the same unit in both tools.

          3. If the units differed between the tools, expand the physical volume to consume the entire partition: pvresize /dev/sda2





          share|improve this answer












          Well, pvresize doesn't have an option for relative values like lvextend does, so you need to specify the exact size you want. Here's what you can do:



          1. Shrink physical volume: pvresize --setphysicalvolumesize 5.5G /dev/sda2

          2. Shrink the partition with the tool of your choice. If you want to script it you can use parted. Make the partition a little bit bigger than 5.5G to account for any differences in how the size in bytes is calculated, or ensure you're using the same unit in both tools.

          3. If the units differed between the tools, expand the physical volume to consume the entire partition: pvresize /dev/sda2






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 4 at 5:17









          Emmanuel Rosa

          2,6501411




          2,6501411











          • # pvresize --setphysicalvolumesize 5.5G /dev/sda2⤶/dev/sda2: Requested size 5.50 GiB is less than real size <12.50 GiB. Proceed? [y/n]: y⤶WARNING: /dev/sda2: Pretending size is 11534336 not 26212352 sectors.⤶/dev/sda2: cannot resize to 1407 extents as later ones are allocated.⤶0 physical volume(s) resized / 1 physical volume(s) not resized
            – SaveMeTenMinutes
            Oct 4 at 9:29
















          • # pvresize --setphysicalvolumesize 5.5G /dev/sda2⤶/dev/sda2: Requested size 5.50 GiB is less than real size <12.50 GiB. Proceed? [y/n]: y⤶WARNING: /dev/sda2: Pretending size is 11534336 not 26212352 sectors.⤶/dev/sda2: cannot resize to 1407 extents as later ones are allocated.⤶0 physical volume(s) resized / 1 physical volume(s) not resized
            – SaveMeTenMinutes
            Oct 4 at 9:29















          # pvresize --setphysicalvolumesize 5.5G /dev/sda2⤶/dev/sda2: Requested size 5.50 GiB is less than real size <12.50 GiB. Proceed? [y/n]: y⤶WARNING: /dev/sda2: Pretending size is 11534336 not 26212352 sectors.⤶/dev/sda2: cannot resize to 1407 extents as later ones are allocated.⤶0 physical volume(s) resized / 1 physical volume(s) not resized
          – SaveMeTenMinutes
          Oct 4 at 9:29




          # pvresize --setphysicalvolumesize 5.5G /dev/sda2⤶/dev/sda2: Requested size 5.50 GiB is less than real size <12.50 GiB. Proceed? [y/n]: y⤶WARNING: /dev/sda2: Pretending size is 11534336 not 26212352 sectors.⤶/dev/sda2: cannot resize to 1407 extents as later ones are allocated.⤶0 physical volume(s) resized / 1 physical volume(s) not resized
          – SaveMeTenMinutes
          Oct 4 at 9:29










          SaveMeTenMinutes is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          SaveMeTenMinutes is a new contributor. Be nice, and check out our Code of Conduct.












          SaveMeTenMinutes is a new contributor. Be nice, and check out our Code of Conduct.











          SaveMeTenMinutes is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473105%2flvm-decrease-shrink-size-of-a-physical-volume-by-deallocating-free-space-from-r%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?