Is it safe to edit files during the defragmentation process?

6

2

Assuming I'm on an NTFS partition, is it just as safe to edit files during defragmentation as when not? Is there any added risk, even if very small? If not, how does the operating system ensure the integrity/consistency of the data?

DuckMaestro

Posted 2011-04-01T20:31:42.563

Reputation: 1 597

I think the worse case is just that the defragmentation process gets restarted. I don't think the data can become corrupted in this way unless there is a bug in the application used for defragmentation. – bobo – 2011-04-01T21:08:49.763

3You can lose data if there's a power failure or system freeze during a defragmentation though. – emgee – 2011-04-01T21:21:00.280

2Nothing is 100% safe in Windows ;-> I have only had one defrag job go south in all my years, I tried to stop the defrag and it locked the system up for some reason, did a hard reboot and it was trashed, reinstalled XP. I tend to leave the system alone when defrag is running, but is not necessary. – Moab – 2011-04-01T21:32:41.253

@Moab: It depends a lot on the filesystem. I've never had data loss with NTFS. On the other hand, I'm not touching FAT32 ever again. – user1686 – 2011-04-02T17:00:34.420

@grawity, It was ntfs in my case, I think it was bad luck also. I did not lose data, it just would not boot and I could not fix it in a reasonable amount of time, it was faster to copy data off the drive and blow my clean image back on using Acronis. XP sp1 if I remember right. Forget Allocation Table is what I use to call it. – Moab – 2011-04-03T02:20:03.407

Answers

6

There is no risk associated with editing files during defragmentation. If a file is open for editing (you can aquire a read-only or a read-write lock when opening a file) it is considered "locked". When the defrag process gets to that file it skips over it, leaving it in it's current place.

Daisetsu

Posted 2011-04-01T20:31:42.563

Reputation: 5 195

What if we open a file for editing when it's in the middle of defragging? For example a 100MB file scattered in 1000 sections take a long time to defrag. What happened if we open it for editing when it's in the middle of the defragmentation process? – David Refoua – 2016-09-19T23:43:20.463