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(三),按Enter 鍵,然後系統會要求您輸入分區類型代碼,您的是「8e」(這意味著LVM ),按 Enter 鍵,它應該看起來像這樣;

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。

相關內容