Introduction
It is a good practice to review disk utilization of the Login Enterprise Virtual Appliance (LE VA). The more tests being run, the more performance and availability data will grow. This can be managed using the data retention features of the virtual appliance for raw data and events. In my case I didn’t watch the disk utilization closely and when I tried to run an upgrade, it failed.
NOTE: These steps are for our default Debian LE VA Implementation. Mileage may vary slightly with other Linux operating systems like Red Hat.
NOTE: This took me about 2-3 hours and did not require a reboot.
Procedure
If you need to add more disk space to the LE VA primary partition (e.g., /dev/sda1) please follow these steps:
Preparation
- BACKUP your virtual appliance.
In most cases you can just take a snapshot of the virtual machine, or virtual machine hard disk using the hypervisor tools. This gives you the opportunity to restore the LE VA to its prior configuration, should something go wrong. - Grow the logical disk that has run out of space. In my case I did this in Azure, which was pretty easy. It should also be pretty easy in any other hypervisor.
- Access the LE VA Bash shell via the console or via SSH tools like PuTTY
NOTE: When performing some of the operations below you may be disconnected from your SSH session, so using the LE VA Console is recommended. - Check disk utilization (you can see my problem right away)
df -h
- Check the disk partition table and get the information you need for the next steps by running
sfdisk -l
NOTE: A physical sector boundary happens every 4096 bytes. If the partition does not start on a physical sector boundary then you will split I/Os across the boundary which can affect disk performance. This should be ok for the virtual appliance swap space as /dev/sda5 is aligned.
Moving the swap space to the end of the new partition
- Calculate where the new starting sector for /dev/sda2 will be (/dev/sda5 is in /dev/sda2, so it will move when you move /dev/sda2). The formula for determining the new starting sector is as follows:
(Total # sectors on disk /dev/sda ) - (# Sectors in partition /dev/sda2 ) - (Starting Sector of /dev/sda2) = New Starting Sector
Here is an example. We are going to use a 128 GB disk as the new size (as shown in the picture above, running 'sdlist -l' should show you 268,435,456 Sectors for "Disk /dev/sda")
(268,435,456) - (8,382,466) - (54,530,048) = 205,522,944
NOTE: I like to align my starting sector to a physical sector boundary for performance. Therefore I divide the new starting sector above by 4096, rounding down to the nearest integer and multiplying by 4096. In this case the math looks like this:
(205,522,944 / 4,096 ) = 50,176.5, round down to 50,176 and multiply by 4096 and we have 205,520,896
This will keep the swap partition /dev/sda5 aligned, while /dev/sda2 is not aligned. (Credit to JDE for catching typo.) - Before you do the move, you need to turn memory swapping off because your swap space is on /dev/sda5.
swapoff -a
- Now use sfdisk to move the /dev/sda2 partition to its new home
echo '+205520896' | sfdisk /dev/sda -N 2 --move-data --no-reread
It will take a while to do the partition remapping. In the example above it took 2 - 3 hours. Look at the disk activity and you'll see the machine remapping the partition. You can also run the following commands to check the statustail /root/sfdisk-sda2.move
andcat /root/sfdisk-sda2.move | more
After the move you’ll see /dev/sda5 moved too
Here is what it looks like after the move is complete (note the new starting sectors for /dev/sda2 and /dev/sda5 ):
Here is what the disk I/O looks like during the 3 hour remapping.
Expanding the primary disk into its new space
- Now expand the /dev/sda1 partition to use up the space you just made
echo ',+' | sfdisk /dev/sda -N 1 --no-reread
It should look like this afterwards (the partition is 124GB now)sfdisk -l
- At this point you’ve expanded your disk partition but you haven’t expanded the filesystem on the partition… to expand the filesystem capacity we need to tell the OS to rescan the partitions using the 'partprobe' command.
First, you'll need to install 'parted' with the following command, then run 'partprobe',apt-get install parted
partprobe
Now you can expand that filesystem:resize2fs /dev/sda1
...and now you have 122 GB of disk space for your LE VA primary disk - /dev/sda1
Finishing up
- Turn swapping back on
swapon -a
All done…
THIS NUGGETS OF INFORMATION USED IN THIS ARTICLE CAME FROM MICHAEL KENT
Tips come from this article:
http://karelzak.blogspot.com/2015/09/whats-cooking-in-sfdisk-for-v228.html