I VM Player running a linux guest and I was wanting to know how do I expand the disk? In the VM player I gave more disk space but I am not sure how to mount/expand/connect the new disk space to the system.
My old disk space was 14GB
[root@localhost ~]# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
14G 4.5G 8.2G 36% /
Then I expanded it and now I see sda2 which is the new space?
[root@localhost ~]# fdisk -l
Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd44d
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 14.5 GB, 14537457664 bytes
255 heads, 63 sectors/track, 1767 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 6408 MB, 6408896512 bytes
255 heads, 63 sectors/track, 779 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Do I need to mount the new space first?
resize2fs -p /dev/mapper/VolGroup-lv_root 108849018880
resize2fs 1.41.12 (17-May-2010)
The containing partition (or device) is only 3549184 (4k) blocks.
You requested a new size of 1474836480 blocks.
resize2fs -p /dev/mapper/VolGroup-lv_root 128849018880
resize2fs 1.41.12 (17-May-2010)
resize2fs: Invalid new size: 128849018880
[root@localhost ~]# lvextend -L+90GB /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 103.54 GiB
Insufficient free space: 23040 extents needed, but only 0 available
[root@localhost ~]# lvextend -L90GB /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 90.00 GiB
Insufficient free space: 19574 extents needed, but only 0 available
EDIT:
So after trying pvcreate/vgextend nothing has so far worked. I'm guessing the new disk space added from VM Player is not showing up?
pvscan
PV /dev/sda2 VG VolGroup lvm2 [19.51 GiB / 0 free]
Total: 1 [19.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 0 [0 ]
Best Answer
As already stated, you had first to resize the partition containing the logical volume, than you can proceed with LVM resize. Follow these steps:
fdisk -l -u /dev/sda
take note of the current partition setting (especially the start sector)partprobe /dev/sda
or reboot the system. This will inform the kernel that partition size has changedpvresize /dev/sda2
. This will resize the physical volume structurespvs
andvgs
to check that the new size is correctly identified by LVMlvresize -l +100%FREE /dev/mapper/VolGroup-lv_root
resize2fs /dev/mapper/VolGroup-lv_root
These instruction are valid for increasing disk space (extending the volume)
Shrinking a volume is conceptually similar but you had to follow the steps backward, starting with filesystem shrink. As a side note, if you use XFS or other filesystems that can not be shrunk, you can not resize your LVM volume without a backup/restore process.