This has not been the first time I have tried, but it has been the first time it has worked. And the best of it, no Partition Magic or (qt)parted is needed, just pure old tune2fs, resize2fs and fdisk (read the man pages and backup everything as usual
).
In order to resize it, the partition should not be mounted. You should read the full post before start issuing any commands.
As an example we are going to resize /dev/sda1 from 200G to 50G. Since the partition is the primary /root we need to use a rescue disk to boot the system, I used BackTrack from a USB stick (Howto:USB Stick).
tune2fs to remove the journal from your ext3 partition:
tune2fs -O ^has_journal /dev/sda1
Now the partition is effectively an ext2 file system.
resize2fs /dev/sda1 50G” to resize the file system.resize2fs /dev/sda1” (no size this time) to resize the file system to the maximum available.tune2fs to add the journal agai:
tune2fs -j /dev/sda1
This turns the partition back to ext3.
Regarding the new size for the partition, it is important to allocate enough physical space to support the file system. I used the formula recommended by [2]:
We multiply the amount of blocks from the resize2fs output (1536000) by the size of a block (4k), and to go sure the partition is big enough, we add 3 to 5% to it (3% was enough for me, but if you want to go sure take 5%):
1536000 * 4k * 1.03 = 6328320k
The interesting number is the first one, and you can get it by looking at the output of resize2fs on step 2. You just need to specify that number when asked by fdisk (step 3) for the last cylinder of the new partition. Again from the same reference:
Last cylinder or +size or +sizeM or +sizeK (1-1247, default 1247): +6328320K
Note that this is not the vaule I used (I forgot to write it down), but I guess that this number depends on the hardware and the important bit is to learn how to apply The Formula.
This post consists of 100% recycled information, credit goes to:
Support for ext3 was added to resize2fs in version 1.19, more than 7 years ago. There is no reason to convert to ext2 first unless you are running a REALLY old system.
So you may avoid steps 1 and 5 if your resize2fs supports ext3. ![]()