Linux Commands Examples

A great documentation place for Linux commands


resize an NTFS filesystem without data loss

see also : fdisk - cfdisk - sfdisk - parted - ntfsclone - mkntfs


ntfsresize [OPTIONS] --info(-mb-only) DEVICE

add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!


MISSING=$(plon_check_progs ntfsresize awk) \
|| { echo_error "error: $MISSING not found"; exit 1; }
|| { echo_error "error: $DEV is not a block device"; exit 3; }
PARTSIZE=$(ntfsresize -i "$DEV" | grep '^Current device size' | awk '{print $4}')
echo "error: plon.shm not found uin \$PATH"
exit 255
MISSING=$(plon_check_progs ntfsresize grep awk)
[ -z "$MISSING" ] || { echo_error "Missing program $MISSING"; exit 1; }
MINSIZE=$[$(LANG=C ntfsresize -i -n "$DEV" | grep 'You might resize at' | awk '{print $5}')+${MB_TO_ADD}000000]

MFT / NTLDR / NTFS (external drive) damaged after ntfsresize (Linux)

All Linux-based NTFS repair utilities are unfortunately rather limited in their scope and ability. Testdisk is the best you're going to get on the cross-platform side of things, and while it is awesome for recovering partitions and bootsectors it's really not what you're going to need if you damaged the NTFS filesystem itself. The best testdisk will do in that case is attempt to restore the MFT mirror. ntfsfsck/ntfsfix are severely neutered and have had parts of their recovery features/methods turned off from years ago due to being dangerous because of being incorrectly implemented or not fully understood when reverse-engineered.

If you have access to a Windows setup CD for Vista and above, use the command line feature from the "Startup Repair" to try chkntfs /f on the partition in question (if it can be seen). Failing that, it may be time to pull out your favorite file recovery tool for the retrieval of files from formatted volumes.

Free software: Testdisk's counterpart, photorec, does just that. I personally have had good experiences with Recuva from Piriform, but that's a Windows-only program so you'll need your hard disk connected to another Windows machine.

There are hard-core commercial NTFS file undelete applications, but honestly, they're almost never worth the hassle - if your partition is damaged enough to need them, you'll get your files back, but they probably will be incomplete/corrupted and won't actually open. Your best bet would be to use those tools to retrieve certain files by name.

Be forewarned: software that recovers files from deleted partitions can take up to several days to run a deep scan!


do ntfsresize and gparted work on a disk image mounted through the loop device?

Yes, loop devices are indistinguishable from 'normal' block devices for higher layer applications (like gparted). Loop device access doesn't change timestamp of mounted file: it is a bug.

Also, while kernel won't create partition subdevices, you can make them with kpartx if you need so (just in case).


After ntfsresize (ntfs resize), what is the exact line to type in for fdisk?

fdisk is an interactive partition table editor, so the only argument it needs is the hard disk device you want to work on.

If you resized the partition /dev/hda1, then yes, sudo fdisk /dev/hda is all you need. Or if you resized /dev/sdb2, then you need to run sudo fdisk /dev/sdb.

Once you get fdisk running, you'll have to delete the partition you resized, then recreate it with the new size. Make the new partition slightly larger than the size you requested in the ntfsresize step.

Remember, if you don't think you've done it right, you can always quit fdisk without writing the changed partition table, and restart fresh. Don't write out the new partition table until you're sure you've gotten it right.

Here's the list of commands to use from inside fdisk:

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes          <------ use this if unsure
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit         <------ don't do this until you're certain
   x   extra functionality (experts only)


The ntfsresize program safely resizes Windows XP, Windows Server 2003, Windows 2000, Windows NT4 and Longhorn NTFS filesystems without data loss. All NTFS versions are supported, used by 32-bit and 64-bit Windows. Defragmentation is NOT required prior to resizing because the program can relocate any data if needed, without risking data integrity.

Ntfsresize can be used to shrink or enlarge any NTFS filesystem located on an unmounted DEVICE (usually a disk partition). The new filesystem will have SIZE bytes. The SIZE parameter may have one of the optional modifiers k, M, G, which means the SIZE parameter is given in kilo-, mega- or gigabytes respectively. Ntfsresize conforms to the SI, ATA, IEEE standards and the disk manufacturers by using k=10^3, M=10^6 and G=10^9.

