Modifying Linux ext3 disk size on non-LVM systems (grow/shrink)

# the example here uses the hard drive /dev/sdb and the partition /dev/sdb1. Watch the numbers! Also note that you might need a boot cd in recovery mode or other system to resize the hard rive you are system hdd.
# To grow, follow the steps below. To shrink, swap Blocks 2 and 3…

## BLOCK 1 START ##
reboot # to reload the HDD details in case you increased the HDD via VMWare
umount /dev/sdb1 # unmount the partition
fsck -n /dev/sdb1 # check if the partition is ok
tune2fs -O ^has_journal /dev/sdb1 # remove journal / convert to ext2 partition
e2fsck -f /dev/sdb1 # do another file system check
## BLOCK 1 END ##

 

## BLOCK 2 START ##
fdisk -l /dev/sdb # list the hdd details. Record this data (just in case…)
fdisk -l /dev/sdb1 # list the partition details. Record this data (just in case…)
fdisk /dev/sdb # start fdisk to edit the partition table

d # delete the existing partition (this will not be done until we write, so don't worry)
1 # chose the required partition. If only one is available, it will be automatically selected
n # create a new partition
p # primary partition (or chose e in case it was an extended one before)
1 # give it the same partition number as before (1 in our example)
1 # start sector (or just press enter
size # just press enter or enter the new size

# add bootable flag if required ->
a
1
# <-

w # write changes to disk
reboot # for the OS to detect the partition table changes
## BLOCK 2 END ##

## BLOCK 3 START ##
umount /dev/sdb1 # in case the partition got remounted during the reboot (shouldn't though as the ext3 entry in the fstab mismatches the current ext2 partition
resize2fs /dev/sdb1 # grow the partition to maximum size
## BLOCK 3 END ##

## BLOCK 4 START ##
fsck -n /dev/sdb1
tune2fs -j /dev/sdb1 # recreate the journal / change back to ext3
reboot
## BLOCK 4 END ##