You know, that’s one that I haven’t thought of before. But now that you bring it up, I intend to act on it.
I believe the answer is yes. You should defrag and yes, do it with the volume open, but with one caveat.
Become a Patron of Ask Leo! and go ad-free!
Avoid the SSD
The caveat is that you should not defragment a solid state drive.
So if your TrueCrypt volume is stored on an SSD, don’t defrag it. Defragmenting is done to prevent performance issues and Solid State Drives don’t really benefit from it very much, if at all. And there’s also some controversy as to whether defragmenting an SSD can actually shorten its life. I just recommend avoiding that issue entirely and only deal with defragmenting on regular spinning platter magnetic media hard drives.
Now, a TrueCrypt volume is a single file. When mounted, you can place files into that file that are automatically encrypted and decrypted.
So, you have a file, and within that file, you have other files.
It might be worth defragmenting both.
Defrag the container, once
First, with the volume dismounted, defragment the drive that contains the volume.
So, for example, if you have your TrueCrypt volume on C:, defrag C:.
The good news here is that you really only need to do this once. Because the container never moves (meaning that you don’t copy it around and you don’t grow it or shrink it – it just sits there being a container), it won’t get fragmented.
Defrag the contents occasionally
When the volume is mounted in TrueCrypt, it appears as another drive, and its contents are treated as another disk drive. That means that the files on this other disk drive could indeed get fragmented.
So, next, with the volume mounted, defrag the volume. What that means is if you mount your TrueCrypt volume as drive F:, then you would defrag drive F:.
As it turns out, Windows might not let you.
I looked with the Windows defragger, and it told me that defragger was unavailable for my mounted volume. On a whim, I fired up Piriform’s Defraggler, and it works – it’s defragging my TrueCrypt volume right now.
If you don’t do a lot of work within the drive, it’s probably not worth defragging very often. On the other hand, if files within the True Crypt are frequently being created, deleted, and written and so on, then yes, a periodic defrag might very well be a good thing.