If both --info(-mb-only) and --size are omitted then the NTFS filesystem will be enlarged to the underlying DEVICE size.

To resize a filesystem on a partition, you must resize BOTH the filesystem and the partition by editing the partition table on the disk. Similarly to other command line filesystem resizers, ntfsresize doesn’t manipulate the size of the partitions, hence to do that you must use a disk partitioning tool as well, for example fdisk(8). Alternatively you could use one of the many user friendly partitioners that uses ntfsresize internally, like Mandriva’s DiskDrake, QTParted, SUSE/Novell’s YaST Partitioner, IBM’s EVMS, GParted or Debian/Ubuntu’s Partman.

IMPORTANT! It’s a good practice making REGULAR BACKUPS of your valuable data, especially before using ANY partitioning tools. To do so for NTFS, you could use ntfsclone(8). Don’t forget to save the partition table as well!

If you wish to shrink an NTFS partition, first use ntfsresize to shrink the size of the filesystem. Then you could use fdisk(8) to shrink the size of the partition by deleting the partition and recreating it with the smaller size. Do not make the partition smaller than the new size of NTFS otherwise you won’t be able to boot. If you did so notwithstanding then just recreate the partition to be as large as NTFS.

To enlarge an NTFS filesystem, first you must enlarge the size of the underlying partition. This can be done using fdisk(8) by deleting the partition and recreating it with a larger size. Make sure it will not overlap with an other existing partition. You may enlarge upwards (first sector unchanged) or downwards (last sector unchanged), but you may not enlarge at both ends in a single step. If you merge two NTFS partitions, only one of them can be expanded to the merged partition. After you have enlarged the partition, you may use ntfsresize to enlarge the size of the filesystem.

When recreating the partition by a disk partitioning tool, make sure you create it at the same starting sector and with the same partition type as before. Otherwise you won’t be able to access your filesystem. Use the ’u’ fdisk command to switch to the reliable sector unit from the default cylinder one.

Also make sure you set the bootable flag for the partition if it existed before. Failing to do so you might not be able to boot your computer from the disk.


Below is a summary of all the options that ntfsresize accepts. Nearly all options have two equivalent names. The short name is preceded by - and the long name is preceded by --. Any single letter options, that don’t take an argument, can be combined into a single command, e.g. -fv is equivalent to -f -v. Long named options can be abbreviated to any unique prefix of their name.
, --check

By using this option ntfsresize will only check the device to ensure that it is ready to be resized. If not, it will print any errors detected. If the device is fine, nothing will be printed.

-i, --info

By using this option without --expand, ntfsresize will determine the theoretically smallest shrunken filesystem size supported. Most of the time the result is the space already used on the filesystem. Ntfsresize will refuse shrinking to a smaller size than what you got by this option and depending on several factors it might be unable to shrink very close to this theoretical size. Although the integrity of your data should be never in risk, it’s still strongly recommended to make a test run by using the --no-action option before real resizing.

Practically the smallest shrunken size generally is at around "used space" + (20-200 MB). Please also take into account that Windows might need about 50-100 MB free space left to boot safely.

If used in association with option --expand, ntfsresize will determine the smallest downwards expansion size and the possible increments to the size. These are exact byte counts which must not be rounded. This option may be used after the partition has been expanded provided the upper bound has not been changed.

This option never causes any changes to the filesystem, the partition is opened read-only.

-m, --info-mb-only

Like the info option, only print out the shrinkable size in MB. Print nothing if the shrink size is the same as the original size (in MB). This option cannot be used in association with option --expand.

-s, --size SIZE[k|M|G]

Resize filesystem to SIZE[k|M|G] bytes by shifting its end and keeping its beginning unchanged. The optional modifiers k, M, G mean the SIZE parameter is given in kilo-, mega- or gigabytes respectively. Conforming to standards, k=10^3, M=10^6 and G=10^9. Use this option with --no-action first.

-x, --expand

Expand the filesystem to the current partition size, shifting down its beginning and keeping its end unchanged. The metadata is recreated in the expanded space and no user data is relocated. This is incompatible with option -s (or --size) and can only be made if the expanded space is an exact multiple of the cluster size. It must also be large enough to hold the new metadata.

If the expansion is interrupted for some reason (power outage, etc), you may restart the resizing, as the original data and metadata have been kept unchanged.

