0

I've cloned and resized a disk image for VirtualBox but I can't find a way to use all the new space. this is how I started:

fdisk:

Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders, total 157286400 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: 0x00034aae

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

lvdisplay:

  --- Logical volume ---
  LV Path                /dev/localhost/root
  LV Name                root
  VG Name                localhost
  LV UUID                tbJqka-ZlYQ-nkq4-Cufz-Yl7t-peSL-z1FGpR
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-04-16 21:15:12 +0200
  LV Status              available
  # open                 1
  LV Size                18.91 GiB
  Current LE             4840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

  --- Logical volume ---
  LV Path                /dev/localhost/swap_1
  LV Name                swap_1
  VG Name                localhost
  LV UUID                3yEDBL-Nc0G-QuVU-M9iR-Pe3u-r6E4-A5egVb
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-04-16 21:15:12 +0200
  LV Status              available
  # open                 2
  LV Size                872.00 MiB
  Current LE             218
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

so, I have now removed the sda2 partition and created a new one as following (this is after reboot):

Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders, total 157286400 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: 0x00034aae

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          499712   157286399    78393344    5  Extended
/dev/sda5          501760   157286399    78392320   8e  Linux LVM

so, what should I do now in order to increase the LVM group and then resize to 100%FREE?

thanks!

1 Answer 1

0

found the solution myself, after the above:

vgdisplay
  --- Volume group ---
  VG Name               localhost
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  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.76 GiB
  PE Size               4.00 MiB
  Total PE              5058
  Alloc PE / Size       5058 / 19.76 GiB
  Free  PE / Size       0 / 0
  VG UUID               XgGBDt-lHmJ-3Tci-hKW6-IRFU-PxN2-wsJmek

and then:

pvresize /dev/sda5
  Physical volume "/dev/sda5" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
root@host:/home/vagrant# vgdisplay
  --- Volume group ---
  VG Name               localhost
  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               74.76 GiB
  PE Size               4.00 MiB
  Total PE              19138
  Alloc PE / Size       5058 / 19.76 GiB
  Free  PE / Size       14080 / 55.00 GiB
  VG UUID               XgGBDt-lHmJ-3Tci-hKW6-IRFU-PxN2-wsJmek

root@host:/home/vagrant# vgdisplay
  --- Volume group ---
  VG Name               localhost
  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               74.76 GiB
  PE Size               4.00 MiB
  Total PE              19138
  Alloc PE / Size       5058 / 19.76 GiB
  Free  PE / Size       14080 / 55.00 GiB
  VG UUID               XgGBDt-lHmJ-3Tci-hKW6-IRFU-PxN2-wsJmek

root@host:/home/vagrant# lvextend -l +100%FREE /dev/localhost/root
  Extending logical volume root to 73.91 GiB
  Logical volume root successfully resized

root@host:/home/vagrant# resize2fs /dev/localhost/root
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/localhost/root is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 5
Performing an on-line resize of /dev/localhost/root to 19374080 (4k) blocks.
The filesystem on /dev/localhost/root is now 19374080 blocks long.

root@host:/home/vagrant# df -lah
Filesystem                  Size  Used Avail Use% Mounted on
rootfs                       73G   18G   52G  26% /

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .