Extending a partition in ubuntu 14 [closed]
Solution 1:
sda5
is a logical partition. It resides within the Extended partition (sda2
). I'm assuming this is an older machine/install using Master Boot Record (MBR). Even under MBR, the Extended partition isn't really necessary. Having a Primary/Extended/Logical partition was for backwards comparability with earlier versions of DOS/Windows (Linux supports 4 primary partitions on MBR where DOS/Win95 only supported primary/extended, and newer GPT partitions elimination the limitations entirely).
/dev/mapper/webserver--vg-root
is a logical volume, that resides within sda5
. Logical volumes are used to abstract away the underlying disk. You can use vgdisplay
to display the volume group (there should be one) and lvdisplay
to list the individual volumes within that group (you should have two, one for swap and the other for root).
Did you copy your partitions to a larger hard drive? If so, you would need to adjust sda2
and sda5
to have the same start block, but a new ending block (the end of the disk). You can do that with fdisk
by deleting and recreating the partition. After this is done, vgextend
can be used on the entire volume group to extend it to the end of the partition. You can then use the various lv*
commands (lvdisplay
, lvextend
, etc.) to extend or move around the individual volumes.
Be sure to backup all your data before changing partitions or volume groups
The following set of commands should work for your situation. You may have to install parted
. Alternatively, you could install cloud-utils
and use the growpart
command:
# via parted
parted /dev/sda resize 2 100%
parted /dev/sda resize 5 100%
# OR using cloud-utils / growpart
growpart /dev/sda 2
growpart /dev/sda 5
# Then have Linux re-read your partition talbe
partprobe /dev/sda
# Then expand your Physical Volume
pvresize /dev/sda5
# Extend the logical root volume
lvextend -l +100%FREE /dev/webserver-vg/root
# Extend the filesystem (assuming you're using ext2/3/4)
resize2fs /dev/webserver-vg/root