SSD trim command in VM, help, please


Recommended Posts

How does Unraid handle SSD TRIM when SSD drive is passed to VM entirely?

I am not talking about passing an entire SATA controller to Ubuntu 18.04 VM, but the disk itself "/Dev/disk/by-id/ata-XXXXXX. In this case SSD will be presented as some virtual disk "VDA". Is TRIM gonna be handled in host or guest OS?

Planning on purchasing Samsung 860 EVO BTW.

Open to any suggestions, even using vdisks too, all I need is to make sure TRIM command will be working correctly.

Thank you!!

Link to comment

   I honestly have no idea, but I would hazard my guess on the answer being, it is the guest OS that will do the TRIM. Such that  guestOS sends TIRM, passed to SATA (guestOS), which is passed through to host sata layer, which gives it to block device and ultimately the drive's own internal logic does trim. Only the guestOS is going to be aware of the unused blocks and issue the addresses to clear.  

 

 

Link to comment
On 7/5/2018 at 9:58 PM, Jcloud said:

   I honestly have no idea, but I would hazard my guess on the answer being, it is the guest OS that will do the TRIM. Such that  guestOS sends TIRM, passed to SATA (guestOS), which is passed through to host sata layer, which gives it to block device and ultimately the drive's own internal logic does trim. Only the guestOS is going to be aware of the unused blocks and issue the addresses to clear.  

 

 

 

That's what's I figured, gotta do some testing to see if it works, these are just assumptions for now, will post results later. 

 

Thank you!! 

Link to comment

If you pass the controller to the VM, then the VM will know it's a SSD and can directly perform trim.

 

If you only pass the drive, then the OS will normally not perform trim because it doesn't understand that it's a SSD. The whole idea with VM is to virtualize the hardware allowing you to switch to different hardware without the VM knowing about it.


The only thing I have seen earlier is that it's possible to configure the image file to be underprovisioned, and have the VM sends trim so unused parts of the image file can be returned. But I'm not sure if this would be applicable if running directly on a SSD, and if the SSD will see any trim requests.

Link to comment
On 7/9/2018 at 9:46 AM, pwm said:

If you pass the controller to the VM, then the VM will know it's a SSD and can directly perform trim.

 

If you only pass the drive, then the OS will normally not perform trim because it doesn't understand that it's a SSD. The whole idea with VM is to virtualize the hardware allowing you to switch to different hardware without the VM knowing about it.


The only thing I have seen earlier is that it's possible to configure the image file to be underprovisioned, and have the VM sends trim so unused parts of the image file can be returned. But I'm not sure if this would be applicable if running directly on a SSD, and if the SSD will see any trim requests.

Exactly, I can't pass the controller unfortunately, I have 4 SATA ports on MB with single controller, passing an entire controller means, passing all my drives. I can possibly use my SATA expansion card to pass it to the VM, it will solve the problem. 

VM image is another issue, I have seen some posts regarding TRIM command inside of VM and how to set it up to make sure VM reports unused space to host. 

 

Good post (although a little unrelated) link 

edit:

 

I thought you would be interested in this article link https://serverfault.com/questions/896448/qemu-trim-and-discard-on-a-physical-ssd-device

 

It's pertinent to my issue, too bad I am no longer interested in this option anymore, I am not gonna be able to test it as of this moment. Ended up passing the entire controller by adding a dedicated PCI SATA HBA card to the motherboard. 

 

Thank you anyway!!!

Edited by pervin_1
Link to comment
  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.