From your fdisk
output, it looks that you indeed have a 80 GB disk with 40 GB extended partition (/dev/vda2
) which contains inside a 40 GB logical partition /dev/vda5
which holds your /
filesystem. Extended partition does not actually contain any files, it's just a "container" for logical partitions that allows to overcome the 4 partitions limit that I mention below. Then there is 40 GB of unallocated space which fdisk
doesn't show in any way.
You may have several options how to use that unallocated space. I assume you are not using LVM because if you do, the procedure would be completely different, as LVM has it's own tools to resize volumes. However your fdisk
output does not indicate any mention of LVM partition.
I would not recommend deleting and recreating partitions in fdisk
as this always causes a risk to lose data. So if you want to do it safely, you can try the following:
First option is to have two 40 GB partitions and intelligently split your files between these two. If you for example keep a lot of large files in /home
, you can use the new partition for /home
and everything else except /home
will stay on the old partition. To do this:
use fdisk
to create another primary partition (it will probably appear as /dev/vda3
!) in that unallocated space and format it as a new Linux filesystem with mkfs /dev/vda3
. There can be maximum 4 primary or extended partitions in total, with at most one of them being extended, so there's room for another partition. It is not a recommended partition layout where a primary partition comes after the extended partition, but it probably will work.
rename your /home
directory to /old_home
(make sure it's not being used at the moment, so do it from root with no regular user logged in) and create a new /home
directory with the same owner and permissions as the old one.
mount the /dev/vda3
filesystem under /home
with the command: mount /dev/vda3 /home
. If this succeeds, you should edit /etc/fstab
to have the new filesystem properly automounted when the system boots. Probably your /etc/fstab
currently contains two lines for vda1 and vda5, something like this (I'm making this one up now, yours may be different):
/dev/vda5 / ext4 defaults 0 1
/dev/vda1 /boot ext4 defaults 0 2
Add a similar line for vda3 that says for example:
/dev/vda3 /home ext4 defaults 0 2
(if your file has something else instead of "ext4" or "defaults" just copy these parameters to the new line). Now write any file to the new /home
directory and reboot the system. If after reboot the file you put in the /home
directory is still there, it means /home
has been correctly mounted at boot.
Now you can move everything from /old_home
to /home
and then delete the empty /old_home
directory.
I consider this method usually safest and easiest for me and have used it multiple times. However, it has the drawback of having actually 2x40 GB instead of single 80 GB of space, which may be sometimes good, sometimes bad - for example when you want to avoid accidental filling up of the system disk with user files, it's better to have /home
as separate partition.
So another option is to use GNU parted program to resize your vda2 and vda5 partitions (first vda2 and then vda5, as the former contains the latter) to 80 GB. parted
is designed specifically to modify partitions without losing data, which fdisk
can not guarantee. I'm sure parted
is in the Debian repository, so you can install it with apt
.
After you have resized the partition, use the command resize2fs /dev/vda5
to extend your /
filesystem to full 80 GB.