Increasing the Partition Size on a Virtual Machine

You can increase the size of partitions on virtual machines to take advantage of unallocated storage space. The procedures below are examples of how you can increase the size of /tmp, /opt and /var partitions. However, you can use these examples to help you increase the size of any partition on a virtual machine.

To increase the partition size, insert a new virtual disk. Do not expand the existing disk

Example #1: Increase The Size of /tmp and /opt Partitions

This procedure will explain how to add 20 GB to the /tmp partition and 87 GB to the /opt partition.

  1. Log into the TOS CLI as user with root privileges.

  2. Run the following command to show the amount of space used by each partition.

    # df -h

    In the image above /tmp is 5 GB and /opt is 13 GB.

    The partitions need to be increased as follows:

    • /tmp = 25 GB
    • /opt = 100 GB

    Therefore, you will have to insert a new disk with an extra 107 GB to the virtual machine.

    • /tmp needs 20 GB
    • /opt needs 87 GB
  3. Insert the new virtual disk with the desired size to the virtual machine.

  4. Log into the TOS CLI as user with root privileges and do the following:

    1. Once all the pods have been terminated, verify the new disk is recognized by the operating system. If the new disk does not appear, you may need to reboot your system.

      # ls -l /dev/sd*

    2. If this is the first new disk you are adding, it will appear as sdb. The last letter advances each time a new disk is added. Therefore if disks were previously added, you may see sdc, sdd, or sde. It depends on the number of disks added.
      These instructions are for sdb.
    3. Add the new disk to the LVM volume group.

      # pvcreate /dev/sdb
      # vgextend VolGroup01 /dev/sdb

    4. Locate the /tmp partition logical volume (see image above).

      # df -h

      In this example the logical volume of /tmp is /dev/mapper/VolGroup01-LogVol06

    5. Extend the LVM logical volume of the /tmp partition to 20 GB.

      # lvextend -r -L +20GB /dev/mapper/VolGroup01-LogVol06

    6. Verify that the storage space was added to the /tmp partition.

      # df -h | grep "[\t ]\+/tmp"

    7. Locate the /opt partition logical volume (see image above).

      # df -h

      In this example the logical volume of /opt is /dev/mapper/VolGroup01-LogVol08

    8. Extend the LVM logical volume of the /opt partition to use all remaining free space (87 GB).

      # lvextend -r -l +100%Free /dev/mapper/VolGroup01-LogVol08

    9. Verify that the storage space was added to the /opt partition.

      # df -h | grep "[\t ]\+/opt"

    10. Press CTRL+C to cancel the previous commands.

    11. Restart the TOS services.

      [primary data node]# sudo tos start

Example #2: Increase The Size of /var Partitions

The /var partition uses all free space on the virtual disk. Do not share the virtual disk space with other partitions.
  1. Add a new virtual disk with the desired size to the virtual machine.

  2. Log into the TOS CLI as user with root privileges and do the following:

    1. Verify the new disk is recognized by the operating system.

      # ls -l /dev/sd*

    2. If this is the first new disk you are adding, it will appear as sdb. The last letter advances each time a new disk is added. Therefore if disks were previously added, you may see sdc, sdd, or sde. It depends on the number of disks added.
      These instructions are for sdb.
    3. Add the new disk to the LVM volume group.

      # pvcreate /dev/sdb
      # vgextend VolGroup01 /dev/sdb

    4. Locate the /var partition logical volume.

      # df -h

      In this example the logical volume of /var is /dev/mapper/VolGroup01-LogVol02

    5. Extend the LVM logical volume of the /var partition to include all free storage space.

      # lvextend -r -l +100%FREE /dev/mapper/VolGroup01-LogVol02

    6. Verify that the storage space was added to the /var partition.

      # df -h | grep "/var[\t ]*$"

    7. Restart the TOS services.

      [primary data node]# sudo tos start