Friday, October 28, 2016

Safely Enlarging a Linux /home Partition

I recently cloned a 1TB server hard drive onto a 1.2TB disk, using Clonezilla. This resulted in 0.2TB being unutilized, so I had to enlarge it. But how to do so without losing your data? Something like this (in my case, I needed to enlarge /dev/sda3, a primary partition):
# fdisk /dev/sda
Print the current partition table (so you can note the starting cylinder of the partition you're going to enlarge).

After noting the starting cylinder, delete the third partition.

Re-create the third partition. You MUST make sure it starts with the cylinder noted above! In my case, this was all just defaults. When done, just write the table to disk and reboot.

Next, you'll use the resize command in Linux to expand the file system to match the partition it's on.
# resize2fs /dev/sda3
Here is what I was presented with, information-wise. The process took merely about a minute.
resize2fs 1.41.12 (17-May-2010)Filesystem at /dev/sda3 is mounted on /home; on-line resizing requiredold desc_blocks = 55, new_desc_blocks = 67Performing an on-line resize of /dev/sda3 to 279054750 (4k) blocks.The filesystem on /dev/sda3 is now 279054750 blocks long.
Very painless!

Before (df -h):
/dev/sda3       865G  7.2G  814G   1% /home

After (df -h):
/dev/sda3       1.1T  7.2G  988G   1% /home

No comments:

Post a Comment