pc Loft.it

Aumentare spazio disco freepbx centos vbox

Come prima attività verifichiamo le partizioni presenti:

#fdisk -l

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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 label type: gpt
Disk identifier: C477DAA5-AD6E-43EC-9B3D-D7AC891AF115


#         Start          End    Size  Type            Name
 1         2048       147455     71M  EFI System      EFI System Partition
 2       147456      4243455      2G  Microsoft basic           <—— Partizione 1
 3      4243456     33550335     14G  Linux LVM                <—— Partizione 2

 

Quindi verifichiamo le partizioni utilizzate e lo spazio libero creato:

#parted /dev/sda print free

Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
        17.4kB  1049kB  1031kB  Free Space
 1      1049kB  75.5MB  74.4MB  fat16        EFI System Partition  boot
 2      75.5MB  2173MB  2097MB  ext4
 3      2173MB  17.2GB  15.0GB                                     lvm

 

25.0GB 270GB 245GB Free Space <——– Spazio libero creato

 

Creiamo la nuova partizione utilizzando lo spazio appena creato:
#fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (48861184-526546175, default 48861184):
Using default value 48861184
Last sector, +sectors or +size{K,M,G} (48861184-526546175, default 526546175):
Using default value 526546175
Partition 3 of type Linux and of size 227.8 GiB is set

Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 31
Changed type of partition ‘Linux’ to ‘Linux LVM’

Command (m for help): w
The partition table has been altered!

eseguiamo la riscansione delle partizioni:
# partprobe -s
/dev/sda: msdos partitions 1 2 3

verifichiamo le partizioni presenti:
# fdisk -l

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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 label type: gpt
Disk identifier: C477DAA5-AD6E-43EC-9B3D-D7AC891AF115


#         Start          End    Size  Type            Name
 1         2048       147455     71M  EFI System      EFI System Partition
 2       147456      4243455      2G  Microsoft basic
 3      4243456     33550335     14G  Linux LVM
 4     33550336     41943006      4G  Linux LVM   <—— Partizione 3 creata

Disk /dev/mapper/SangomaVG-root: 17.6 GB, 17578328064 bytes, 34332672 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 /dev/mapper/SangomaVG-swaplv1: 1719 MB, 1719664640 bytes, 3358720 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

Quindi inizializziamo il PhisicalVolume per il suo successivo utilizzo nel nostro LVM:

#pvcreate /dev/sda4
Physical volume “/dev/sda4” successfully created.
# vgdisplay
— Volume group —
VG Name SangomaVG
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 21.34 GiB
PE Size 4.00 MiB
Total PE 5464
Alloc PE / Size 5464 / 21.34 GiB
Free PE / Size 0 / 0
VG UUID Pcc0pu-mUbd-rOg0-V4iI-5jdO-sVUp-tk6Icd

Inseriamo il volume nel nostro volume logico SangomaVG:

# vgextend SangomaVG /dev/sda4
Volume group “SangomaVG” successfully extended

Infine estendiamo il filesystem esistente all’intero spazio disponibile sul volume:

# lvresize -r -l+100%FREE /dev/mapper/SangomaVG-root
Size of logical volume SangomaVG/root unchanged from <247.12 GiB (63262 extents).
Logical volume SangomaVG/root successfully resized.

A questo punto il nostro volume è stato allargato, lo possiamo verificare facilmente con il comando df -lh.