My Ubuntu 14.04 is running as a Hyper-V guest. So far it had a 140 GB extra virtual "data" disk (in addition to the main Ubuntu OS image). I have now resized the disk in Hyper-V to 200 GB. How do I extend the LVM volume that has been created on this disk to take up all available space if the volume has been created on a raw device (without partitioning the device first and adding the disk partition to LVM)? All answers I could find come from the assumption that the device has been partitioned and a partition has been added to LVM (an now a new partition can be created and added to LVM again).
The way the volume has been set up:
# pvcreate /dev/sdb
# vgextend ubuntubase-vg /dev/sdb
# lvcreate -n lvol0 -L 140G ubuntubase-vg
# mkfs.ext4 /dev/mapper/ubuntubase--vg-lvol0
fdisk
already shows that /dev/sdb
has an updated size of 200 GB, but no partitions:
Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
pvdisplay
still shows the old 140GB:
--- Physical volume ---
PV Name /dev/sdb
VG Name ubuntubase-vg
PV Size 140.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 35839
Free PE 0
Allocated PE 35839
PV UUID XZ2sei-NRnA-IzF1-EQAK-fq9m-VTHS-Q0zRx6
This should extend the physical volume to use up all the available space on the disk:
pvresize /dev/sdb
See man 8 pvresize
.
After that you have to resize the logical volume:
lvextend -l +100%FREE /dev/ubuntubase-vg/lvol0
And extend the filesystem:
resize2fs /dev/ubuntubase-vg/lvol0
No comments:
Post a Comment