Linux removes the physical volume of PV in LVM

  

LVM is usually used for systems equipped with a large number of disks, with good scalability, can adjust the size of volume groups and logical volumes, today Xiaobian wants to introduce to you Is Linux how to delete the PV physical volume (hard disk or partition) in LVM, let's learn together.

First, due to the operation of the hard disk or partition in fact are the same, so I'm here to partition an example.

Second, /home partition 2.6G, consists of the following pv:

/dev/sda5 100M

/dev/sda6 200M

/dev/Sda7 300M

/dev/sda8 400M

/dev/sda9 500M

/dev/sda10 600M

/dev/sda11 500M

Very broken right? ^_^ Because of the test.

Third, randomly write a bunch of files into, the amount reached 2G, idle 500M

Fourth, prepare to remove the sda6 200M PV (removed capacity must be less than the free capacity)

Ok, let's get started.

Unmount the partition (the shrink operation must be uninstalled):

umount /home

Reduce the partition:

e2fsck -f /dev/liuhg_disk/home

resize2fs /dev/liuhg_disk/home 2200M

First shrink the partition to 2200M. This is to make room for sda6, sda6 is 200M, and I vacated 400M, so it should be enough of.

Reduce the logical volume:

lvreduce -L 2200M /dev/liuhg_disk/home

The partition is reduced and the logical volume used is also reduced, and the PV is used. Status:

pvdisplay -m

is displayed as follows:

--- Physical volume ---

PV Name /dev/sda5

VG Name liuhg_disk

PV Size 103.26 MiB /not usable 3.26 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 25

Free PE 0

Allocated PE 25

PV UUID 5lnx52-b4jc-OOfZ-f2QA-ttdQ-DZeD-Ce3rb3

--- Physical Segments ---

Physical extent 0 to 24:

Logical volume /dev/liuhg_disk/home

Logical extents 0 to 24

-- - Physical volume ---

PV Name /dev/sda6

VG Name liuhg_disk

PV Size 203.92 MiB /not usable 3.92 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 50

Free PE 0 "-----That tragedy, sda6 is full of data, no more

Allocated PE 50 "-----This 50PE The data should be removed, otherwise the data will be lost, and the storage location must be at least 50PE

PV UUID S2ane6-nlFG-uSNR-35NP-Yxa6-cXRb-r8E8mK

--- Physical Segments ---

Physical extent 0 to 49:

Logical volume /dev/liuhg_disk/home

Logical extents 25 to 74

--- Physical volume ---

PV Name /dev/sda7

VG Name liuhg_disk

PV Size 305.89 MiB /not usable 1.89 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 76

Free PE 76 "---This partition has 76 spares, so it is expected that 50 will be loaded

Allocated PE 0

PV UUID 9CFnlx-CAEw-CSul-Rig9-FiCN-zK0a-oGmTEP

--- Physical Segments ---< Br>

Physical extent 0 to 75:

FRE E

--- Physical volume ---

PV Name /dev/sda8

VG Name liuhg_disk

PV Size 407.87 MiB /not usable 3.87 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 101

Free PE 60

Allocated PE 41

PV UUID X0I8p0-x2xr-2xLG-QQD4-jbtS-3C4i-xPn4Bl

--- Physical Segments ---

Physical extent 0 to 40:

Logical Volume /dev/liuhg_disk/home

Logical extents 471 to 511
Previous12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved