In our example, there is only one partition. It is called /dev/vda1 and has a capacity of 5GB. The hard disk itself has a capacity of 10GB. Let's expand /dev/vda1 to 10GB.
- Run d to delete the existing partition. Then n is for creating a new one, p is for primary, 1 is the partition number; and indicates the beginning and end of the section in sectors. The start sector must match the start sector of the partition that was deleted. The screenshot shows that this is 2048. We select the last sector of the partition as much as possible. In our case, fdisk offers us 20971519. We will enter it.
- Once again p - to make sure that the partition has now grown to the size we need. And w is for writing and exiting fdisk.
After that, we will receive a warning that the device is mounted and the superblock is not available and the volume of the partition will be changed after the OS is restarted.
Reboot the OS - reboot
After the reboot, we need to expand the FS to the entire partition. Let's do this with the resize2fs /dev/vda1 command
- Next, df -h - to make sure everything worked out.