How to increase size of filesystem to match partition

filesystemsgpartedlvmpartitionresize2fs

Apologies for this question but I am very new to Linux.
When I installed my Fedora distribution I only allocated 20GB of my hard drive space for its partition. I recently used GParted and tried to increase the size of the partition to around 40GB. I was under the impression that I was successful but today I tried to create a directory and I got the following error message:

mkdir: cannot create directory ‘b_scripts’: No space left on device

I checked the space on my disk and found out that I had used 20GB on my fedora-root.

derrick@dazza >> df -h 
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G  253M  1.7G  14% /dev/shm
tmpfs                    1.9G  1.5M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root   20G   19G     0 100% /
tmpfs                    1.9G  128K  1.9G   1% /tmp
tmpfs                    386M   20K  386M   1% /run/user/42
tmpfs                    386M   28K  386M   1% /run/user/1000

Is a partition different from a Filesystem? How come there are only 20GB in total allocated to my fedora-root?
What is my solution? How do I increase the size of my fedora-root Filesystem so that it is more than 20GB Size?

Best Answer

In this case, your file system is on the LV(Logical Volumne), which is on the partition. If you expand the partition, your LV will not be expanded.

Please run these commands :

pvresize <device name> <-- This will let the Physical Volume know that the partition it is on has been expanded.

And :

lvextend -l +100%FREE /dev/mapper/fedora-root <Physical Volume name> <-- This will extend the LV.

resize2fs /dev/mapper/fedora-root

PS: You can find the Physical Volume name using the command pvs

Thank you @Dani_l for the edit suggestions.

Related Question