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

  1. Take a snapshot of the vm for backup
  2. 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
  3. Shut down vm to be able to change the disk size
  4. Increase the disk space in vmware
  5. Start the VM
  6. Run fdisk -l again and verify the disk space is increased
  7. 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.

  1. Reboot
  2. Create the physical drive pvcreate /dev/sda3
  3. 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
  4. Add new partition to the volume group vgextend vg_epaddev /dev/sda3
  5. Confirm the partition is created and added to the volume group pvscan
  6. Confirm the path. It should be /dev/mapper/vg_epaddev-lv_home for the ePAD centos 6 VM lvdisplay
  7. Extend the logical drive with the new space lvextend /dev/mapper/vg_epaddev-lv_home /dev/sda3
  8. Resize the logical volume resize2fs /dev/mapper/vg_epaddev-lv_home
  9. Check the disk space df -h It should show extended storage