Ci saranno altri modi, ma secondo me questa è la via più semplice, usando anche le funzionalità proprie di LVM.
Prima di tutto devi creare una nuova partizione, sda3. Usando per esempio
sudo fdisk /dev/sda
.
La sequenza dei comandi usati dentro fdisk sarà questa:
p
stampa lo schema delle partizioni
n
nuova partizione
invio
per il tipo di partizione (di default sarà partizione primaria p
)
invio
per Partition number (sarà 3)
invio
per First sector
invio
per Last sector
p
stampa il nuovo schema delle partizioni
w
scrivi le modifiche
Esempio di quello che vedrai (in questo caso c’è vda, nel tuo sarà sda):
Welcome to fdisk (util-linux 2.36).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x682c9d55
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 41943039 39843840 19G 8e Linux LVM
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (41943040-83886079, default 41943040):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (41943040-83886079, default 83886079):
Created a new partition 3 of type 'Linux' and of size 20 GiB.
Command (m for help): p
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x682c9d55
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 41943039 39843840 19G 8e Linux LVM
/dev/vda3 41943040 83886079 41943040 20G 83 Linux
Command (m for help): w
The partition table has been altered.
Syncing disks.
Dopo aver creato la partizione, dovrai definire un nuovo Physical Volume LVM (PV).
sudo pvcreate /dev/sda3
Con sudo pvdisplay
vedrai il nuovo PV.
Quindi espandiamo il Volume Group (VG).
sudo vgextend fedora /dev/vda3
Con sudo vgdisplay
vedrai ora che la voce Free PE / Size
non sarà più 0/0
Ora possiamo espandere i logical volume fedora-root
e fedora-home
.
Per esempio assegniamo 10GB alla root /
:
sudo lvextend -L+10G /dev/fedora/root
Quindi espandiamo effettivamente il file system:
sudo resize2fs /dev/fedora/root
Con df -h
o con lsblk
vedrai che /
avrà una nuova dimensione. Con sudo vgdisplay
vedrai che quei Free PE
saranno un po’ diminuiti.