Differences
This shows you the differences between two versions of the page.
— | tech:linux:resize_partition [2025/02/10 12:29] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Resize Partition (with preserving data) ====== | ||
+ | Steps to resizing partition without losing data | ||
+ | <code bash> | ||
+ | PARTNUM=1 | ||
+ | MPNAME=/ | ||
+ | # | ||
+ | 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, Ignore Message Disk /dev/sxx1 doesn' | ||
+ | fdisk -l $MPNAME1 | ||
+ | # Remount (assuming this has entry in fstab) | ||
+ | mount -a | ||
+ | </ | ||
+ | |||
+ | Ref: http:// | ||