Linux

Resizing a partion.

I had some difficulty figguting out how to resize a partion, so I thought I’d document it for future use (since I’m sure I will do this again).

I mounted the drive in another installation of the OS, ran Yast, and did the resize of the partition.

Once that was done, yast was displaying the new partion size (9.5GB) but df -h showed the original size (900MB).

I followed this link to solve the problem.

In summary,

Run:

#fdisk /dev/xvdd -l
Disk /dev/xvdd: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00007638
Device Boot      Start         End      Blocks   Id  System
/dev/xvdd1   *           1        1241     9960300   83  Linux
/dev/xvdd2            1242        1305      514080   82  Linux swap / Solaris

Take the number of blocks (9960300) and divide by four (9960300/4=2490075)

Then run:

# resize2fs -p /dev/xvdd1 2490075
resize2fs 1.41.9 (22-Aug-2009)
Resizing the filesystem on /dev/xvdd1 to 2490075 (4k) blocks.
Begin pass 1 (max = 68)
Extending the inode table     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/xvdd1 is now 2490075 blocks long.

That’s it. Now df -h reports the correct value.

Leave a Reply

Your email address will not be published. Required fields are marked *