ResizeNTFS

From Wiki
Jump to: navigation, search

You have got Windows XP/2000 installed on your machine with NTFS filesystem. Now, you want to install GNU/Linux also but still want to keep your Windows partition for some reason(s). Here is a sweet and simple way to do it using ntfstools. Although, I've done it on Ubuntu Intrepid 8.10 Live CD, you can use any live GNU/Linux CD along with compatible libntfs and ntfstools packages.

1. Defragment the filesystem while you are in Windows. 2. Run a complete test on the disks and reboot twice.

chkdsk /f   

3. Use Ubuntu CD and boot from it into GNU/Linux. Press ALT-F2 and run:

:~$ fdisk -lu

Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x50000000

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1              63      240974      120456   de  Dell Utility
/dev/hda2   *      241664     4435967     2097152    7  HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/hda3         4435968   111410774    53487403+   7  HPFS/NTFS

This prints the output of the partition table in sectors. Let's save it.

4. This command will show you the minimum partition size to which it can be shrunk:

# ntfsresize -if /dev/hda3

ntfsresize v1.9.4
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 31999996416 bytes (32000 MB)
Current device size: 32078559744 bytes (32079 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 12790 MB (40.0%)
Collecting shrinkage constrains ...
Estimating smallest shrunken size supported ...
File feature         Last used at      By inode
$MFT               :      3343 MB             0
Multi-Record       :     20597 MB         19865
You might resize at 12789129216 bytes or 12790 MB (freeing 19210 MB).
Please make a test run using both the -n and -s options before real resizing!


5. It says we can safely shrink the filesystem to 12790MB. Say, we want to make NTFS partition size as 15G, we'll run:

# ntfsresize -f -s 15G /dev/hda3

ntfsresize v1.9.4
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 31999996416 bytes (32000 MB)
Current device size: 32078559744 bytes (32079 MB)
New volume size    : 14999994880 bytes (15000 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 12790 MB (40.0%)
Collecting shrinkage constrains ...
Needed relocations : 691084 (2831 MB)
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...


6. We've successfully shrunk the filesystem, now we've to resize the partition accordingly. You can use your favourite partitioning tool like fdisk, cfdisk, sfdisk etc. The only precaution that needs to be taken is to keep the starting cylinder of the partition same as original. Also, the partition should be 20-200MB larger than the size of the shrunk filesystem. We can safely chose our partition size as 15200MB as our filesystem is of 15000MB. And, don't forget to set the bootable flag ON for the NTFS partition or you will not be able to boot into the Windows.


7. ntfsresize marks the filesystem dirty and forces chkdsk to be run on the reboot. Reboot the machine into Windows, and you should see chkdsk running on the blue screen.

Personal tools
Namespaces
Variants
Actions
Navigation
Content
Toolbox