HowToResizeAnExt3Partition: Easy when you know how

Once, we had a disk split into two NTFS partitions. We now have a disk with one ext3 partition. This involved a fair amount of juggling of files and partitions around, which was fun. One of this things I had to do was create a Linux partition, move files into it then resize it to fill up the disk.

Here’s how to resize an ext3 Linux partition. for future reference.

1. Remove the journal to make it ext2

 tune2fs -O^has_journal /dev/hdb1

2. Use fdisk to delete and resize the partition

 fdisk /dev/hdb
 Command (m for help): d
 Selected partition 1Command (m for help): n
Command action
e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-9964, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-9964, default 9964): Using default value 9964
 Command (m for help): p
 Disk /dev/hdb: 81.9 GB, 81964302336 bytes
 255 heads, 63 sectors/track, 9964 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Device Boot  Start    End     Blocks     Id  System
 /dev/hdb1    1        9964    80035798+  83  Linux
 Command (m for help): w
 The partition table has been altered!

3. Check the partition for errors

 e2fsck -f /dev/hdb1

4. Resize it

 resize2fs /dev/hdb1

5. Check it again.

 e2fsck -f /dev/hdb1

6. Re-create the journal

 tune2fs -j /dev/hdb1

7. Check it again!

 e2fsck -f /dev/hdb1

8. Finally, mount it

 mount /mnt/f
 Filesystem Size  Used Avail Use% Mounted on
 /dev/hdb1  76G   25G   47G  35% /mnt/f


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.