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

Reducing an lvmgroup - cannot resize to xxxx extents as later ones are allocated

· 52CE 我爱测

I've been going through the process of reducing the size of a Centos 6.10 image by reducing an lvmgroup. I'm at the point where I've been able to run this command: pvresize -tv --setphysicalvolumesize 1600G /dev/md125p2 And it's …

问题原文

原帖链接 · Jack BeNimble · CC BY-SA 4.0

I've been going through the process of reducing the size of a Centos 6.10 image by reducing an lvmgroup. I'm at the point where I've been able to run this command:

pvresize -tv --setphysicalvolumesize  1600G /dev/md125p2

And it's giving me the following error message:

 /dev/md125p2: cannot resize to 409599 extents as later ones are allocated.

I'm trying to understand how to construct the pvmove command to get rid of the error, but I don't quite get the concept.

Here is the output of this command pvs -v --segments /dev/md125p

  PV           VG            Fmt  Attr PSize PFree   Start  SSize  LV       Start Type   PE Ranges                 
  /dev/md125p2 vg_centos6svr lvm2 a--u 1.86t 320.11g      0 384000 lv_mysql     0 linear /dev/md125p2:0-383999     
  /dev/md125p2 vg_centos6svr lvm2 a--u 1.86t 320.11g 384000  81947              0 free                             
  /dev/md125p2 vg_centos6svr lvm2 a--u 1.86t 320.11g 465947  12800 lv_root      0 linear /dev/md125p2:465947-478746
  /dev/md125p2 vg_centos6svr lvm2 a--u 1.86t 320.11g 478747   1998 lv_swap      0 linear /dev/md125p2:478747-480744
  /dev/md125p2 vg_centos6svr lvm2 a--u 1.86t 320.11g 480745   7500 lv_home      0 linear /dev/md125p2:480745-488244

I know the move command has to look something like this:

pvmove --alloc anywhere /dev/md125p2 vg_centos6svr:yyyy-end

I'm just not clear how to calculate the yyyy-end part. I figure it means move that 81947 (blocks?) that start at 384000, but what is "yyyy" and "end"?

已采纳解答

原帖链接 · dsz · CC BY-SA 4.0

So, what I can see is everything is on /dev/md125p2 and we want to reduce the size of this PV.

Your output from pvs -v --segments /dev/md125p show you have a very large free space (SSize==81947) after your lv_mysql and before your lv_root. This is big enough to house lv_root and all of the LVs that come after it in the physical layout.

So, the first set of numbers I'd suggest is:

***# pvmove --alloc anywhere /dev/md125p2:480745-488244 /dev/md125p2:384000+7499

that is, move the whole of lv_home to the free space starting directly after lv_mysql.

Then re-run pvs -v --segments /dev/md125p to see the revised numbers, and move the next block into whatever free space is left.

This will effectively defrag your PV.

Now, pvmove may have way more options than what I'm using (maybe specifying the PV instead of the extents?) but what I got comfortable with is just being explicit with the blocks, so all of my sources and targets are in the form of /dev/<dev>:<Start>-<End> or /dev/<dev>:<Start>+<SSize-1>.

I suspect your problem was mainly missing the extents off of your "source" specification.

I've seen a few examples out their using -end - I don't know if that's something that's supposed to work, but it would beg the question "end of what?". So I avoid it and use explicit block numbers. You just need to be mindful that the + syntax is a plus, and needs to be one less than the SSize.

Extra

OK, on the source side it seems like you can do -name lv_home /dev/md125p2 as a short-hand for /dev/md125p2:480745-488244 - but note also that this will get more complex if lh_home was fragmented into multiple extents (would it mean "all fragments?") - I think I still prefer the numbers approach. Note that your example in the question didn't include the LV name, so I'm not sure what pvmove would have understood from what you gave it...

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

资料来源与适用范围

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

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

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