A.3 Expanding Disk Space in Hyper-V Virtual Machine

Prerequisite: Ensure that the current disk has the required space to expand by running the fdisk -l command at the Change Guardian appliance prompt.

NOTE:You can expand the partition if there are less than four primary partitions. However, if there are four primary partitions, add a new virtual disk to the virtual machine and expand the logical volume.

To expand the disk space:

  1. Expand the disk space:

    1. Log in to the Hyper-V server and power off the virtual machine where you installed Change Guardian appliance.

    2. Right-click the virtual machine and click Settings.

    3. Under IDE Controller, click Hard Drive.

    4. Select Virtual hard disk, and click Edit.

      The Edit Virtual Hard Disk Wizard opens.

    5. In Locate Virtual Hard Disk, click Next.

    6. In Choose Action, Click Expand > Next.

    7. In Configure Disk, specify the disk size, and click Next > Finish.

    8. Turn the machine on.

  2. Verify that the disk space has increased by running the following at the appliance prompt:

    fdisk -l

  3. Create a partition:

    1. Run the disk partitioning utility:

      fdisk <partition_name>

      For example, fdisk /dev/sda.

    2. To create a new partition, specify ‘n’.

    3. To create a primary partition, specify ‘p’.

    4. Specify the desired partition number.

    5. When prompted for the first and last sectors, press Enter.

  4. Change the partition type:

    1. To change the partition type, specify ‘t’.

    2. Specify the partition number you had mentioned.

    3. Specify the Hex code as 8e.

  5. To write the partition to the disk, specify ‘w’.

  6. Scan for the newly created partition:

    partprobe -s

    The new partition number is listed in the output.

  7. Verify that the partition is created:

    fdisk -l

    The details of the new partition and logical volumes are displayed. For example, the new partition is /dev/sda3. Make a note of the logical volume path to use in a later step. For example the path is /dev/mapper/systemVG-LVvar_opt.

  8. Expand the logical volume with the new partition:

    1. Create a physical volume by replacing newly created partition:

      pvcreate <partition_name>

      For example, the command is: pvcreate /dev/sda3

    2. Find out the volume group name:

      vgdisplay

      For example, the volume group is displayed as VG Name volume_group1.

    3. Expand the volume group:

      vgextend <volume_group_name> <partition_name>

      For example, the command is vgextend volume_group1 /dev/sda3.

    4. Check the newly added physical volume and the usable space:

      pvscan

    5. Expand the logical volume:

      lvextend <logical_volume_path> <partition_name>

      For example, the command is lvextend /dev/mapper/systemVG-LVvar_opt /dev/sda3.

    6. To use the newly created space, resize the file system to the logical volume:

      resize2fs <logical_volume_path>

      For example, the command is resize2fs /dev/mapper/systemVG-LVvar_opt.

    7. Display the total space and available space on the file system:

      df -h