Tell me the best way to extend ext4 partition and filesystem?
I have a 400GB disk with a 320GB ext4 partition. I would like to grow the ext4 partition to use the left space (80GB of free space).
+--------------------------------+--------+
| ext4 | Free |
+--------------------------------+--------+
What should i do to do it?
I've seen people using resize2fs
but I don't understand if it resizes the partition.
Another solution would be to use fdisk
but I don't want to delete my partition and loose data. How does a given grow partition work without loosing a file?
Note: i'm talking about an un-mounted data partition without lvm and i have backups, but i'd like to avoid spending some time on recovery.
You should start with unmounted partitions If you can't unmount it (e.g. it's your root partition or something else the system needs to run), use something like System Rescue CD instead.
Run
parted
, orgparted
if you prefer a GUI, and resize the partition to use the extra space. I prefergparted
as it gives you a nice graphical representation, very similar to the one you've drawn in your question.resize2fs /dev/whatever
e2fsck /dev/whatever
(just to find out whether you are on the safe side)Remount the partition
While i have never seen this fail remember to backup your data first