Wednesday, September 10, 2008

Games with ntfsresize

Resizing with the GUI was a breeze, but for some reason I felt this overwhelming urge to try using the ntfsresize tool to do the same job.
Since Ntfsresize will not proceed with a "flagged" NTFS partition, I had to boot into XP to get the chkdsk /f routine done. Ntfsresize is a deep tool which can first estimate the amount of reducing that can be done, and then do it without really writing stuff to the disk, and then finally doing the whole hog.
ntfsresize -fi /dev/sda will give the reducable size of the partition.
ntfsresize /dev/sda -n -s XXXXM will do a dry run of the process of reducing the parition to XXXX MB
And without the -n option the actual process is launched.
The -n option is a good way to check if there would be any hiccups during the process.
The major issue with ntfsresize is that it does not actually make changes in the partition table as well. This means that while the partition would have effectively been reduced by transferring data existing at the end of the partition to other areas, and updating the MFT to reflect the changes in the addresses, the Parition table itself still shows the old size.
Therefore after the process is completed, ntfsresize suggests ways to modify the partition table to reflect the new size. These instructions are important, and it is best to write them down before proceeding. One critical area which could create problems is in the way fdisk displays partition sizes by default - as cylinders. ntfsresize explicity warns the user to change this behaviour of fdisk for a successfull completion of the resize. Fdisk needs to be set to display partition information in sectors.
Once this is done, the old partition can be deleted, and a new one created which starts at the same sector as the older parition. Ofcourse the final size has to be more than the figure used in the ntfsresize command.
The problem with fdisk is that it renames paritions without informing the user, and this causes a lot of heartache since the system is rendered non bootable if the partition names and positions are not in sync. To rectify the renaming, again fdisk needs to be resorted to, and since the system is not booting this means getting a live CD for this purpose.
The final word is that this is a rare instance where the GUI proves to be a better option than the command line.

No comments: