在 CentOS 6 上扩展分区

在 CentOS 6 上扩展分区

我有一个 VPS,似乎某个地方缺少空间。它应该是 150GB,但只有 50GB。我一直在尝试扩展分区,但即使在指南的帮助下,我似乎也找不到方法。

这是在 CentOS 6 上安装有 Plesk 11 的 VPS。

任何指导都将不胜感激。我想将所有剩余空间用于 vda2 分区。

[root@www ~]# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda                         252:0    0  150G  0 disk
├─vda1                      252:1    0  500M  0 part /boot
└─vda2                      252:2    0 49.5G  0 part
  ├─vg_plesk-lv_root (dm-0) 253:0    0   48G  0 lvm  /
  ├─vg_plesk-lv_swap (dm-1) 253:1    0    1G  0 lvm  [SWAP]
  └─vg_plesk-lv_tmp (dm-2)  253:2    0  512M  0 lvm  /tmp

[root@www ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_plesk" using metadata type lvm2

[root@www ~]# lvm vgdisplay
  --- Volume group ---
  VG Name               vg_plesk
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               49.51 GiB
  PE Size               4.00 MiB
  Total PE              12674
  Alloc PE / Size       12674 / 49.51 GiB
  Free  PE / Size       0 / 0
  VG UUID               8Hsz6T-yQVv-GerB-32Qe-ZvIQ-BQvA-uYqft5

(parted) print all
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/vg_plesk-lv_tmp: 537MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size   File system  Flags
 1      0.00B  537MB  537MB  ext4


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/vg_plesk-lv_swap: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system     Flags
 1      0.00B  1074MB  1074MB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/vg_plesk-lv_root: 51.5GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0.00B  51.5GB  51.5GB  ext4


Model: Virtio Block Device (virtblk)
Disk /dev/vda: 161GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  525MB   524MB   primary  ext4         boot
 2      525MB   53.7GB  53.2GB  primary               lvm

添加的输出:

[root@www ~]# fdisk -l

Disk /dev/vda: 161.1 GB, 161061273600 bytes
16 heads, 63 sectors/track, 312076 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00034f7d

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018      104026    51915776   8e  Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/vg_plesk-lv_root: 51.5 GB, 51547996160 bytes
255 heads, 63 sectors/track, 6267 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: 0x00000000


Disk /dev/mapper/vg_plesk-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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: 0x00000000


Disk /dev/mapper/vg_plesk-lv_tmp: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 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: 0x00000000

[root@www ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               vg_plesk
  PV Size               49.51 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              12674
  Free PE               0
  Allocated PE          12674
  PV UUID               oFD1tJ-wJt1-MlBK-NKfq-4MMF-ZUCG-kZQZVx

我似乎无法找出这 100GB 的免费空间在哪里或如何分配它。

答案1

好的,这些命令很重要;

首先执行“fdisk -l”,查看列出的内容,然后执行“pvdisplay”查看 PV 的布局方式,有可能磁盘上有未分区的空间(在这种情况下只需创建一个类型为“8e”的新分区,然后将其添加到 PV,扩展 VG,然后扩展 LV)或者它在 PV 中但不在 VG 中,在这种情况下只需扩展 VG,然后扩展 LV。

编辑-根据您的输出,您需要做的是,以root/sudo身份输入;

fdisk /dev/fda

fdisk 应用程序将启动,输入“n”并回车,您将看到;

Command action
   e   extended
   p   primary partition (1-4)

输入“p”

然后会要求你输入分区号,输入 3(三),按 Enter

Partition number (1-4): 3

然后会要求您输入第一个圆柱体,只需接受系统上弹出的任何内容(不是下面的值,这只是为了向您展示它的样子);

First cylinder (197-621, default 197):<RETURN>
Using default value 197

然后它会询问最后一个圆柱体,同样只需接受它抛出的任何内容,而不是我下面的示例

Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M

现在输入“p”并回车显示分区表,它看起来应该像这样;

   Device Boot    Start       End    Blocks   Id  System
/dev/vda1             1       196    395104   8e  LVM
/dev/vda2           197       262    133056   8e  LVM
/dev/vda3           197       262    133056   8e  Linux

现在输入“t”并回车,首先会要求您输入分区号,您的分区号是 3(三),按回车键,然后会要求您输入分区类型代码,您的分区号是“8e”(表示 LVM),按回车键,它看起来应该像这样;

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (LVM)   

现在输入“p”并再次输入,输出应该看起来像这样;

   Device Boot    Start       End    Blocks   Id  System
/dev/vda1             1       196    395104   8e  LVM
/dev/vda2           197       262    133056   8e  LVM
/dev/vda3           197       262    133056   8e  LVM

现在输入“w”来写出此配置,您将返回到 shell 提示符,然后可以像往常一样扩展 PV、VG 和 LV。

相关内容