Note : expanding a Windows system partition and filesystem downwards may lead to the registry or some files not matching the new system layout, or to some important files being located too far from the beginning of the partition, thus making Windows not bootable.

-f, --force

Forces ntfsresize to proceed with the resize operation either without prompting for an explicit acceptance, or if the filesystem is marked for consistency check. Double the option (-ff, --force --force) to avoid prompting even if the file system is marked for check.

Please note, ntfsresize always marks the filesystem for consistency check before a real resize operation and it leaves that way for extra safety. Thus if NTFS was marked by ntfsresize then it’s safe to use this option. If you need to resize several times without booting into Windows between each resizing steps then you must use this option.

-n, --no-action

Use this option to make a test run before doing the real resize operation. Volume will be opened read-only and ntfsresize displays what it would do if it were to resize the filesystem. Continue with the real resizing only if the test run passed.

-b, --bad-sectors

Support disks having hardware errors, bad sectors with those ntfsresize would refuse to work by default.

Prior using this option, it’s strongly recommended to make a backup by ntfsclone(8) using the --rescue option, then running ’chkdsk /f /r volume:’ on Windows from the command line. If the disk guarantee is still valid then replace it. It’s defected. Please also note, that no software can repair these type of hardware errors. The most what they can do is to work around the permanent defects.

This option doesn’t have any effect if the disk is flawless.

-P, --no-progress-bar

Don’t show progress bars.

-v, --verbose

More output.

-V, --version

Print the version number of ntfsresize and exit.

-h, --help

Display help and exit.


Many thanks to Anton Altaparmakov and Richard Russon for libntfs, the excellent documentation and comments, to Gergely Madarasz, Dewey M. Sasser and Miguel Lastra and his colleagues at the University of Granada for their continuous and highly valuable help, furthermore to Erik Meade, Martin Fick, Sandro Hawke, Dave Croal, Lorrin Nelson, Geert Hendrickx, Robert Bjorkman and Richard Burdick for beta testing the relocation support, to Florian Eyben, Fritz Oppliger, Richard Ebling, Sid-Ahmed Touati, Jan Kiszka, Benjamin Redelings, Christopher Haney, Ryan Durk, Ralf Beyer, Scott Hansen, Alan Evans for the valued contributions and to Theodore Ts’o whose resize2fs(8) man page originally formed the basis of this page.


ntfsresize is part of the ntfs-3g package and is available from:

Ntfsresize related news, example of usage, troubleshooting, statically linked binary and FAQ (frequently asked questions) are maintained at:

exit codes

The exit code is 0 on success, non-zero otherwise.

known issues

No reliability problem is known. If you need help please try the Ntfsresize FAQ first (see below) and if you don’t find your answer then send your question, comment or bug report to the development team:

There are a few very rarely met restrictions at present: filesystems having unknown bad sectors, relocation of the first MFT extent and resizing into the middle of a $MFTMirr extent aren’t supported yet. These cases are detected and resizing is restricted to a safe size or the closest safe size is displayed.

Ntfsresize schedules an NTFS consistency check and after the first boot into Windows you must see chkdsk running on a blue background. This is intentional and no need to worry about it. Windows may force a quick reboot after the consistency check. Moreover after repartitioning your disk and depending on the hardware configuration, the Windows message System Settings Change may also appear. Just acknowledge it and reboot again.

The disk geometry handling semantic (HDIO_GETGEO ioctl) has changed in an incompatible way in Linux 2.6 kernels and this triggered multitudinous partition table corruptions resulting in unbootable Windows systems, even if NTFS was consistent, if parted(8) was involved in some way. This problem was often attributed to ntfsresize but in fact it’s completely independent of NTFS thus ntfsresize. Moreover ntfsresize never touches the partition table at all. By changing the ’Disk Access Mode’ to LBA in the BIOS makes booting work again, most of the time. You can find more information about this issue in the Troubleshooting section of the below referred Ntfsresize FAQ.

see also

fdisk , cfdisk , sfdisk , parted , evms, ntfsclone , mkntfs , ntfsprogs


ntfsresize was written by Szabolcs Szakacsits, with contributions from Anton Altaparmakov and Richard Russon. It was ported to ntfs-3g by Erik Larsson and Jean-Pierre Andre.

How can this site be more helpful to YOU ?

give  feedback