Centos Xen调整DomU分区和卷组的大小

我有一个像这样的设置:

Dom0 LV | DomU Physical Disk | | XVDA1 XVDA2 (/boot) (DomU PV) | VolGroup00 (DomU VG) | | LogVol00 LogVol01 (swap) (/) 

我正在尝试调整DomU根文件系统的大小。 (VolGroup00-LogVol01)我意识到我现在需要调整分区XVDA2,但是当我尝试在Dom0上分开时,它只是告诉我“错误:无法检测文件系统”。

所以要调整根部分的大小VolGroup-LogVol00不应该是:

 # Shut down DomU xm shutdown domU #Resize Dom0 Logical volume lvextend -L+2G /dev/volumes/domU-vol # Parted parted /dev/volumes/domU-vol # Resize root partition resize 2 START END (This is where I get an error) "Error: Could not detect file system." # add the vm volume group to Dom0 lvm kpartx -a /dev/volumes/domU-vol # resize the domU PV pvresize /dev/mapper/domU-pl (as listed in pvdisplay) # The domU volume group should automatically adjust # resize the DomU lv lvextend -L+2G /dev/VolGroup/LogVol00 

然后明显增加fs,从kpartx等移除设备

问题是我不知道如何调整分区大小? 如何调整这个分区的大小,以便我可以在DomU上运行pvresize?

谢谢

以下是我粗略遵循的步骤来调整内部使用LVM的KVM来宾的大小。

  1. closuresVM
  2. 给客人的“图像文件”添加更多的空间(如:cat old.img 10G_addon.raw >> new.img
  3. 启动虚拟机(使用新创build的new.img)
  4. 在虚拟机内部运行fdisk并删除并重新创buildLVM分区

     % fdisk /dev/vda ... Device Boot Start End Blocks Id System /dev/vda1 * 1 13 104391 83 Linux /dev/vda2 14 3263 26105625 8e Linux LVM Command (m for help): d Partition number (1-4): 2 Command (m for help): p Disk /dev/vda: 48.3 GB, 48318382080 bytes 255 heads, 63 sectors/track, 5874 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/vda1 * 1 13 104391 83 Linux Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (14-5874, default 14): 14 Last cylinder or +size or +sizeM or +sizeK (14-5874, default 5874): Using default value 5874 Command (m for help): p Disk /dev/vda: 48.3 GB, 48318382080 bytes 255 heads, 63 sectors/track, 5874 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/vda1 * 1 13 104391 83 Linux /dev/vda2 14 5874 47078482+ 83 Linux Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 8e Changed system type of partition 2 to 8e (Linux LVM) Command (m for help): p Disk /dev/vda: 48.3 GB, 48318382080 bytes 255 heads, 63 sectors/track, 5874 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/vda1 * 1 13 104391 83 Linux /dev/vda2 14 5874 47078482+ 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. % 
  5. 重启虚拟机

  6. 调整LVM物理卷的大小

     % pvdisplay --- Physical volume --- PV Name /dev/vda2 VG Name VolGroup00 PV Size 24.90 GB / not usable 21.59 MB Allocatable yes (but full) PE Size (KByte) 32768 Total PE 796 Free PE 0 ... % pvresize /dev/vda2 % pvdisplay --- Physical volume --- PV Name /dev/vda2 VG Name VolGroup00 PV Size 44.90 GB / not usable 22.89 MB Allocatable yes PE Size (KByte) 32768 Total PE 1436 Free PE 640 ... 
  7. 调整LVM逻辑卷的大小

      % lvresize /dev/VolGroup00/LogVol00 -l +640 Extending logical volume LogVol00 to 43.88 GB Logical volume LogVol00 successfully resized 
  8. 增长文件系统

      % resize2fs /dev/VolGroup00/LogVol00 resize2fs 1.39 (29-May-2006) Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required Performing an on-line resize of /dev/VolGroup00/LogVol00 to 11501568 (4k) blocks. The filesystem on /dev/VolGroup00/LogVol00 is now 11501568 blocks long. 

以上是我的例子,但我遵循这个网站上的步骤

所以,为了澄清:你需要调整虚拟机内的根LV的大小,但是VG已经满了,所以你首先需要调整PV所在的物理分区的大小。 假设是正确的,我们继续…

我很惊讶,分手会在这个dom0分区上有这样的窘态。 从它的angular度来看,这只是一个正在使用的LVM PV。 我从来没有特别留下深刻的印象,但是,我只是坚持与好fdisk。

无论如何,在使用磁盘时,您可能无法调整分区的大小,因为在已挂载的文件系统上重新扫描分区表是非常棘手的。 最好closures虚拟机并完成dom0中的所有操作。

我build议完全跳过分区,并用LVM做所有事情; 我也不喜欢虚拟机中的LVM,因为它们的I / O吞吐量足够差。 只需在dom0中为VM中的分区添加一些LV即可 – 这也使得复制更容易,因为您通常不想复制swap(除非您正在进行实时迁移,但是这只是一个更多的块设备无论如何复制)。

resize时也要小心。

看来你遇到麻烦的一步是分手的一步:

http://www.gnu.org/software/parted/manual/html_chapter/parted_7.html#SEC68

注意按照说明,你也可能想在分区上使用fdisk -l,以确保它是你所期望的分区types和文件系统。

其他可以为您或其他人提供帮助的一般参考资料: http : //linuxwave.blogspot.com/2008/08/resizing-your-xen-domu-using-lvm.html

http://www.novell.com/communities/node/4790/how-resize-xen-file-based-disk-vms-ext3-or-reiser-sles-10-sp1

http://webcache.googleusercontent.com/search?q=cache:jNh6rSBUqVEJ:grantmcwilliams.com/tech/virtualization/xen-howtos/265-resize-xen-disk-image-used-as-domu-partition+grant+麦克威廉斯+ Xen的+调整+ DIY和CD = 4&HL = EN&CT = clnk&GL =我们