20

So I noticed with 4.1 that VirtualBox added a "Solid-State Drive" option in the storage section.

I also know that Win7 will report free space differently for a solid state disk so that the disk can re-use those sectors in it's built-in optimization.

I'm wondering about turning this on even though my host has a spinning disk. Would this effectively zero free space so that I can compact my virtual disk? Would I take a big performance hit by turning this on?

sherbang
  • 325
  • 1
  • 2
  • 8

2 Answers2

12

This just changes whether or not your guest OS sees a solid-state drive (and enables/disables features based on that). Since VirtualBox supports physical pass-through for hard drives, this will only matter if you have a solid-state drive on the host computer and have the virtual hard drive on the same drive.

From the guest OS's perspective, all it will do is disable disk defragging, and try to send TRIM commands to the drive (they are ignored if the host drive doesn't support them, or VirtualBox is not using pass-through I/O requests). Aside from that, it's actually up to the SSD controller to choose what sectors to read/write data from/to, not the operating system.

You can turn this on, but you won't see any performance differences. For what it's worth, though, nobody ever has a reason to turn this on unless they are testing SSD-specific features (and even then, can test said features with a simulated SSD).

Breakthrough
  • 34,227
  • 10
  • 105
  • 149
  • 5
    TRIM is what I was thinking of. I'd expect TRIM would help VirtualBox know which blocks are free so it doesn't have to grow the .vdi as much/often. Of course that's only if VBox has TRIM support, which some quick Google searches aren't telling me. – sherbang Aug 24 '11 at 18:59
  • AFAIK, it does *not* have TRIM support. That being said, there are much easier/faster ways to accomplish this. See the following question, [Is it possible to shrink a VirtualBox dynamic image?](http://superuser.com/questions/47562/is-it-possible-to-shrink-a-virtualbox-dynamic-image) Alternatively (this is what I do), you can just compress the VDI with an archiver (7zip, WinRar, etc...), and extract it when you need to fire up the machine. – Breakthrough Aug 24 '11 at 19:14
  • Sorry, one last thing to add... Even if the virtual hard drive *was* TRIM aware, that wouldn't prevent the VDI from increasing in size as much. Without TRIM, a hard drive will overwrite still closer "deleted" blocks before extending out. All TRIM does is tell the SSD controller which blocks it can use with garbage collection (to help prevent [write amplification](http://en.wikipedia.org/wiki/Write_amplification)). – Breakthrough Aug 24 '11 at 19:18
  • Well, it sounds to me like you _do_ want to turn on this feature if your drive image file resides on an SSD... Admittedly you don't need to _block_ defragging; just don't run defrag on the guest OS (make sure no automatic defrag or scheduled defrag is set up either), but why not have the extra check to prevent mistakes? TRIM may also help provide the device with additional information it can use to optimize itself better. This may not create any appreciable _performance_ benefit, but I think it may help extend the life of the device. And FWIW, I don't see any reason not to... – Dave Lillethun Aug 08 '13 at 00:59
  • 1
    @DaveLillethun yes, that's what I said in my answer. The original question was asking about turning this feature on while running the virtual machine off of a *hard* drive, not a solid state drive. Indeed it is worth turning this feature on if the image resides on a SSD. – Breakthrough Aug 08 '13 at 10:51
  • Oh, you're right. I misread the OQ. :( – Dave Lillethun Aug 08 '13 at 16:48
  • 2
    AFAIK [Virtualbox can use TRIM command to shrink vdi files automatically](http://superuser.com/a/728469/241386). And no, no archiver can compress your virtual hard disk like `vboxmanage compact` because all the non-zero sectors on disk still need to be compressed even though they belong to deleted files. The only way to really shrink those image files are zeroing sectors by tools like [`zerofree`](http://manpages.ubuntu.com/manpages/xenial/en/man8/zerofree.8.html) – phuclv Nov 16 '16 at 06:53
0

If you are doing pass through to an SSD, I'm pretty sure the guest is already going to see it as an SSD. This flag is much more relevant for virtual drives. I'm not clear on how much benefit this flag can provide, particularly if you have the guest tools installed on the guest, but a few things come to mind. First, there is the "TRIM" feature, which can help the host OS to know it doesn't need to flush out unused file system pages to disk once they are abandoned. More than that though, I think a potential win could be that most OS's turn off their normal elevator scheduling for disk IO when presented with an SSD. Particularly if you have host I/O caching enabled, this is probably a big win, as having two levels of elevator scheduling is likely counter productive.