Extending the disk and filesystem

This chapter will guide you through adding disk space to your IAM appliance.

This guide can be used both to increase the amount of space during the first launch when the supplied virtual disk doesn’t contain parameters for the specific environment, but also later to add more space whenever needed.

The situation described is valid when the appliance only uses one connected hard drive. If multiple hard drives are connected, the guide may need to be modified to address the different drive and partition identification.

Steps to add drive space
  1. Turn off the appliance.

  2. Increase the size of the virtual drive in the datastore of virtualization platform as needed.

  3. Create an appliance drive snapshot so you can return to a functioning state in case something goes wrong.

  4. Turn on the appliance.

  5. Increase the drive partition size to use the entire size of the drive.

  6. Increase the physical volume size.

  7. Allocate space for each partition.

  8. Increase the filesystem borders.

  9. Remove the snapshot from the virtualization (if successful), return to the snapshot (if unsuccessful).

Turn off the appliance.

Turn off the appliance using the usual way, e. g., using the command poweroff, or using ACPI shutdown.

Increase the size of the virtual drive and create a snapshot

Increase the size of the virtual drive using the tools of your virtualization platform. Then, create a snapshot.

Turn on the appliance

Turn on the appliance using the usual way. After startup, check that all services are running.

Increase the drive partition size

Internally, the appliance uses two drive partitions. The first is called sda1 mounted in the system as /boot. This partition has a fixed sized and doesn’t require any changes. The second partition is a physical volume of the system LVM, identified as sda2. It contains all appliance and its OS data (mounted as /, /data and swap).

LVM works with physical volumes (pv), volume groups (vg) a logical volumes (lv).

  • A physical volume corresponds to a hard drive partition. One or more volumes make up a volume group.

  • A volume group is a storage of drive space, abstracted from the physical storage. The space from it can be given to each logical volume.

  • A logical volume corresponds to a mountpoint which can be seen from the OS. From the point of view of the appliance, data is stored there.

During the appliance start, the operating system loads the new size of the physical drive. It is necessary to increase the drive partition sda2 (sda is a drive identificator, 2 is the identificator of the partition on the drive).

We can change the size of the partition 2 using a program called parted. The 100% argument is a drive offset reference, so it means "to the end".

Change the partition size with parted
[root@localhost ~]# parted /dev/sda
... abbreviated ...

(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 85.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1075MB  1074MB  primary  ext4         boot
 2      1075MB  80.5GB  79.5GB  primary               lvm

(parted) resizepart 2 100%
(parted) q
Information: You may need to update /etc/fstab.

Increasing the physical volume

Now, we can increase the physical volume to use the entire space of the drive partition. If we use the command pvresize without parameters, the physical volume will automatically take up all of the free space.

Using pvresize
[root@localhost ~]# pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

Now, we can check that the new free space showed up in the volume group. The utility vgdisplay shows all volume groups, their names, and allocated and free space. We want details about the vg_iam group. The parameter Free PE / Size shows the current free space which can be divided between logical volumes.

List volume groups and their properties
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_iam
... abbreviated ...
  VG Size               <79.00 GiB
  PE Size               4.00 MiB
  Total PE              18943
  Alloc PE / Size       18943 / <74.00 GiB
  Free  PE / Size       1280 / 5.00 GiB
... abbreviated ...

Allocating space for partitions

First, we need to identify the partition to which we want to allocate the space. We can use a tool call lsblk for this.

An example of an lsblk output
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   75G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   74G  0 part
  ├─vg_iam-root 253:0    0   20G  0 lvm  /
  ├─vg_iam-swap 253:1    0    4G  0 lvm  [SWAP]
  └─vg_iam-data 253:2    0   50G  0 lvm  /data
sr0              11:0    1 1024M  0 rom

From the output of lsblk, we can read the mountpoints, drive partitions which are running out of space, and which logical volume needs to be extended.

Let’s assume we are adding space to the partition /data. Using lsblk, we found that the storage is in volume group vg_iam and the logical volume is called data (see the left-hand side of the previous output).

We will add 1GB of space to the logical volume with the lvextend utility.
[root@localhost ~]# lvextend -L+1G /dev/vg_iam/data
  Size of logical volume vg_iam/data changed from <50.00 GiB (12799 extents) to <51.00 GiB (13055 extents).
  Logical volume vg_iam/data successfully resized.

It is important you follow the syntax of the -L parameter. The sign + means that we are adding space to the current size.

Without using the + sign, we would set an absolute partition size. If we set a size smaller than the current size of the parition, we would have damaged the filesystem.

Extending the filesystem

The last step is extending the filesystem itself. Since XFS is used, we can use the tool xfs_growfs.

Using xfs_growfs to extend the partition /data
[root@localhost ~]# xfs_growfs /dev/vg_iam/data
meta-data=/dev/mapper/vg_iam-data isize=512    agcount=4, agsize=3276544 blks
... abbreviated ...
data blocks changed from 13106176 to 13368320
Checking the added space

Using the command df, we can check that the partition /data now has more available space.

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    2.0G     0  2.0G   0% /dev/shm
tmpfs                    2.0G   17M  2.0G   1% /run
tmpfs                    2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/vg_iam-root   20G  3.9G   17G  20% /
/dev/mapper/vg_iam-data   50G  390M   51G   1% /data
/dev/sda1                976M   96M  814M  11% /boot
tmpfs                    393M     0  393M   0% /run/user/0

Delete the virtual machine snapshot

If all actions were finished successfully, you can delete the virtual machine snapshot which you created at the beginning of the tutorial.