Table of Contents

Resize Partition (with preserving data)

Steps to resizing partition without losing data

PARTNUM=1
MPNAME=/dev/sda
#
MPNAME1=${MPNAME}${PARTNUM}
#
# Unmount partition
umount $MPNAME1
# Check file system
fsck -n $MPNAME1
#
fdisk -l $MPNAME1
fdisk $MPNAME
# Inside fdisk, do the below
# p - print partition table
# d - delete said partition
# n - create new partition
# w - to write changes back
#
# Check file system
e2fsck -f $MPNAME1
# To resize to full partition size
resize2fs $MPNAME1
# Get size
fdisk -l $MPNAME1
# Remount (assuming this has entry in fstab)
mount -a

Ref: http://www.htmlgraphic.com/how-to-resize-partition-without-data-loss-part-2-of-3/