Aller au contenu

Gestion des disques/volumes additionnels

Christophe TREMBLAY-GUILLOUX
Christophe TREMBLAY-GUILLOUXIngénieur système Linux

D'abord, stopper quelques services et démonter le disque à l'aide du script :

Section intitulée « D'abord, stopper quelques services et démonter le disque à l'aide du script : »
bash
mount-backup-disk.sh umount

On voit s'afficher quelque chose comme :

>> 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

Changer la configuration Terraform du projet Public Cloud à gérer :

Section intitulée « Changer la configuration Terraform du projet Public Cloud à gérer : »
  1. Préparer la mise à jour fichier resource-openstack-compute-instance-xxx.tf en modifiant cette section et le paramètre size:
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. Préparer le plan de mise à jour:
bash
terraform plan -var-file=prod.tfvars -out plan.zip

On voit quelque chose de ce style:

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. Vérifier le plan:
bash
terraform show plan.zip

On vérifie la sortie que rien n'indique un destroy, seulement update in-place en couleur orangée:

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. Appliquer le plan:
bash
terraform apply -var-file=prod.tfvars planDANGER.zip

Après quelques instants:

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

On force la détection du retour du disque et on corrige la table GPT:

bash
partrprobe
parted /dev/sdb

On utilise ces commandes dans le prompt parted pour agrandir la 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

Remonter le système et agrandir le système de fichier

Section intitulée « Remonter le système et agrandir le système de fichier »

Si le système des fichiers est ext4, on l'agrandit avant le remontage, sinon après :

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