21

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

I also know that Windows 7 will report free space differently for a solid state disk so that the disk can re-use those sectors in its 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?

Giacomo1968
  • 55,001
sherbang
  • 335

3 Answers3

13

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,497
  • 6
    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? 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). – 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
  • 3
    AFAIK Virtualbox can use TRIM command to shrink vdi files automatically. 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 – phuclv Nov 16 '16 at 06:53
1

In theory one would think that marking an HDD as a SDD could be a good idea, because it would allow online shrinking of the virtual disk (if it's a VDI), thus freeing up some space on the host.

In practice, that online shrinking could impact performance, because, well, it’ll happen on a HDD, so it wouldn’t probably go as unnoticed as on a (much faster) SSD.

Quoting from a VirtualBox forum site moderator; bold emphasis is mine:

If you want the performance of an SSD you simply locate the VM on an SSD, simple as that. Trim being an optional extra. Marking a VDI as SSD when it's not located on an SSD will not improve performance. Potentially it could decrease performance if it causes image blocks to be shuffled, causing extra seek latencies.

Giacomo1968
  • 55,001
1

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 elevated scheduling is likely counter productive.

Giacomo1968
  • 55,001