Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to remove a physical volume from a volume group in LVM

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to delete physical volumes from the LVM volume group. It is very detailed and has a certain reference value. Friends who are interested must read it!

If you no longer need to use a device for your LVM, you can use the vgreduce command to remove physical volumes from the volume group.

The vgreduce command reduces the capacity of a volume group by deleting physical volumes. However, to ensure that the physical volume is not used by any logical volume, use the pvdisplay command to view it. If the physical volume is still in use, you must use the pvmove command to transfer the data to another physical volume.

After the data is transferred, it can be removed from the volume group.

Finally, use the pvremove command to delete the LVM tags and LVM metadata on the empty physical management volume.

Part 1: how to create / configure LVM in Linux (logical volume management)

Part 2: how to extend / add LVM in Linux (logical volume adjustment)

Part III: how to reduce / reduce LVM size in Linux (logical volume adjustment)

Move the extension block to an existing physical volume

Use the pvs command to check that the required physical volumes are being used (we plan to delete the / dev/sdc disk in LVM).

# pvs-o+pv_used PV VG Fmt Attr PSize PFree Used/dev/sda myvg lvm2 a-75.00G 14.00G 61.00G/dev/sdb myvg lvm2 a-50.00G 45.00G 5.00G/dev/sdc myvg lvm2 a-17.15G 12.15G 5.00g

If so, check that the other physical volumes in the volume group have enough free extension block extent.

If so, you can run the pvmove command on the device that needs to be deleted. Extension blocks will be assigned to other devices.

# pvmove / dev/sdc / dev/sdc: Moved: 2.0%... / dev/sdc: Moved: 79.2%... / dev/sdc: Moved: 100.0%

When the pvmove command is complete. Use the pvs command again to check if the physical volume is free.

# pvs-o+pv_used PV VG Fmt Attr PSize PFree Used/dev/sda myvg lvm2 a-75.00G 1.85G 73.15G/dev/sdb myvg lvm2 a-50.00G 45.00G 5.00G/dev/sdc myvg lvm2 a-17.15G 17.15G 0

If it is idle, use the vgreduce command to remove the physical volume / dev/sdc from the volume group.

# vgreduce myvg / dev/sdcRemoved "/ dev/sdc" from volume group "vg01"

Finally, run the pvremove command to remove the disk from the LVM configuration. Now the disk has been completely removed from LVM and can be used for other purposes.

# pvremove / dev/sdcLabels on physical volume "/ dev/sdc" successfully wiped. Move the expansion block to the new disk

If you do not have enough extensions available on other physical volumes in the volume group. Use the following procedure to add a new physical volume.

Request a new LUN from the storage group. After the allocation is complete, run the following command to discover the newly added LUN or disk in Linux.

# ls / sys/class/scsi_hosthost0# echo "- -" > / sys/class/scsi_host/host0/scan# fdisk-l

After the disk is detected in the operating system, use the pvcreate command to create a physical volume.

# pvcreate / dev/sddPhysical volume "/ dev/sdd" successfully created

Use the following command to add a new physical volume / dev/sdd to the existing volume group vg01.

# vgextend vg01 / dev/sddVolume group "vg01" successfully extended

Now, use the pvs command to view the new disk / dev/sdd you added.

# pvs-o+pv_used PV VG Fmt Attr PSize PFree Used/dev/sda myvg lvm2 a-75.00G 14.00G 61.00G/dev/sdb myvg lvm2 a-50.00G 45.00G 5.00G/dev/sdc myvg lvm2 a-17.15G 12.15G 5.00G/dev/sdd myvg lvm2 a-60.00G 60.00G 0

Use the pvmove command to move data from / dev/sdc to / dev/sdd.

# pvmove / dev/sdc / dev/sdd / dev/sdc: Moved: 10.0%... / dev/sdc: Moved: 79.7%... / dev/sdc: Moved: 100.0%

After the data is moved to the new disk. Use the pvs command again to check that the physical volume is free.

# pvs-o+pv_used PV VG Fmt Attr PSize PFree Used/dev/sda myvg lvm2 a- 75.00G 14.00G 61.00G/dev/sdb myvg lvm2 a-50.00G 45.00G 5.00G/dev/sdc myvg lvm2 a-17.15G 17.15G 0/dev/sdd myvg lvm2 a-60.00G 47.85G 12.15G

If idle, use the vgreduce command to remove the physical volume / dev/sdc from the volume group.

# vgreduce myvg / dev/sdcRemoved "/ dev/sdc" from volume group "vg01"

Finally, run the pvremove command to remove the disk from the LVM configuration. Now the disk has been completely removed from LVM and can be used for other purposes.

# pvremove / dev/sdcLabels on physical volume "/ dev/sdc" successfully wiped. The above is all the contents of the article "how to remove physical volumes from LVM's volume group". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report