How do I defragment NTFS drives in linux

Asked by Sidarth Dasari

I have a headless home server running with 3 NTFS drives attached. Is there a way to defragment these drives? A command line app would be preferred.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu coreutils Edit question
Assignee:
No assignee Edit question
Solved by:
Sidarth Dasari
Solved:
Last query:
Last reply:
Revision history for this message
Jim Hutchinson (jphutch) said :
#1

This might not be all that easy to do. Most people with NTFS drives also have windows and can do it that way. A couple potential solutions are http://sourceforge.net/projects/linux-ntfs/ and http://www.ntfs-3g.org/ but I don't know if they support defrag. Another, albeit less enjoyable, solution is to copy the data off, reformat and then copy back. There may be a native Linux tool to defrag and if so hopefully someone will reply.

I have a NAS device that "looks" like a windows share so it works with windows but is actually Linux driven with a Linux FS so no defrag needed. I wonder if something like that would be an option. Out of curiosity, why are you using NTFS if you don't have windows?

Revision history for this message
Sidarth Dasari (sirsid) said :
#2

Its just a leftover from when I did have windows. The drives are only used to store things on my home server now. If I did reformat them into a more linux compatible format, would I still be able to share them over my network to my other windows PCs?

Revision history for this message
Jim Hutchinson (jphutch) said :
#3

Good question. I'm not sure but my hunch is yes. I have a WD NAS that uses Linux FS but has a front end (not sure if it's hardware or software) that make it act like a windows share. My guess is you can set up something similar but I have no idea how. I'll do some looking and let you know if I find anything.

Revision history for this message
Sidarth Dasari (sirsid) said :
#4

Ah thanks. I appreciate it

Revision history for this message
Jim Hutchinson (jphutch) said :
#5

I didn't know samba went both ways but it looks like maybe that's the answer. This article has some info on it. Scroll down a ways to get to the "Accessing Linux files from Windows" section. It's a pretty old article but maybe the samba approach is still the answer.

http://www.itworld.com/Net/4160/lw-01-legacy/

Revision history for this message
Sidarth Dasari (sirsid) said :
#6

Thanks again. Ill try it out

Revision history for this message
Matthew H McKenzie (f-launchpad-swellhunter-org) said :
#7

This would be very useful to have on a live CD. In theory if you had access to a windows system drive you might be able to run a defrag from within wine ?

As an aside, my employer too does not allow us to defrag our windows drives from within Windows. This can also be a risk if the drive (or partition) is subject to third party encryption.

So currently there are other options :

a) remove the drive and mount it on a Windows (even if it's a junker) machine for defrag.
- dd a full backup copy somewhere first.
b) if you need to minimise downtime, dd the drive and defrag the copy.
c) dd the drive to a SSD and use that instead.

Mind how you go, don't get yourself fired, and try not to break any laws....

Revision history for this message
Matthew H McKenzie (f-launchpad-swellhunter-org) said :
#8

Additionally, defragging from another windows machine may be quite complex if you don't have and cannot synthesise permissions over the files concerned.

Suggest then a "turnaround" copy to temporary drive to repartition all drives as EXT2 (if static) or EXT3. This could be done over USB or eSATA if you have the patience.