Expanding the disk space manually
Overview
Reviewing disk utilization of the Login Enterprise Virtual Appliance is essential for maintaining performance and availability, especially as the number of Tests increases and the volume of performance data grows.
You can manage this growth using the data retention features of the Virtual Appliance for raw data and events. For more information, see the Data retention for database usage. If disk utilization is not monitored closely, you may encounter issues during upgrades, which can lead to failures.
These steps are intended for the default Debian Virtual Appliance implementation. Results may vary slightly with other Linux operating systems, such as Red Hat.
This process typically takes 2-3 hours and does not require a reboot.
Instructions
To add more disk space to the Virtual Appliance's primary partition, for example, /dev/sda1, follow these steps:
Preparation
1. Backup your Virtual Appliance
Take a snapshot of the Virtual Machine or the VM's hard disk using the hypervisor tools. This allows you to restore the Virtual Appliance to its previous configuration if any issues arise.
2. Grow the Logical Disk
Expand the logical disk that has run out of space. This process is generally straightforward in most hypervisors, including Azure.
3. Access the Virtual Appliance Bash Shell
Use the console or SSH tools like PuTTY to access the Bash shell.
Some operations may disconnect your SSH session, so using the Login Enterprise Virtual Appliance Console is recommended.
4. Check Disk Utilization
Run the following command to assess disk utilization:
df -h
5. Check the Disk Partition Table
Gather the necessary information for the next steps by running the following command:
sfdisk -l
A physical sector boundary occurs every 4096 bytes. If the partition does not start on a physical sector boundary, it may split I/Os across the boundary, potentially affecting disk performance. However, this should not be an issue for the virtual appliance swap space, as /dev/sda5 is aligned.
Moving the swap space to the end of the new partition
1. 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). Use the following formula to determine the new starting sector:
(Total # sectors on disk /dev/sda ) - (# Sectors in partition /dev/sda2 ) - (Starting Sector of /dev/sda2) = New Starting Sector
For illustration, let’s consider a 128 GB disk as the new size (you can verify this by running sdlist -l, which will display the number of sectors for "Disk /dev/sda").
(268,435,456) - (8,382,466) - (54,530,048) = 205,522,944
The best practice is to align the starting sector to a physical sector boundary for optimal performance. To do this, divide the new starting sector by 4096, round down to the nearest integer, and then multiply by 4096. For example, the calculation would look like this:
(205,522,944 / 4,096 ) = 50,176.5, round down to 50,176 and multiplied by 4096 equals to 205,520,896
This will keep the swap partition /dev/sda5 aligned, while /dev/sda2 is not aligned.
2. Before you make the move, you need to turn memory swapping off because your swap space is on /dev/sda5.
swapoff -a
3. Now, use sfdisk to move the /dev/sda2 partition to its new home:
echo '+205520896' | sfdisk /dev/sda -N 2 --move-data --no-reread
The partition remapping process may take some time. In the example above, it typically took about 2-3 hours. During this period, monitor the disk activity to observe the machine remapping the partition.
To check the status of the remapping, you can run the following commands:
tail /root/sfdisk-sda2.move
and
cat /root/sfdisk-sda2.move | more
Once the move is complete, you will notice that /dev/sda5 has also been relocated.
Below is an example of what the partition layout looks like after the move is finished. Pay special attention to the new starting sectors for both /dev/sda2 and /dev/sda5:
During the 3-hour remapping process, you can monitor the disk I/O activity. Here’s what the disk I/O might look like:
Expanding the primary disk into its new space
1. To utilize the newly allocated space, expand the /dev/sda1 partition:
echo ',+' | sfdisk /dev/sda -N 1 --no-reread
After expanding the /dev/sda1 partition, it should reflect the new size. The partition should now be 124 GB.
sfdisk -l
2. At this point, you have successfully expanded your disk partition; however, the filesystem on the partition has not yet been expanded. To expand the filesystem capacity, you need to instruct 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 that you have rescanned the partitions, you can expand the filesystem on /dev/sda1 to utilize the new space. Run the following command to expand the filesystem:
resize2fs /dev/sda1
After executing this command, your Login Enterprise Virtual Appliance primary disk will have 122 GB of usable disk space - /dev/sda1
Finishing up
Turn Swapping back on
1. Once the filesystem expansion is complete, re-enable swapping by using the following command:
swapon -a
2. You have successfully expanded the Virtual Appliance disk and filesystem. The additional disk space is now available for use.
Expanding the disk space using the script
Overview
This script is designed to quickly and easily expand the disk size on your Virtual Appliance, helping to prevent potential crashes due to a full disk.
The script file is included in all new versions of the Appliance, located in the /loginvsi/bin folder, and is named expand-disk.sh
Prerequisites
This script expands the Appliance's disk using space that has already been added. Before executing the script, ensure that you have added the required disk space to the Appliance in your virtualization environment.
Executing the script
In the example provided, the Appliance has 100 GB of space, with an additional 100 GB added. The values shown in the screenshots correspond to these amounts. Be sure to refer to your own values based on the amount of space you add.
1. Log in to your Virtual Appliance console and open the bash shell by selecting Troubleshooting > Open Bash Shell.
2. The disk expansion script is named expand-disk.sh and is located in the /loginvsi/bin folder. Move to the aforementioned folder by running the cd /loginvsi/bin command. After moving to the folder, run chmod 755 expand-disk.sh to give it executable rights.
3. Run the script with the ./expand-disk.sh command. If the script can't find the added unpartitioned space, or if the added space is less than 1 GB, it will prompt you to reboot.
4. After rebooting, run ./expand-disk.sh again (remember to relocate to /loginvsi/bin/ first).
5. The script will detect the unpartitioned space, display the existing partition table, and prompt you to confirm the expansion (in this example, by 100 GB). Press Y to proceed.
6. The script will indicate the partition increased by 100 GB (you can see the difference compared to the previous message) and will prompt you to reboot. After rebooting, run ./expand-disk.sh continue to continue.
7. The final prompt will confirm that the partition and filesystem have been successfully increased.
Attachments
- expand-disk.sh4 KB