#!/bin/bash

FDISK=$(which fdisk)

expand_debian10() {
$FDISK /dev/vda <<EOF
d
5
d
2
n
e



n


N
w
EOF
partprobe /dev/vda
pvresize /dev/vda5
FREE_SIZE=$(pvs|grep vda5|awk '{print $6}'|awk '{print substr($0, 1, length($0) - 1)}'| awk '{s=substr($0,2); print s}'|awk -F '.' '{print $1}')
lvextend -L+${FREE_SIZE}G /dev/debian10-vg/root
resize2fs /dev/debian10-vg/root
}
expand_debian10
