KB N°2359: ADDING A DISK TO VMWARE APPLIANCES

Published November 20, 2023

How to add an extra disk to VMware virtual appliances.

Objective

Add an extra disk to VMware virtual appliances.

BACKGROUND

Partitions on Olfeo VMware appliances are based on LVM. The aim of this tutorial is to increase available disk space.

Here's a diagram showing the architecture for deploying virtual appliances, then at the end of this tutorial :

STEPS

We recommend that you create a snapshot of the virtual machine before performing the following operations.
  1. First, create a new disk from the VMware interface, then add this new disk to the Olfeo appliance.
  2. Then connect to the appliance in console mode, and do : fdisk /dev/sdb where sdb is the name of the new disk. This name may be different depending on the configuration. Once started fdiskPress (n)ew partition, (p)rimary, (1)st partition, (Default), (Default), (w)rite :
  3. Turn off the Olfeo chroot part:/etc/init.d/olfeo-chroot stop
  4. Move files located in the data folder :mkdir /root/data_temp && mv /opt/olfeo5/chroot/opt/olfeo5/data/* /root/data_temp
  5. Create a new physical volume so that LVM can use this partition :pvcreate /dev/sdb1
  6. Add this physical volume to the vaolfeo volume group :vgextend vaolfeo /dev/sdb1
  7. Create the new logical volume: (Replace the value "10G" with that of the disk set up in VMware)lvcreate -n data -L 10G vaolfeo
  8. Format this new logical volume as ext4 :mkfs -t ext4 /dev/vaolfeo/data
  9. Add the following line to /etc/fstab so that the new logical volume is used by the data folder:/dev/mapper/vaolfeo-data /opt/olfeo5/chroot/opt/olfeo5/data ext4 defaults 0 1
  10. Apply changes to mount points :mount -a

Validation

Check that the data folder uses the new logical volume:

Once this has been verified :

  1. Replace the data folder :mv /root/data_temp/* /opt/olfeo5/chroot/opt/olfeo5/data
  2. Restart the chroot part: /etc/init.d/olfeo-chroot start

Additions to increase partition size later :

To increase the size of this volume again, repeat steps 1, 2, 5 and 6 above, then perform the following operations:

  • Unmount the data partition so that you can perform the following operations: umount /opt/olfeo5/chroot/opt/olfeo5/data
  • Check the file system to be modified: e2fsck -f /dev/vaolfeo/data
  • Resize the logical volume: (replace 20g by the desired total size) Be careful not to reduce the size of the disk at this point, otherwise data will be lost.lvresize -L 20g /dev/vaolfeo/data
  • Resize partition :resize2fs /dev/vaolfeo/data
  • Remount partition :mount -a

At this stage, a 20GB data partition uses the second disk installed: