克隆磁盘后调整 LVM 大小

克隆磁盘后调整 LVM 大小

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

请参阅此处了解详细信息。 克隆 ubuntu linux 硬盘

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

我如何让卷使用整个磁盘。

上一篇文章中有一些建议,我也在 Google 上搜索过,但我不确定什么是最好的前进方式。

谢谢

$ 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

答案1

您可以通过以下方式扩展 LVM:

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

上面的磁盘信息有点不清楚,所以我将忽略它并向您提供该过程的一般描述。如果您的 1TB 磁盘除了 LVM 分区外是空的,那么您可以简单地:

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

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

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

相关内容