You need to remove swap partition, extend the data partition and re-create the swap if you need it.
If you have enough free memory (swap is not used much), you may do this without interruption the service. Begin with: swapoff /dev/vda2
, to release the swap. If you unable to do that (not enough memory), you'll need to stop memory-consuming services until you can disable swap.
After successfull swapoff, run fdisk /dev/vda
and remove the second partition.
Now decide how much swap do you need and calculate where should it begin. For instance, if you want to have exactly 8 GiB (16777216 sectors) swap as you have now, and you have exactly 150 GiB (314572800 sectors) disk, your swap should begin at sector 314572800-16777216 = 297795584. So create new vda2 partition of type 82 (Linux swap), which begins on this sector and the 314572799 (it should suggest this value by itself). Don't use my numbers blindly, calculate them yourself, because I made an assumption about the disk size — you somewhat hide parts of information that could make this calculation exact. (And in the future don't post screenshots of the console, but just copy and paste it as text, that's much better. And don't omit such information as disk partitioning, better copy complete output; it couldn't be used to identify you or to do any harm, but makes life easier.)
When you recreated swap partition at the end of the drive, you may extend your first partition. It is described in detail in this answer, so I just outline it here and you can always refer there for the details.
Notice your vda1
begins at sector 2048. This is very important!
- Remove the first partition. Yes, do it. Yes, on the running system. Nothing will happen and nothing will be lost.
- Create new partition 1, it should begin at exact sector 2048 and end at or past the current last sector, 188745727. Make sure your new partition begins at 2048 and is not any smaller that it was! Also notice, it may detect a file system signature and suggest to wipe it. Don't wipe.
- Commit changes to disk (
w
), fdisk should exit and say that partition table is written, but kernel still uses old partition table. Use kpartx
or partprobe
to reload it, as it suggests. Or disable swap in /etc/fstab
and reboot (you need to disable it for it to not halt boot due to missing swap signature).
- At this point your
lsblk
should already show new partition size. You may extend the file system with resize2fs /dev/vda1
. As for swap, create new swap structure with mkswap /dev/vda2
and, if /etc/fstab
refers to swap using UUID, update it with new value that mkswap had printed to you.