Growing an LVM Partition

last updated on Sept. 16, 2022

The way to grow the root partition on your Access Anywhere depends on what version of Access Anywhere was originally installed. To determine whether these instructions apply to your Access Anywhere, please consult this page carefully.

Once you have determined that the partition type is LVM, space can be added to the first disk via the hypervisor or cloud platform. Generally, the appliance will pick up the new disk space, but a reboot is recommended to ensure that the instance recognizes the increase.

After the reboot, log into the instance as smeconfiguser and become the root user:

su -

Check the current size of the root partition.

df -h

Sample Output:

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   14G  2.2G   12G  16% /
devtmpfs                 987M     0  987M   0% /dev
tmpfs                    997M     0  997M   0% /dev/shm
tmpfs                    997M  8.6M  989M   1% /run
tmpfs                    997M     0  997M   0% /sys/fs/cgroup
/dev/mapper/centos-var    16G  626M   16G   4% /var
/dev/sda1                509M  168M  342M  33% /boot
tmpfs                    200M     0  200M   0% /run/user/5003
tmpfs                    200M     0  200M   0% /run/user/0
tmpfs                    200M     0  200M   0% /run/user/5001
tmpfs                    200M     0  200M   0% /run/user/5000

In the example above the root partition has 21GB free and is mounted on /dev/mapper/centos-root

Run pvs to see the LVM physical volume:

pvs

Sample Output:

  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda2  centos lvm2 a--  34.00g    0

This appliance has 34GB allocated and 0 free. This is the base default. Please note the PV volume. In this case it’s /dev/sda2, however it may be different in your environment.

Now we will allocate the new disk space to this LVM physical volume. To do this we will need the tool “parted”, which may not be installed on the appliance. To install run:

yum install parted -y

Then run the command below, changing the green text to match the PV volume information obtained in the previous step. In our case our PV volume is /dev/sda2. Thus we will give the first part of the command the drive location which is /dev/sda and we will separate the partition number which is 2 for the resizepart flag.

parted -s /dev/sda resizepart 2 100%
partprobe
pvresize /dev/sda2

Sample Output:

  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

Now our LVM physical volume should show more free space:

pvs

Sample Output:

  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda2  centos lvm2 a--  59.50g 25.50g

To allocate all of the new space to the root partition run the following command:

lvextend -l +100%FREE /dev/centos/root

Sample Output:

  Size of logical volume centos/root changed from 14.00 GiB (3584 extents) to 39.50 GiB (10111 extents).
  Logical volume root successfully resized.

NOTE: If only some of the space is desired for root and the rest should be allocated to the mysql partition the below examples can be used.

Give just the amount of space desired to grow root partition by:

lvextend -L+10G /dev/centos/root

Sample Output:

  Size of logical volume centos/root changed from 14.00 GiB (3584 extents) to 15.00 GiB (10111 extents).
  Logical volume root successfully resized.

To grow the mysql partition by some amount of space:

lvextend -L+10G /dev/centos/var

Sample Output:

  Size of logical volume centos/var changed from 16.00 GiB (3584 extents) to 26.00 GiB (10111 extents).
  Logical volume root successfully resized.

Once the partition is grown check the new size:

lvs

Sample Output:

  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 39.50g
  swap centos -wi-ao----  4.00g
  var  centos -wi-ao---- 16.00g

Finally grow the root filesystem into the partition space:

xfs_growfs /

Sample Output:

meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=917504 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=3670016, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 3670016 to 10353664

Check the amount of available space on / partition to confirm success:

df -h

Sample Output:

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   40G  2.2G   38G   6% /
devtmpfs                 987M     0  987M   0% /dev
tmpfs                    997M     0  997M   0% /dev/shm
tmpfs                    997M  8.6M  989M   1% /run
tmpfs                    997M     0  997M   0% /sys/fs/cgroup
/dev/mapper/centos-var    16G  638M   16G   4% /var
/dev/sda1                509M  168M  342M  33% /boot
tmpfs                    200M     0  200M   0% /run/user/5003
tmpfs                    200M     0  200M   0% /run/user/5001
tmpfs                    200M     0  200M   0% /run/user/5000