Saturday, June 17, 2006

Resize NTFS partitions

Whether you need to install Linux on an XP box, or if you just want to make another partition on your Windows box, Linux contains a great set of tools for resizing NTFS.
The ntfsresize command is a part of ntfsprogs (http://www.linux-ntfs.org). The site contains much more information .. but I just thought it's always good to read one more experience.

So .. to resize your partition you have to:
1. Use ntfsresize to actually physically resize the partition
2. Update your partition table using fdisk.

Note: This is the experience I had on Mandriva and Fedora, don't know about Debian based editions.

basic assumptions:
the partition we are resizing is /dev/hda1
we want to resize it to 8Gig
We have some bad sectors on the disk (typical in older computers)

First, resize your partition (assuming the partition name is /dev/hda1):
1. This command will just tell you how much is used from the partition
ntfsresize --no-action -b --info /dev/hda1

2. This command will simulate the resize (assuming we want to resize to 8Gig)- always a good idea if you care about the source
ntfsresize --no-action -b -s 8000M /dev/hda1

3. This is the actual resize command
ntfsresize -b -s 8000M /dev/hda1

Then - you have to redo your partition table:
run : fdisk /dev/hda1
p - to see your current settings (write them down)
d - delete the ntfs partition you just resized
n - add a new partition (make sure the starting cluster is the same is the one you deleted), allocate a new size to the partition - it must be at least the same or bigger than the resized size.
a - if necessary, toggle the boot flag on the partition
w - write partition table and exit

All set - you now have a freshly minted and resized ntfs partition.
As always - if the data on the ntfs partition is critical - make sure to back it up before the process.

Enjoy!