Ceci est une ancienne révision du document !


Agrandir un disque

Le paquet libguestfs-tools doit être installé

# aptitude install libguestfs-tools

Nous nous plaçons où se trouvent nos disques de VMs

# cd /var/lib/libvirt/images

Nous agrandissons le disque au format qcow2

# qemu-img resize test.qcow2 +10G

Comme nous ne pouvons agrandir directement la partition en place, nous le copions

# cp test.qcow2 test-orig.qcow2
<code>

Nous agrandissons la partition /dev/sda2
<code>
# virt-resize --expand /dev/sda2 test-orig.qcow2 test.qcow2

Vous devriez avoir ce genre de retour

[   0.0] Examining test-orig.qcow2
◓ 25% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒═══════════════════════════════════════════════════════════════════════════════════════════════════════════════⟧ --:--
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
**********

Summary of changes:

/dev/sda1: This partition will be left alone.

/dev/sda2: This partition will be resized from 16,5G to 27,0G.  The LVM PV 
on /dev/sda2 will be expanded using the ‘pvresize’ method.

**********
[  12,9] Setting up initial partition table on test.qcow2
[  14,2] Copying /dev/sda1
[  15,7] Copying /dev/sda2
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[  78,1] Expanding /dev/sda2 using the ‘pvresize’ method

Resize operation completed with no errors.  Before deleting the old disk, 
carefully check that the resized disk boots and works correctly.

Nous démarrons la VM. Il ne reste plus qu'à agrandir le volume groupe LVM

# lvextend -L +10G /dev/mapper/vg_sys-lv_log

ou pour prendre 100% de l'espace libre

# lvextend -l +100%FREE /dev/mapper/vg_sys-lv_log

Pour retailler une partition ext4

# resize2fs /dev/mapper/vg_sys-lv_log

Pour retailler une partition xfs

# xfs_growfs /dev/mapper/vg_sys-lv_log
  • infrastructure/virtualisation/libvirt/disk-resize.1609357719.txt.gz
  • Dernière modification : 30/12/2020 19:48
  • de Stéphane Paillet