Ubuntu: 12.04 LTS
VMware ESXi: 5.5

I wanted increase the store on one partition by 100GB to 250GB on a system and minimize down time. I was almost able to pull it off. I need one quick reboot to get the new size to show up.

With the system up, I used the vSphere client and modifed the size of the disk.

root@myhostname~:# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_myhostname_subdir-lv_subdir 148G 125G 16G 90% /mountpt/subdir

root@myhostname~:# mount | grep subdir
/dev/mapper/vg_myhostname_subdir-lv_subdir on /mountpt/subdir type ext4 (rw)

root@myhostname~:# fdisk -l

Disk /dev/sde: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders, total 314572800 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: 0x00000000

Disk /dev/sde doesn’t contain a valid partition table

Scan for new hardware or changes:

root@myhostname~:# echo “- – -” > /sys/class/scsi_host/host0/scan
root@myhostname~:# echo “- – -” > /sys/class/scsi_host/host1/scan
root@myhostname~:# echo “- – -” > /sys/class/scsi_host/host2/scan

Still didn’t show up with the new size:

root@myhostname~:# pvdisplay
— Physical volume —
PV Name /dev/sde
VG Name vg_myhostname_subdir
PV Size 150.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 38399
Free PE 0
Allocated PE 38399
PV UUID dkK9oP-XQq2-p2CM-BVBZ-pv0r-J9cP-Hnc0UB

I rebooted at this point.

root@myhostname:~# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xeeb3e856.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sde: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders, total 524288000 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: 0xeeb3e856

Device Boot Start End Blocks Id System

Command (m for help): quit

root@myhostname:~# pvdisplay
— Physical volume —
PV Name /dev/sde
VG Name vg_myhostname_subdir
PV Size 150.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 38399
Free PE 0
Allocated PE 38399
PV UUID dkK9oP-XQq2-p2CM-BVBZ-pv0r-J9cP-Hnc0UB

Resize physical volume to reflect the new size:

root@myhostname:~# pvresize /dev/sde
Physical volume “/dev/sde” changed
1 physical volume(s) resized / 0 physical volume(s) not resized

root@myhostname:~# pvdisplay /dev/sde
— Physical volume —
PV Name /dev/sde
VG Name vg_myhostname_subdir
PV Size 250.00 GiB / not usable 3.81 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 63999
Free PE 25600
Allocated PE 38399
PV UUID dkK9oP-XQq2-p2CM-BVBZ-pv0r-J9cP-Hnc0UB

Interestingly, the volume group updated with the new size:

root@myhostname:~# vgdisplay
— Volume group —
VG Name vg_myhostname_subdir
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 250.00 GiB
PE Size 4.00 MiB
Total PE 63999
Alloc PE / Size 38399 / 150.00 GiB
Free PE / Size 25600 / 100.00 GiB
VG UUID QNgKYt-ueHo-hq54-kvWB-HRcd-3Guq-yfBwhu

However, the logical volume did not:

root@myhostname:~# lvdisplay
— Logical volume —
LV Name /dev/vg_myhostname_subdir/lv_subdir
VG Name vg_myhostname_subdir
LV UUID D4xZEe-yAfH-pJoH-51Na-5l2B-Baqu-b37tOw
LV Write Access read/write
LV Status available
# open 1
LV Size 150.00 GiB
Current LE 38399
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 252:1

So, I had to extend it:

root@myhostname:~# lvextend /dev/vg_myhostname_subdir/lv_subdir /dev/sde
Extending logical volume lv_subdir to 250.00 GiB
Logical volume lv_subdir successfully resized

root@myhostname:~# lvdisplay
— Logical volume —
LV Name /dev/vg_myhostname_subdir/lv_subdir
VG Name vg_myhostname_subdir
LV UUID D4xZEe-yAfH-pJoH-51Na-5l2B-Baqu-b37tOw
LV Write Access read/write
LV Status available
# open 1
LV Size 250.00 GiB
Current LE 63999
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 252:1

Now, to resize the filesystem:

root@myhostname:~# resize2fs /dev/mapper/vg_myhostname_subdir-lv_subdir
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/mapper/vg_myhostname_subdir-lv_subdir is mounted on /mountpt/subdir; on-line resizing required
old_desc_blocks = 10, new_desc_blocks = 16
The filesystem on /dev/mapper/vg_myhostname_subdir-lv_subdir is now 65534976 blocks long.

Success:

root@myhostname:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_myhostname_subdir-lv_subdir 247G 125G 110G 54% /mountpt/subdir