Increase disk space in the VM - RubinLab/epad-ws GitHub Wiki
referenced from https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk/
Follow the commands below to increase the home partition in the centos 6 vM distributed for ePAD
- Take a snapshot of the vm for backup
fdisk -l
See the information about the disk and check the disk space /dev/sda1 (linux) is the boot partition we will extend the other, /dev/sda2 make sure it is Linux LVM- Shut down vm to be able to change the disk size
- Increase the disk space in vmware
- Start the VM
- Run
fdisk -l
again and verify the disk space is increased - Create a new partition using fdisk
fdisk /dev/sda
- Select βnβ for adding a new partition.
Command (m for help): n
- Select βpβ as we are making a primary partition.
Command action
`l logical (5 or over)`
`p primary partition (1-4)`
p
- As we already have /dev/sda1 and /dev/sda2 , use β3β for this new partition which will be created as /dev/sda3
Partition number (1-4): 3
- We just press enter twice above as by default the first and last cylinders of the unallocated space should be correct. After this the partition is then ready.
First cylinder (2611-3916, default 2611): "enter"
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916): "enter"
Using default value 3916
- Select βtβ to change to a partitionβs system ID, in this case we change to β3β which is the one we just created.
Command (m for help): t
Partition number (1-5): 3
- The hex code β8eβ was entered as this is the code for a Linux LVM which is what we want this partition to be, as we will be joining it with the original /dev/sda2 Linux LVM.
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
- Type βwβ to write the table to disk and exit, basically all the changes that have been done will be saved and then you will be exited from fdisk.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
- Reboot
- Create the physical drive
pvcreate /dev/sda3
- See the volume group
vgdisplay
Use the name of the volume group to extend, it should be vg_epaddev for the ePAD centos 6 VM - Add new partition to the volume group
vgextend vg_epaddev /dev/sda3
- Confirm the partition is created and added to the volume group
pvscan
- Confirm the path. It should be /dev/mapper/vg_epaddev-lv_home for the ePAD centos 6 VM
lvdisplay
- Extend the logical drive with the new space
lvextend /dev/mapper/vg_epaddev-lv_home /dev/sda3
- Resize the logical volume
resize2fs /dev/mapper/vg_epaddev-lv_home
- Check the disk space
df -h
It should show extended storage