大网数据广告活动
服务器运维问答

Shrink Volume Group in LVM on linux with just one disk

· 52CE 我爱测

I'm using LVM on a single disk and now I need to resize the partition (sda2) I'm using. I've already resized the Logical Volume but I can't manage to shrink the Volume Group. I know that vgreduce can remove Physical Volumes entir…

问题原文

原帖链接 · Andreas Wederbrand · CC BY-SA 4.0

I'm using LVM on a single disk and now I need to resize the partition (sda2) I'm using.

I've already resized the Logical Volume but I can't manage to shrink the Volume Group. I know that vgreduce can remove Physical Volumes entirely but I have only one and I need too shrink that one.

Is it possible?

已采纳解答

原帖链接 · John Mahowald · CC BY-SA 4.0

Assuming Linux LVM.

Reducing the size of a PV, and keeping the same PV partition, is a multiple step process. A little bit dangerous, data corruption is possible if the volumes are reduced too small for the file system.

  1. Backup data.
  2. Reduce the size of the file system. This is not possible for XFS, in which case you will need an alternative solution like restore backups to a smaller volume.
  3. lvreduce --resizefs --size the LV. --resizefs does step #2 at the same time, ensuring the sizes match.
  4. pvresize --setphysicalvolumesize the PV.
  5. Re-partition the PV. Tricky on the PV that contains the root file system. May be necessary to reboot into a rescue enviornment with root not mounted and VG not activated.

vgreduce removes entire PVs from the VG, and is not useful in this example.


As an alternative, if you move to using entire disks and not partitions, this process can be simpler.

  1. Backup data.
  2. lvreduce --resizefs --size if necessary to fit in the new disk
  3. Create disk, say it is named /dev/sdb
  4. vgextend /dev/sdb
  5. pvmove /dev/sda1
  6. vgreduce /dev/sda1

End result, VG moved to new disk, old partition empty and can be deleted.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-05-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。