Lvm – Extending partition on centos 6

centos6lvmpartition

I have a VPS which appeared to lack some space somewhere. It should've been 150GB but was only 50GB. I've been trying to extend the partition but I can't seem to find out how even with the help of guides.

It's a VPS installed with Plesk 11 on CentOS 6.

Any guidance would be appreciated. I would like to use all the space remaining into the vda2 partition.

[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

Added output:

[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

I can't seem to find out where this free 100GB of space is or how to allocate it.

Best Answer

Ok, there are the commands that matter;

Firstly do an 'fdisk -l', see what's listed, then do a 'pvdisplay' to see how your PVs are laid out, chances are that either the disk has unpartitioned space on it (in which case just create a new partition with a type of '8e', then add it to the PV, extend the VG and then extend the LV) or it's in the PV but not the VG, in which case just extend the VG and then extend the LV.

EDIT - based on your output what you need to do is this, all as root/sudo, type;

fdisk /dev/fda

The fdisk application will start, type 'n' and enter, you'll see;

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

Type 'p'

You'll then be asked for your partition number, this will be 3 (three), press enter

Partition number (1-4): 3

You'll then be asked for the first cylinder, just accept whatever pops up on your system (not the value below, that's just to show you what it looks like);

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

It will then ask for the last cylinder, again just accept whatever it throws up not my example below

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

Now type 'p' and enter to show the partition table, it should look something like this;

   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

Now type 't' and enter, you'll be asked for the partition number first, yours is 3 (three), press enter, you'll then be asked for the partition type code, yours is '8e' (which means LVM), press enter and it should look something like this;

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)   

Now type 'p' and enter again and the output should look something like this;

   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

Now type 'w' to write out this configuration and you'll be back at your shell prompt and can then extend the PV, VG and LV as usual.

Related Topic