How to Increase the Size of a Volume of a Gandi Cloud Server¶
Warning
This documentation does not cover all use-cases. Resizing a partition and/or filesystem always has a risk of data loss, and as such it is always recommended to backup the data on the Volume before any action. Feel free to contact our support team if you have any questions or concerns.
On the Cloud server, check the current size of the Volume to be extended:
# cat/proc/partitions
major minor #blocks name
202 0 10485760 xvda
202 1 10484719 xvda1
Edit the Volume size using the public API or the website (In this example we change the size of the main Volume from 10 GB to 11 GB), then check on the Cloud Server:
# grep xvda /proc/partitions
major minor #blocks name
202 0 11534336 xvda
202 1 10484719 xvda1
We can see in the partitions
file that the main Volume contains a partition and the filesystem is inside the partition. We now have to resize the partition and filesystem on the Volume. GANDI provides a script to help resize the partition of the main Volume (xvda):
# /usr/share/gandi/bootstrap.d/03-resize_main_disk
# grep xvda /proc/partitions
major minor #blocks name
202 0 11534336 xvda
202 1 11533295 xvda1
If the Volume to resize does not have any partition (i.e. if the grep returns only one line from /proc/partitions), then you can safely resize the filesystem with the name of the Volume:
# resize2fs /dev/xvdk
In some seldom cases, the resize2fs
command will fail and ask for a check on the filesystem before changing the size. This can be done with these commands after stopping all application with data on the Volume to be resized:
# umount /dev/xvdk
# fsck -f /dev/xvdk
# resize2fs /dev/xvdk
# mount /dev/xvdk /srv/"$(blkid -o value -s LABEL /dev/xvdk)"
If the Volume cannot be unmounted due to an application that cannot be stopped, you can try:
# mount -o remount,ro /dev/xvdk && fsck -f /dev/xvdk && \
resize2fs /dev/xvdk ; mount -o remount,rw /dev/xvdk
Note
You always have the option to stop the Cloud Server, detach the Volume you want to resize, and attach the Volume to another Cloud Server to apply the change in a simpler environment.
After performing these steps, the df -h
comand should show the new size for the filesystem.