This took me around 10 minutes to execute.Here is how you can extend/increase your ext3 partition size, without any data loss.
Just in case always do backup before you make any modifications to the partition table.Although this could be considered safe,a bit can flip and kiss your data GoodBye!
First unmount your partition,if it is not an attachable storage you will need to boot in rescue mode and unmount it from there.In my case it is attachable /dev/hdb storage.
umount /dev/hdb1
Check the partition before doing anything to it:
fsck -n /dev/hdb1
Next remove the journal from /dev/hdb1, this will turn it into an ext2 partition:
tune2fs -O ^has_journal /dev/hdb1
Use fdisk to delete current /dev/hdb1 partition and create a bigger one.There should not be any data loss, but just in case make sure you have backup,these operations are always dangerous!
fdisk /dev/hdb
Let’s print out the partition table:
Command (m for help): p Disk /dev/hdb: 268.4 GB, 268435456000 bytes 255 heads, 63 sectors/track, 32635 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdb1 1 19582 157286368+ 83 Linux
Now lets delete partition ā1 (/dev/hdb1):
Command (m for help): d Selected partition 1
Make sure the partition is not there:
Command (m for help): p Disk /dev/hdb: 268.4 GB, 268435456000 bytes 255 heads, 63 sectors/track, 32635 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
Create a new one, i will use 1 cause it is the only partition:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-32635, default 1): (press enter) Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-32635, default 32635):(press enter) Using default value 32635
Print again the partition table and see it there:
Command (m for help): p Disk /dev/hdb: 268.4 GB, 268435456000 bytes 255 heads, 63 sectors/track, 32635 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdb1 1 32635 262140606 83 Linux
Write these changes to the disk:
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. \Syncing disks.
Initiate a disk check just in case:
e2fsck -f /dev/hdb1
Execute the “holy grail” for which it was all about.In other words, increase the space:
resize2fs /dev/hdb1
Lets return the partition to ext3 journal:
tune2fs -j /dev/hdb1
Mount the partition:
mount /dev/hdb1
Check the newly created space:
df -h Filesystem Size Used Avail Use% Mounted on /dev/hdb1 247G 144G 90G 62% /BACKUP
This is how you would extend Linux ext3 partition, hopefully you got the idea.There are many different cases where this example could apply with someĀ modifications.
You can also find more methods here.