How can I resize an active LVM partition?
I am quite new to LVM and I'm uncertain about what is happening here. I was not the one to initially setup this machine.
There is a harddrive of 1tb in size and an LVM partition of only 50gb in size. I can not figure out how I can use the remaining space of the harddrive.
output of command df -h
:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-slash 46G 1.4G 42G 4% /
udev 3.9G 4.0K 3.9G 1% /dev
tmpfs 1.6G 236K 1.6G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
/dev/sda1 232M 29M 191M 14% /boot
output of command fdisk -l
:
Disk /dev/sda: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders, total 2147483648 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: 0x00038096
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 104855551 52176897 5 Extended
/dev/sda5 501760 104855551 52176896 8e Linux LVM
Disk /dev/mapper/vg00-swap: 3997 MB, 3997171712 bytes
255 heads, 63 sectors/track, 485 cylinders, total 7806976 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/mapper/vg00-swap doesn't contain a valid partition table
Disk /dev/mapper/vg00-slash: 49.4 GB, 49429872640 bytes
255 heads, 63 sectors/track, 6009 cylinders, total 96542720 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/mapper/vg00-slash doesn't contain a valid partition table
What I assume I had to do, was create a new partition on /dev/sda to contain the remaining space but when trying to create a new primary partition I am told I can't.
Last sector, +sectors or +size{K,M,G} (499712-501757, default 501757): +800G
Value out of range.
I do not know what I can do now...
When trying to resize the logical volume I get:
# lvresize vg00/slash -L +800g
Extending logical volume slash to 846.04 GiB
Insufficient free space: 204800 extents needed, but only 0 available
# pvdisplay -m
--- Physical volume ---
PV Name /dev/sda5
VG Name vg00
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 WNZba3-bCCs-NmqL-Bc9v-zusy-TtfQ-BpAj3e
--- Physical Segments ---
Physical extent 0 to 952:
Logical volume /dev/vg00/swap
Logical extents 0 to 952
Physical extent 953 to 12737:
Logical volume /dev/vg00/slash
Logical extents 0 to 11784
(parted) print free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 1100GB
Sector size (logical/physical): 512B/512B
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 53.7GB 53.4GB extended
5 257MB 53.7GB 53.4GB logical lvm
53.7GB 1100GB 1046GB Free Space
Most of the disk is in an LVM partition already, which lvm calls a physical volume. LVM then divides up the space from physical volumes into logical volumes. You can use the pvs
or pvdisplay
commands to show stats on the physical volumes and lvs
or lvdisplay
to see information on all of the logical volumes. You should see that there is plenty of free space in the physical volume. You then can use lvresize
to expand a logical volume to use more of the space, as in:
sudo lvresize vg00/slash -L +10g
That will add 10 gb to the logical volume named slash in the volume group vg00, which is apparently your root volume. After that, you need to expand the filesystem to use that space, which assuming you are using the default ext4 filesystem with:
sudo resize2fs /dev/mapper/vg0-slash
lvdisplay
gave me :
--- Logical volume ---
LV Path /dev/VolGroup/lv_root
then
sudo lvextend -L+10g /dev/VolGroup/lv_root
sudo resize2fs /dev/VolGroup/lv_root
solved my problem