Skip to content

Managing extra disks/volumes

Christophe TREMBLAY-GUILLOUX
Christophe TREMBLAY-GUILLOUXLinux systems engineer

First, stop a few services and unmount the disk with the script :

Section titled “First, stop a few services and unmount the disk with the script :”
bash
mount-backup-disk.sh umount

Something like this appears:

>> désactivation de l'agent Puppet
>> suspension des planifs
Updated scheduled backup xxx
disable xxx
>> arrêt de Webmin
>> démontage des binds
umount /home/xxx/virtualmin-backup
...
>> démontage du disque /var/backups/home
OK. Disque démonté. Pour remonter : /usr/local/bin/mount-backup-disk.sh remount

Change the Terraform configuration of the Public Cloud project to manage :

Section titled “Change the Terraform configuration of the Public Cloud project to manage :”
  1. Prepare the update of the resource-openstack-compute-instance-xxx.tf file by changing this section and the size parameter:
resource "openstack_blockstorage_volume_v3" "xxx_data" {
provider = openstack.ovh
region = "GRA9"
name = "xxx_data"
size = 100
enable_online_resize = true
lifecycle {
prevent_destroy = true
}
}
  1. Prepare the update plan:
bash
terraform plan -var-file=prod.tfvars -out plan.zip

You get something along these lines:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# openstack_blockstorage_volume_v3.xxx_data will be updated in-place
~ resource "openstack_blockstorage_volume_v3" "xxx_data" {
id = "xxx"
name = "xxx_data"
~ size = 40 -> 100
# (10 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
───────────────────────────────────────
Saved the plan to: plan.zip
To perform exactly these actions, run the following command to apply:
terraform apply "plan.zip"
  1. Check the plan:
bash
terraform show plan.zip

Check in the output that nothing mentions a destroy, only update in-place in orange:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# openstack_blockstorage_volume_v3.xxx_data will be updated in-place
~ resource "openstack_blockstorage_volume_v3" "xxx_data" {
id = "xxx"
name = "xxx_data"
~ size = 40 -> 100
# (10 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
  1. Apply the plan:
bash
terraform apply -var-file=prod.tfvars planDANGER.zip

After a few moments:

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Force the detection of the returning disk and fix the GPT table:

bash
partrprobe
parted /dev/sdb

Use these commands at the parted prompt to grow the partition:

(parted) print
Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of
the space (an extra xxx blocks) or continue with the current setting?
Fix/Ignore? F
...
(parted) resizepart 1 100%
(parted) quit

Remounting the system and growing the file system

Section titled “Remounting the system and growing the file system”

If the file system is ext4, grow it before remounting, otherwise afterwards:

bash
mount-backup-disk.sh remount
bash
e2fsck -f /dev/sdxy
resize2fs /dev/sdxy
mount /mount/point
bash
btrfs filesystem resize max /var/backups/home
bash
xfs_growfs /var/backups/home