Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any tools that I can use to defrag my Windows partition from Linux?

share|improve this question
up vote 10 down vote accepted

Yes, you can use shake. You'll first need to add a custom repository to your system:

sudo add-apt-repository ppa:un-brice/ppa
sudo apt-get update
sudo apt-get install shake-fs

Then you can do

sudo shake /some/dir
share|improve this answer
Shake isn't quite a defragmenter, it simply copies each file in the hope that the copy will be less fragmented. That's of course far from how real defragmenters work. – rustyx Dec 23 '14 at 20:29

There is no such a tool around, for what I know.

Some site reports the following command

# WARNING - does not work
fsck -t ntfs --kerneldefrag /dev/hdX

but this does not work, and it is not clear where do they get it.

share|improve this answer
OK. Thanks for letting me know – Alex Aug 28 '11 at 18:18
-1 Why add an answer when it isn't even useful in any way? – Wolfer Mar 4 '15 at 13:16
+1 because it is actually an answer. – Michael Jan 20 at 15:01

Update: UltraDefrag for Linux:

UltraDefrag is a powerful Open Source Defragmentation tool for the Windows Platform. It can defragment any system files including registry hives and paging file. Also one of the main goals of UltraDefrag is doing the job as fast and reliable as possible. It is being ported to Linux and NTFS-3G for defragmenting NTFS partitions. Currently only a test version in console mode is available. Please read the included file README.linux for compiling and testing

[I've not yet used this myself. Found it via a thread on an Arch forum. Further following the thread through to the next page leads to more on the topic. Try at your own risk.—kevjonesin—]

share|improve this answer

There is a very well know tricky cheat to archive a NTFS defragmentation (including free space)... it can be done with a Live Linux like SystemRescueCD...

But, you must have a second HDD or at least a 51% free space (that if not using compression).

The trick (very tricky) is to use tools to "clone" the partition, but not typical ones... there is a tool that can "clone" a NTFS parttion but not doing an exact "clone"... let me explain...

The tool is fsarchive (if i do not remember bad).

It makes a very big file (as clone tools does), with all files (beware of NTFS special metadata of files, streams i think they are callled), just as a "clone" tool does...

But the tricky part comes when restoring... it does not put files where they where, it puts files without any fragmentation at all.

I had used it for Windows System partition as well as for NTFS data partitions... with succed... not very easy to use / understand (read carfully the docs)... but can do the trick.

Remember... such big file it create can be compressed, so not really need to have a 51% free.

But any way, first you must Shrink NTFS partition... use GParted (if i dont remember bad).

So steps:

  1. Worst case: HDD has only one BIG NTFS partition, with enough free space
  2. Boot SystemRescuCD (if you want start X windows with wizard command)
  3. Use GParted to shrink NTFS partition to its min size (will fragment NTFS files more, no matter)
  4. Use GParted to create another partition on free space, better if ext4 type (journal)
  5. Mount such new partition, but do not mount NTFS
  6. Use fsarchiver to create a "clone" of the NTFS partition, use compression and store the bif file on created partition
  7. From now on this is very RISKY: Use GParted to delete NTFS partition and re-create it
  8. Restore the "clone" using fsarchiver, all files on NTFS partition will be 1 fragment (except one or two because $MFT could be putted on middle, not at strat or end of partition)
  9. Use Gparted to shrink NTFS partition if needed
  10. Check NFTS is correct, can be mounted, read/write, and dismounted
  11. Unmount newly created ext4 partition
  12. Use Gparted to grow that ext4 (or better, delete it and recreate it)

That's it, folks... as i said very tricky and risky, of course.

Beware Key Points:

  • NFTS shrink let enough free space to hold a compressed image of the NTFS partition (51% free on the HDD will ensure there is enough)
  • fsarchiver does not save NTFS streams?
  • fsarchiver restore do not put files where they where, it put them unfragmented (like a copy)
  • After deleting and recreating NTFS partition there is no back way

The steps are for: Use a LiveCD / LiveUSB linux to defrag a NTFS partition that uses 100% of the disk, with no other HDD connect to such PC [must have enough free space].


  • Some could think if you have 51% free on the HDD after NTFS shrink it could be safer to just create that ext4 and copy all NTFS to it, then delete NTFS, recreate it and copy them back... DOING THAT will cause looses, like NTFS security permisions, etc

As long as i know GParted/fsarchiver is the most near solution (for using only a LiveCD/LiveUSB with Linux), not fast, somehow risky, but satisfing terms imposed by the person who post the question.

BE AWARE: It is very, very risky... as with any "clone" tool... and for now i do not know any other best way... and it will loose NTFS streams (if i do not remember bad)

PLEASE: Read carfully fsarchiver docs, before using it.

I have any responsability (i had used it on my own data, but allways i have a external BackUP - good partices).

In practice... all info i have, i put them on at least three different mediums (HDD, DVD, Flash Memories), with at least three copies on each medium, so i have 9 copies... if i loose 8 of them it rest one more to recover data... i am a little paranoid, i kown.

share|improve this answer
I would not recommend this method, as (just like you said) it is very risky and usually not worth because of a defragmentation. Better use Windows live systems to do such a job (or the original Windows system - why not?). – Byte Commander Jan 27 '15 at 15:01
fsarchive is just a sophisticated tar archive that store some extended attributes. It doesn't defragment anything. You method is as good as simple copy of files from one partition to another clean filesystem. – ZAB Jun 7 at 11:10

No. These are Windows filesystems so you will need to use Windows to defrag them.

share|improve this answer
Ok thank you :) – Levan Nov 6 '12 at 1:12
Doesn't Wine have the standard Windows defrag app? ??? – Juan Dec 12 '15 at 21:54
@Juan, no, that is part of Windows. WINE just allows running third party applications written for windows. It also makes use of windows filesystem driver specific ioctls that are not available on linux. – psusi Dec 13 '15 at 19:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.