Is it safe to defrag a virtual machine on an SSD?

2

1

As part of my coursework I need to show some evidence (screen shot) of myself defragmenting a computer. Since I missed out doing it at college, I need to do it at home. This requires me to use a Windows virtual machine since I have a Mac (needs to be Windows).

Is it safe for me to defrag a virtual machine where the host is a SSD? The reason why I am asking this is because I've heard that you shouldn't defrag SSDs.

iProgram

Posted 2015-12-23T20:56:58.117

Reputation: 505

The advice not to defrag SSDs to avoid harm is ancient and obsolete. It will do almost no good on a modern SSD, but it won't do any significant harm either. (The main reason to defrag an HD was to reduce latency. Defragging won't affect latency on an SSD. But it will slightly reduce the number of I/Os needed to read/write, which can provide some benefit in IOPS-limited workloads.) – David Schwartz – 2015-12-23T21:13:05.690

@DavidSchwartz So is it still safe to defrag a VM with the host using a SSD? – iProgram – 2015-12-23T22:05:53.903

Yes you can do that. The defrag saga for SSDs means that it is a useless exercise to defrag an SSD because the access time to any point on the SSD is the same and you gain nothing with a defrag - you don't lose anything either. – whs – 2015-12-23T22:16:06.717

1@whs It's not true that you gain nothing. Many SSD operations are IOPS limited, and accessing contiguous data takes fewer I/Os than accessing discontiguous data. – David Schwartz – 2015-12-23T22:58:48.650

Now you are slicing it awfully thin. I deal only with real cases. – whs – 2015-12-24T00:51:18.773

He's not, really. Left unchecked the drive could end up very fragmented, which could easily increase write amplification. That's why Windows 8 and up defrag SSDs monthly. http://www.hanselman.com/blog/TheRealAndCompleteStoryDoesWindowsDefragmentYourSSD.aspx

– afrazier – 2015-12-24T01:29:06.363

Answers

2

It is safe. It doesn't damage the VM, nor the SSD, unless you it do a thousand times.

I do it often, to be able to reduce the file size of the virtual machine afterwards, so backups don't take hours, and for that you need to Defrag and then sdelete.

Aganju

Posted 2015-12-23T20:56:58.117

Reputation: 9 103

Do you mean SSD? Hard Drives are magnetic. – iProgram – 2015-12-23T22:47:46.720

1yes, on an SSD. For me the term 'hard disk' meant any kind of disk – Aganju – 2015-12-23T22:48:32.820

0

The short answer is Yes. The long answer is that it doesn't matter because it's a virtual disk, not a real one, on top of a filesystem on top of an SSD. In this case, you are modifying a file which is being modified either way by simply turning on the VM.

The only reason I would think of for saying you shouldn't defrag an SSD is because of all the data movement that comes along with it. SSDs tend to make use of all the space because there is a specific number of time you can write to each bit. Defragmenting will move a lot of data around using the SSD sectors.

Digisec

Posted 2015-12-23T20:56:58.117

Reputation: 216

That's what I thought. Just wanted to check. Thanks. – iProgram – 2015-12-23T21:03:50.243

1Do you understand why they say don't defrag on SSD ? – Digisec – 2015-12-23T21:04:14.963

If I remember correctly, it's because of amounts of read and writes you can do on a SAD, as well as SSDs not needing to be defaged due to the speed anyway. – iProgram – 2015-12-23T21:05:54.843

Looking at the reason why you shouldn't, it should matter that much about moving files since it is not all of the data on the SSD. – iProgram – 2015-12-23T21:16:00.277

2You can rewrite every single byte on a typical modern SSD once a week for three years. – David Schwartz – 2015-12-23T21:20:48.217

1The reason people say SSD don't need to be defragged is because there are no moving parts and every part of the SSD takes the same amount of time to access. Also the access time is typically <1ms(0.1ms on good drives) vs 9-14ms for a hdd so fragments are less noticeable. 1000 frags on a ssd is 10000.1 or 100ms, on a hdd 10009 is 9000. However, a SSD can still benefit from a defrag, but unless your drive is horribly fragged benefits are really small. I would do it once a year. – cybernard – 2015-12-23T21:45:11.307

@DavidSchwartz So a small file defrag should be fine then when doing it once in a life time. Thanks – iProgram – 2015-12-23T22:10:36.720

1@iProgram Absolutely. You can even defrag a modern SSD every month if you want to. It won't help very much at all, but it won't hurt very much either. – David Schwartz – 2015-12-23T22:59:23.537