Ntfsresize

From Wsms

Jump to: navigation, search

Note: This page should be titled ntfsresize (all lowercase). It is Ntfsresize due to technical limitations of Mediawiki.


Contents

ntfsresize

ntfsresize is a command-line utility that resizes ntfs partitions.

common usage

Resize the ntfs file system on /dev/hda1 to match the new larger allocation for the partition:

# ntfsresize /dev/hda1

scenario

I purchased a Seagate Free Agent 320G USB hard drive. It came as one giant ntfs partition. I boot mckinley with Knoppix 4.0.2, plug in the USB drive, watch dmesg to see that the drive is recognized a /dev/sdb, then I run fdisk:

root@2[knoppix]# fdisk -l /dev/sdb

Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       38913   312568641    7  HPFS/NTFS

I want it to have two partitions - one ntfs and one ext3. First run ntfsresize with the info option.

root@1[knoppix]# ntfsresize --info /dev/sdb1
ntfsresize v1.11.3-WIP
Device name        : /dev/sdb1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 320070287872 bytes (320071 MB)
Current device size: 320070288384 bytes (320071 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 30572 MB (9.6%)
Collecting resizing constraints ...
You might resize at 30571720704 bytes or 30572 MB (freeing 289499 MB).
Please make a test run using both the -n and -s options before real resizing!

Do a dry run of the resize command:

root@1[knoppix]# ntfsresize --no-action --size 150G /dev/sdb1
ntfsresize v1.11.3-WIP
Device name        : /dev/sdb1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 320070287872 bytes (320071 MB)
Current device size: 320070288384 bytes (320071 MB)
New volume size    : 149999993344 bytes (150000 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 30572 MB (9.6%)
Collecting resizing constraints ...
Needed relocations : 266709 (1093 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 ...
The read-only test run ended successfully.

Then the real thing...

root@1[knoppix]# ntfsresize --size 160G /dev/sdb1
ntfsresize v1.11.3-WIP
Device name        : /dev/sdb1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 320070287872 bytes (320071 MB)
Current device size: 320070288384 bytes (320071 MB)
New volume size    : 159999996416 bytes (160000 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 30572 MB (9.6%)
Collecting resizing constraints ...
Needed relocations : 165712 (679 MB)
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
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 ...
Syncing device ...
Successfully resized NTFS on device '/dev/sdb1'.
You can go on to shrink the device e.g. with 'fdisk'.
IMPORTANT: When recreating the partition, make sure you
  1)  create it with the same starting disk cylinder
  2)  create it with the same partition type (usually 7, HPFS/NTFS)
  3)  do not make it smaller than the new NTFS filesystem size
  4)  set the bootable flag for the partition if it existed before
Otherwise you may lose your data or can't boot your computer from the disk!

The next steps are to repartition the disk with fdisk, grow the sdb1 with ntfsresize, and run chkdsk /f on a windows system.

Tips

see also

man ntfsresize. This is not available on Fedora, as installed, but is on Knoppix.
http://mlf.linux.rulez.org/mlf/ezaz/ntfsresize.html. This site is frequently unavailable, but you can access its contents in google cache.
Sfdisk
Fdisk
Dd
Partimage
Gparted
Linux_commands
How to have Documents and Settings on a different partition

Personal tools