Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Resize partitions with LVM volumes

Leer en espanol
Resize partitions with LVM volumes

Table of contents

We check how much esp ===

As in the previous entry, we are going to see how to extend a logical and physical volume to expand a file system but this time the disk is partitioned

We check how much space the disk has

Bash
fdisk -l /dev/sda2

Disk /dev/sda2: 50 GB, 53687091200 bytes

We rescan the disk

Bash
echo 1 > /sys/block/sdb/device/rescan

echo ‘1’ > /sys/class/scsi_disk/0\:0\:0\:0/device/rescan

We check the disk size again

Bash
fdisk -l /dev/sda2

Disk /dev/sdb: 60 GB, 64424509440 bytes

We create a new primary partition

Bash
fdisk /dev/sda
Orden (m para obtener ayuda): n

Acción de la orden

e   Partición extendida

p   Partición primaria (1-4)
p

Número de partición (1-4): 3

Primer cilindro (1-19457, valor predeterminado 1):

Último cilindro, +cilindros o +tamaño{K,M,G} (1-3232, valor predeterminado 3232):

Se está utilizando el valor predeterminado 3232
Orden (m para obtener ayuda): t

ex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help):  w

Finally we run partprobe to reread the disks

text
partprobe

We check that we now have a new partition with 10GB

Bash
fdisk -l /dev/sda3

Disk /dev/sda: 10 GB, 10737418240 bytes

We create the physical volume with the new disk

text
pvcreate /dev/sda3

We add the disk to the VG

To check the VG where we want to add the disk we use the vgdisplay command

text
vgextend vg_app  /dev/sda3
lvextend -l+100%FREE  /dev/vg_app/lv_web

We resize the disk

text
resize2fs /dev/mapper/vg_app/lv_web

All the best.

Comments