Extend LVM Volume - How to use parted to extend physical volume?
Sebastian Wright
I have a cloud server running Ubuntu 14.04 being hosted by fasthosts. I recently upgraded the storage from 100GB to 110GB however when i run df i can see this currently isn't being used by the filesystem
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 483M 4.0K 483M 1% /dev
tmpfs 99M 688K 99M 1% /run
/dev/dm-0 99G 87G 7.4G 93% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 494M 8.0K 494M 1% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 232M 79M 137M 37% /bootI understand i need to extend my physical volumes to use them with LVM
$ sudo pvdisplay --- Physical volume --- PV Name /dev/sda5 VG Name VolGroup00 PV Size 49.76 GiB / not usable 2.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12738 Free PE 0 Allocated PE 12738 PV UUID 6Oa34y-MFIr-KFy1-7TUB-liRV-d6vn-qnlWZ9 --- Physical volume --- PV Name /dev/sda6 VG Name VolGroup00 PV Size 50.00 GiB / not usable 3.97 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12799 Free PE 0 Allocated PE 12799 PV UUID DIwQMv-vFaL-dih4-OE2R-bwRp-XfUd-etDeWoI tried extending my second partition to the end of the disk space to use it with LVM but this hasn't worked.
(parted) print free
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 118GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 256MB 255MB primary ext4 boot 256MB 257MB 1048kB Free Space 2 257MB 118GB 118GB extended 5 257MB 53.7GB 53.4GB logical lvm 6 53.7GB 107GB 53.7GB logical lvm 107GB 118GB 10.6GB Free Space 118GB 118GB 112MB Free SpaceShould i create a new partition or is there a way to extend partition 6 to use the extra space?
output to pvs;vgs;lvs
$ sudo pvs && sudo vgs && sudo lvs PV VG Fmt Attr PSize PFree /dev/sda5 VolGroup00 lvm2 a-- 49.76g 0 /dev/sda6 VolGroup00 lvm2 a-- 50.00g 0 VG #PV #LV #SN Attr VSize VFree VolGroup00 2 1 0 wz--n- 99.75g 0 LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert LogVol00 VolGroup00 -wi-ao--- 99.75g 3 1 Answer
It may be a little late but I want to explain as a RedHat user.
You should create a physical volume with the pvcreatecommand, in your case
$ pvcreate /dev/sda7You have /dev/sda6 as your last physical volume which means you can create new physical volume as/dev/sda7.
and then extend your volume group to have free space with vgextend VolumeGroupName /created/part and vgdisplay VolumeGroupName to check free space
$ vgextend VolGroup00 /dev/sda7 $ vgdisplay VolGroup00 and then you can extend your lvm partition(/dev/sda6).
Physical volumes are combined into volume groups and volume groups are divided up into logical volumes.
To extend logical volume you need to have free space in your volume group. To have free space in your volume group you need a free partition which is a physical partition to extend your volume group.
Logical Volume operations are nearly same for lots of distributions.
2