Differenze tra le versioni di "Extend a Volume Group"
(11 versioni intermedie di 2 utenti non mostrate) | |||
Riga 1: | Riga 1: | ||
− | =Aggiungere un disco fisico ad un VolumeGroup= | + | =Gestire i Volume Groups & Logical Volumes= |
+ | * Effettuare una scansione dei logical volumes e verificarne lo stato | ||
+ | lvscan -a | ||
+ | * Riattivare un LV che risulti disattivo | ||
+ | lvchange -ay <pathToLV> | ||
+ | * Disattivare un LV | ||
+ | lvchange -an <pathToLV> | ||
+ | |||
+ | ==Aggiungere un disco fisico ad un VolumeGroup== | ||
vgextend <volume-group-name> /dev/sdX | vgextend <volume-group-name> /dev/sdX | ||
+ | Nota: Se è necessario aggiungere alla vm un disco fisico seguire questa guida: [[Sitech:Progetti/vmWare#Aggiungere_un_disco_virtuale|Aggiungere_un_disco_virtuale]] | ||
− | =Creare un Logical Volume= | + | ==Creare un Logical Volume== |
* Creazione di un LV utilizzando la dimensione massima disponibile nel VG | * Creazione di un LV utilizzando la dimensione massima disponibile nel VG | ||
lvcreate -n <logical-volume-name> -l 100%FREE <volume-group-name> | lvcreate -n <logical-volume-name> -l 100%FREE <volume-group-name> | ||
Riga 8: | Riga 17: | ||
lvcreate -n <logical-volume-name> -L8G <volume-group-name> | lvcreate -n <logical-volume-name> -L8G <volume-group-name> | ||
− | =Creare un file-system in un LV esistente= | + | ==Creare un file-system in un LV esistente== |
mkfs -t ext4 /dev/mapper/lv-name | mkfs -t ext4 /dev/mapper/lv-name | ||
+ | ==UUID di un volume e mount automatico== | ||
+ | Per ottenere il UUID di un volume, utilizzare il seguente comando | ||
+ | blkid | ||
+ | <br> | ||
+ | Per attivare il mount automatico, editare il file | ||
+ | /etc/fstab | ||
+ | |||
+ | ==Shrinking a logical volume== | ||
+ | Before shrinking the volume must be unmounted. | ||
+ | |||
+ | umount /dev/mapper/volume_lv | ||
+ | lvresize --resizefs -L<NEWSIZE> /dev/mapper/volume_lv | ||
+ | mount /dev/mapper/volume_lv | ||
+ | ==Extending a logical volume (and corresponding filesystem)== | ||
+ | lvresize --resizefs -L<NEWSIZE> /dev/mapper/volume_lv | ||
+ | Example (extend vgData-lvdocker_volumes by 4GB): | ||
+ | lvresize --resizefs -L+4G /dev/mapper/vgData-lvdocker_volumes | ||
+ | oppure | ||
+ | lvextend --resizefs -L+4G /dev/mapper/vgData-lvdocker_volumes | ||
− | =Extending a logical volume in a virtual machine running Red Hat, Cent OS or OpenSUSe= | + | ==Extending a logical volume in a virtual machine running Red Hat, Cent OS or OpenSUSe== |
'''Purpose'''<br> | '''Purpose'''<br> |
Versione attuale delle 17:10, 22 nov 2023
Indice
- 1 Gestire i Volume Groups & Logical Volumes
- 1.1 Aggiungere un disco fisico ad un VolumeGroup
- 1.2 Creare un Logical Volume
- 1.3 Creare un file-system in un LV esistente
- 1.4 UUID di un volume e mount automatico
- 1.5 Shrinking a logical volume
- 1.6 Extending a logical volume (and corresponding filesystem)
- 1.7 Extending a logical volume in a virtual machine running Red Hat, Cent OS or OpenSUSe
- 2 Altre fonti di informazione
Gestire i Volume Groups & Logical Volumes
- Effettuare una scansione dei logical volumes e verificarne lo stato
lvscan -a
- Riattivare un LV che risulti disattivo
lvchange -ay <pathToLV>
- Disattivare un LV
lvchange -an <pathToLV>
Aggiungere un disco fisico ad un VolumeGroup
vgextend <volume-group-name> /dev/sdX
Nota: Se è necessario aggiungere alla vm un disco fisico seguire questa guida: Aggiungere_un_disco_virtuale
Creare un Logical Volume
- Creazione di un LV utilizzando la dimensione massima disponibile nel VG
lvcreate -n <logical-volume-name> -l 100%FREE <volume-group-name>
- Creazione di un LV indicando la dimensione iniziale del LV a 8Gb
lvcreate -n <logical-volume-name> -L8G <volume-group-name>
Creare un file-system in un LV esistente
mkfs -t ext4 /dev/mapper/lv-name
UUID di un volume e mount automatico
Per ottenere il UUID di un volume, utilizzare il seguente comando
blkid
Per attivare il mount automatico, editare il file
/etc/fstab
Shrinking a logical volume
Before shrinking the volume must be unmounted.
umount /dev/mapper/volume_lv lvresize --resizefs -L<NEWSIZE> /dev/mapper/volume_lv mount /dev/mapper/volume_lv
Extending a logical volume (and corresponding filesystem)
lvresize --resizefs -L<NEWSIZE> /dev/mapper/volume_lv
Example (extend vgData-lvdocker_volumes by 4GB):
lvresize --resizefs -L+4G /dev/mapper/vgData-lvdocker_volumes
oppure
lvextend --resizefs -L+4G /dev/mapper/vgData-lvdocker_volumes
Extending a logical volume in a virtual machine running Red Hat, Cent OS or OpenSUSe
Purpose
This article provides steps for extending a volume group created with Logical Volume Manager (LVM) in a virtual machine running Red Hat/Cent OS/OpenSUSe.
Resolution
Create a new disk then rescan devices.
Run this command to convert the new disk to a physical volume:
Note: The number for the sda can change depending on system setup. Use the sda number that was created in step 5.
# pvcreate /dev/sda3
Run this command to extend the physical volume:
# vgextend VolGroup00 /dev/sda3
Note: To determine which volume group to extend, use the command vgdisplay.
Run this command to verify how many physical extents are available to the Volume Group:
# vgdisplay VolGroup00 | grep "Free"
Run the following command to extend the Logical Volume:
# lvextend -L+#G /dev/VolGroup00/LogVol00
Where # is the number of Free space in GB available as per the previous command. Use the full number output from Step 10 including any decimals. Or use:
# lvextend -l +100%FREE /dev/VolGroup00/LogVol00
to extend to max size available.
Note: to determine which logical volume to extend, use the command lvdisplay.
Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:
# resize2fs /dev/VolGroup00/LogVol00
Note: Use ext2online instead of resize2fs if it is a Red Hat virtual machine.
Run the following command to verify that the / filesystem has the new space available:
# df -h /
Altre fonti di informazione
Puoi trovare altre informazioni utili e complete in questo articolo.