Le but est d’agrandir le disque dur virtuel de la machine virtuelle. Il faut que le disque de la machine virtuelle soit configurée en LVM.
- DomO = Serveur de virtualisation Xen qui héberge les VM
- DomU = VM
- LV = volume logique
- VG = Groupe de volume
Sur le DomO :
- Agrandissement d’un LV d’une VM de 250G:
- Arreter la VM
Identifier le disque de la VM en question puis :
lvextend -L +250G /dev/vg/lv_ispconfig
- Redémarrer la VM
Nous allons modifier la table des partitions pour prendre en compte l’espace disque rajouté : Sur la VM
# fdsik /dev/xvda Command (m for help): p Disk /dev/xvda: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0006d2da Device Boot Start End Blocks Id System /dev/xvda1 2048 499711 248832 83 Linux /dev/xvda2 501758 104855551 52176897 5 Extended /dev/xvda5 501760 104855551 52176896 8e Linux LVM
- IMPORTANT : Les valeurs importante sont la partition /dev/xvda5 qui commence à 501760
- Nous allons supprimer le volume étendue /dev/xvda2 puis le re créer pour prendre en compte le nouvelle escape libre :
fdisk /dev/xvda Command (m for help): p
Disk /dev/xvda: 322.1 GB, 322122547200 bytes 255 heads, 63 sectors/track, 39162 cylinders, total 629145600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0006d2da Device Boot Start End Blocks Id System /dev/xvda1 2048 499711 248832 83 Linux /dev/xvda2 499712 629145599 314322944 5 Extended /dev/xvda5 501760 629145599 314321920 8e Linux LVM Command (m for help): d
Partition number (1-5): 2
Command (m for help): n
Partition type: p
primary (1 primary, 0 extended, 3 free) e
extended Select (default p): e
Partition number (1-4, default 2): Using default value 2
First sector (499712-629145599, default 499712): Using default value 499712 Last sector, +sectors or +size{K,M,G} (499712-629145599, default 629145599): Using default value 629145599
Command (m for help): n
Partition type: p
primary (1 primary, 1 extended, 2 free) l
logical (numbered from 5) Select (default p): l
Adding logical partition 5 First sector (501760-629145599, default 501760): Using default value 501760 Last sector, +sectors or +size{K,M,G} (501760-629145599, default 629145599): Using default value 629145599
Command (m for help): t
Partition number (1-5): 5 Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
Command (m for help):w
# fdisk /dev/xvda Command (m for help): p
Disk /dev/xvda: 322.1 GB, 322122547200 bytes 255 heads, 63 sectors/track, 39162 cylinders, total 629145600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0006d2da Device Boot Start End Blocks Id System /dev/xvda1 2048 499711 248832 83 Linux /dev/xvda2 499712 629145599 314322944 5 Extended /dev/xvda5 501760 629145599 314321920 8e Linux LVM
Le nouvelle espace est pris en compte dans la table de partion
- Maintenant il faut augmenter la VG puis la LV en question :Avant
# pvs PV VG Fmt Attr PSize PFree /dev/xvda5 isp1 lvm2 a-- 50g 0 # ls /dev/isp1/ home root swap_1 tmp usr var # lvs LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert home isp1 -wi-ao-- 10,00g root isp1 -wi-ao-- 3,44g swap_1 isp1 -wi-ao-- 4,78g tmp isp1 -wi-ao-- 380,00m usr isp1 -wi-ao-- 8,38g var isp1 -wi-ao-- 20,79g
- On augmente le VG pour prendre en compte l’espace libre ajouté :
# pvresize /dev/xvda5 Physical volume "/dev/vda2" changed 1 physical volume(s) resized / 0 physical volume(s) not resized# pvs PV VG Fmt Attr PSize PFree /dev/xvda5 isp1 lvm2 a-- 299,76g 50,00g
- On veut augmenter la partition LV var
NEW
lvextend -r -L +150G /dev/vg_isp/lv_var
-> Plus besoin de démonter, killer et rebooter
OLD
- On démonte la partition :
umount /dev/isp1/var
e2fsck /dev/isp1/var
resize2fs /dev/isp1/var #(peut etre long suivant la taille ajouté)
Et voilà !
lvs LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert home isp1 -wi-ao-- 10,00g root isp1 -wi-ao-- 3,44g swap_1 isp1 -wi-ao-- 4,78g tmp isp1 -wi-ao-- 380,00m usr isp1 -wi-ao-- 8,38g var isp1 -wi-ao-- 222,79g
- On remonte les partitions à leur point de montage :
mount -a
- On pourra redémarrer la VM pour être sure que ton est OK