克隆磁盘后调整LVM大小

我已经将一个160Gb磁盘克隆到1TB磁盘上。

看到这里的确切的细节。 克隆Ubuntu的Linux硬盘

我想要使​​用整个磁盘。

我如何获得卷使用整个磁盘。

在前面的post里有一些build议,我已经search了一下,但是我不确定什么是最好的前进方向。

谢谢

$ sudo fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xd42ad42a Device Boot Start End Blocks Id System /dev/sda1 * 1 19426 156039313+ 8e Linux LVM /dev/sda2 19427 19457 249007+ 5 Extended /dev/sda5 19427 19457 248976 83 Linux Disk /dev/sdb: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2c9c2c9b Device Boot Start End Blocks Id System /dev/sdb1 1 19457 156288321 83 Linux $ sudo pvdisplay --- Physical volume --- PV Name /dev/sda1 VG Name AO-0023 PV Size 148.81 GiB / not usable 2.14 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 38095 Free PE 0 Allocated PE 38095 PV UUID 9QOBa4-SKHd-P82d-LDi7-gYh6-6hT8-2eezF1 --- Physical volume --- PV Name /dev/sdb1 VG Name AO-0023 PV Size 149.05 GiB / not usable 1.31 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 38156 Free PE 0 Allocated PE 38156 PV UUID yeBtIS-UrEE-9Is8-QkEC-Rzl3-s7RL-gVvReI ~$ sudo lvdisplay --- Logical volume --- LV Name /dev/AO-0023/root VG Name AO-0023 LV UUID rc2Nwi-gxSQ-S2lZ-GOS1-af2g-mSR9-rAYsCm LV Write Access read/write LV Status available # open 1 LV Size 143.12 GiB Current LE 36640 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:0 --- Logical volume --- LV Name /dev/AO-0023/swap_1 VG Name AO-0023 LV UUID CzZtTB-hpDT-G7co-OvZ7-Xa4K-IpOq-tyuz1H LV Write Access read/write LV Status available # open 1 LV Size 5.68 GiB Current LE 1455 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:1 --- Logical volume --- LV Name /dev/AO-0023/copy VG Name AO-0023 LV UUID kKpe1x-OtsI-vvJu-t5Ei-jhOt-ufLC-s1GsRh LV Write Access read/write LV Status available # open 1 LV Size 149.05 GiB Current LE 38156 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:2 $ sudo vgdisplay --- Volume group --- VG Name AO-0023 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 2 Act PV 2 VG Size 297.86 GiB PE Size 4.00 MiB Total PE 76251 Alloc PE / Size 76251 / 297.86 GiB Free PE / Size 0 / 0 VG UUID J4wgRy-EaDi-07A0-0Wyc-6IOG-dt82-Pdcics 

您可以通过以下方式增长L​​VM:

  • 调整底层块设备的大小并运行pvresize
  • 将额外的PV添加到您的卷组。

上面的磁盘信息有点不清楚,所以我会忽略它,给你一个程序的一般描述。 如果你的1TB磁盘是空的,除了LVM分区,那么你可以简单地:

  • 使用fdisk来增加分区的大小
  • 使用pvresize增长LVM PV以匹配分区的大小。

如果您将磁盘上的LVM PV与其他分区混合,请不要这样做。 但是如果坚持,可以创build一个覆盖额外空间的额外分区,然后将其添加到卷组中:

  • pvcreate /dev/sd??
  • vgextend vg0 /dev/sd??