How to expand disk space?


I have a virtual server with the vyos operating system. Through the hosting control panel, I increase the disk space /dev/sda. What actions should I do at the operating system level? These steps give a mistake:

fdisk -l

echo 1 > /sys/block/sda/device/rescan

3. parted
Partition type? primary/extended? extended
Start? XX.XMB


4. fdisk /dev/sda
Command (m for help): n
Command action

l logical (5 or over)

p primary partition (1-4)

First sector (XXX-YYY, default ZZZ): 

Last sector, +sectors or +size{K,M,G} (XXX-YYY, default ZZZ):
Command (m for help): t

Partition number (1-X): X

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

5. partx -v -a /dev/sda

6. resize2fs /dev/sda5


Looks like you’re trying to resize a mounted partition.
Use a linux live disk and start the VM with that, from the live system use
parted to show the systems’ partitions:

parted /dev/sda

(parted) print

Now write down the partition number you want to resize (if there’s
only one disk/partition it should be number one).
Now use parted resizepart to actually resize the partition:

(parted) resizepart

You’ll be be prompted for the partition number and the new
endpoint of the partition (in MB). If you run parted print
again it should show you the new sized partition.