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.
-
Turn off the appliance.
-
Increase the size of the virtual drive in the datastore of virtualization platform as needed.
-
Create an appliance drive snapshot so you can return to a functioning state in case something goes wrong.
-
Turn on the appliance.
-
Increase the drive partition size to use the entire size of the drive.
-
Increase the physical volume size.
-
Allocate space for each partition.
-
Increase the filesystem borders.
-
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).
|
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".
[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.
[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.
[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.
[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).
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 Without using the |
Extending the filesystem
The last step is extending the filesystem itself. Since XFS is used, we can use the tool xfs_growfs
.
[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
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