5

I have a vm test installation of a linux running a build server. Unfortunately I just pressed ok when adding the disk and ended up with an 8gb drive to play with. Well into the test the builds are consuming more and more space, of course.

The vm drive was resized to 21gb and using gparted I expanded the drive partitions and that all worked fine but when I go back into the console and do df there's still only 8gb available.

How can I claim the other 13gb I added?

fdisk -l

Disk /dev/sda: 21.0 GB, 20971520000 bytes
255 heads, 63 sectors/track, 2549 cylinders, total 40960000 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: 0x0006d284

Device    Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    40959999    20229121    5  Extended
/dev/sda5          501760    40959999    20229120   8e  Linux LVM

vgdisplay

--- Volume group ---
VG Name               ct
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  4
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               19.29 GiB
PE Size               4.00 MiB
Total PE              4938
Alloc PE / Size       1977 / 7.72 GiB
Free  PE / Size       2961 / 11.57 GiB
VG UUID               MwiMAz-52e1-iGVf-eL4f-P5lq-FvRA-L73Sl3

lvdisplay

  --- Logical volume ---
LV Name                /dev/ct/root
VG Name                ct
LV UUID                Rfk9fh-kqdM-q7t5-ml6i-EjE8-nMtU-usBF0m
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                5.73 GiB
Current LE             1466
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:0

--- Logical volume ---
LV Name                /dev/ct/swap_1
VG Name                ct
LV UUID                BLFaa6-1f5T-4MM0-5goV-1aur-nzl9-sNLXIs
LV Write Access        read/write
LV Status              available
# open                 2
LV Size                2.00 GiB
Current LE             511
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:1
Asken
  • 215
  • 1
  • 2
  • 8
  • Please paste the vgdisplay output and lvdisplay ... if your lvm see now new free physical extends then you only have to extend lvm volume and do resize2fs ... – B14D3 Jul 02 '13 at 07:05
  • @B14D3 added... – Asken Jul 02 '13 at 07:11
  • You have Free PE / Size 2961 / 11.57 GiB wait I will update my answere – B14D3 Jul 02 '13 at 07:29
  • You're almost there - you need to resize the filesystem on your partition (I assume it's on /dev/sda5) as well (This is well documented on the 'net). – Roman Jul 02 '13 at 06:50

1 Answers1

10

You resized the partition now you have to resize lvm and file system ... You can do that with pvextend and resize2fs read the manual do backup use with consideration... :)

All you have to do is extend proper lvm volume in your case I think /dev/ct/root with you new free pe (phisical extends). You can see all volumes using lvdisplay and extend proper one with command

lvextend -l +2961 /dev/ct/root

after that you must extend your file system with command resize2fs -p /dev/ct/root

That's all! You can do this on working filesystem even when its mounted (WARNING I have never do that on root partition / so I can't give you any warranty about this tutorial )

Asken
  • 215
  • 1
  • 2
  • 8
B14D3
  • 5,110
  • 13
  • 58
  • 82
  • 2
    Dude, your answer reads like a squirrel on speed wrote it. – Roman Jul 02 '13 at 07:09
  • 1
    @Roman Still better then your answere "go search in google" :P – B14D3 Jul 02 '13 at 07:36
  • @B14D3. It was just 'lvextend -l +2961 /dev/ct/root' but otherwise worked fine! Edited the answer... jesus how annoying that I needed to edit 6 characters :) – Asken Jul 02 '13 at 09:35
  • Same problem here; needed both lvextend and resize2fs (VM was Oracle VirtualBox, OS is CentOS 5, used gParted like the OP for the partition work). Thanks, B14D3! – Kevin_Kinsey Sep 28 '15 at 15:33