回收 fdisk 未显示但在 parted 中显示的 100GB 磁盘空间

回收 fdisk 未显示但在 parted 中显示的 100GB 磁盘空间

我正在运行 Ubuntu 14.04,并使用 lvm 作为根分区和交换分区。当我使用 parted (或 gparted) 时,我在 /dev/sda 上看到 110GB 未分区。

hari@Ubuntu02:~$ sudo parted /dev/sda unit GB print free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 3408GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
        0.00GB  0.00GB  0.00GB            Free Space
 1      0.00GB  0.26GB  0.25GB  primary   ext2         boot
        0.26GB  0.26GB  0.00GB            Free Space
 2      0.26GB  805GB   805GB   extended
 5      0.26GB  805GB   805GB   logical                lvm
 3      805GB   1636GB  831GB   primary                lvm
 4      1636GB  3299GB  1662GB  primary                lvm
        3299GB  3408GB  110GB             Free Space

但是,当我使用 fdisk 创建分区时,它没有显示这个可用空间。

hari@Ubuntu02:~$ sudo fdisk -l /dev/sda

Disk /dev/sda: 3408.5 GB, 3408486045696 bytes
255 heads, 63 sectors/track, 414391 cylinders, total 6657199308 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d989d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758  1572861951   786180097    5  Extended
/dev/sda3      1572861952  3196057599   811597824   8e  Linux LVM
/dev/sda4      3196057600  6442450943  1623196672   8e  Linux LVM
/dev/sda5          501760  1572861951   786180096   8e  Linux LVM

看起来可用空间从扇区 6442450943 开始一直到扇区 6657199308。

我天真地尝试了 lvextend,但它给了我以下消息。

hari@Ubuntu02:~$ sudo lvextend -L+100G /dev/ubuntu-vg/root
  Extending logical volume root to 3.63 TiB
  Insufficient free space: 25600 extents needed, but only 2 available

鉴于 /dev/sda2 是我唯一的逻辑卷,并且可用扇区位于 /dev/sda5 之后,我该如何使用 parted 、 fdisk 和 lv- 命令回收 110GB 未分区空间并将其添加到我的 lvm 卷组。

答案1

我通过四个步骤成功恢复了那 100GB

Mounted a new Disk (/dev/sdc) with same size as incompletely used
disk (/dev/sda4) and used pvcreate and lvextend to add it as a
logical volume to the LVM volume group 

I used pvmove to move the data from /dev/sda4 . This took ~16 hrs
but was seamless. It automagically moved it to new /dev/sdc volume
and then showed that /dev/sda4 was unused.   I pvremoved the
/dev/sda4 from the volume group 

I used fdisk to remove the existing partition and repartitioned the
space using gparted. 

I added this volume to the volume group( pvcrate and lvextend) and
then was able to use up all size with a sudo lvresize -r -l
+100%FREE /dev/ubuntu-vg/root 

This added back that 100GB which was not incorporated into the
partition and also the volume-group.

相关内容