SSD on USB 3.0 3.1 with TRIM support: Windows & Linux

If you want to connect a Solid State Drive with SATA interface via a USB 3.0/3.1 port to fully utilize disk speed, because for example you want to install over it a full operating system as Windows or Linux which boot directly from the USB port, there are many SATA-USB adapters that do this job. The first thing to know is that to get the maximum possible read/write speed, the adapter must support the UASP (or UAS, "USB Attached SCSI" protocol) protocol, otherwise it will not exceed 250 MB/s in sequential read/write. But there is a problem. If the operating system fails to systematically send the TRIM command to the disk controller, then read/write speed slowly will slow down, losing all the benefits of using an SSD. The problem is that TRIM is a SATA command and is therefore not natively supported on a USB interface. Now the question is: are there SATA-USB adapters that let the TRIM command pass? The answer is yes, few but there are. I bought one and tested it, that is StarTech.com USB312SAT3CB. If you're interested in this, this is the adapter cable and here where I bought it. I connected through it a Samsung EVO 850 SATA III 2.5" 250GB and tell you how it went with Windows and Linux, precisely with Windows 10 and Ubuntu 16.04.

Foto USB SATA SSD StarTech.com USB312SAT3CB ESCAPE='HTML'

 

WINDOWS 10

After connecting it to a USB 3.1 gen1 port of my notebook with i7-7700HQ CPU, I tested the read/write speed with CrystalDiskMark to see if the UASP protocol worked, and in fact I doubled the speeds compared to my old USB 3.0 adapter as you can see in the picture below.

CrystalDiskMark test with USB adapter ESCAPE='HTML'

So I downloaded the "trimcheck" program that must be started from a NTFS partition of the SSD disk that you want to test and the result was that the TRIM was not working. Then I went to the startech.com manufacturer site and  I downloaded the new firmware for the adapter that officially enables the TRIM support as you can read on the readme file in the zip (you can also download it from below).

It was enough to click on the exe file of the new firmware and the update happened almost instantly and successfully. After I restarted the TRIM test with trimcheck and this time the test was successful: TRIM is working.

TRIMcheck_test_working ESCAPE='HTML'

At this point I also tested the manual TRIM with the following command given by Powershell with administrator rights:

 Optimize-Volume -DriveLetter YourDriveLetter -ReTrim -Verbose

Replace the YourDriveLetter portion with your solid state drive partition letter.

Powershell_manual_TRIM ESCAPE='HTML'

 

UBUNTU 16.04

With the default kernel, the fstrim linux command is not supported on USB devices. So by default in Ubuntu you do not have the automatic TRIM of your USB SSD. However, you can manually trim (or possibly setting up a cron job) by using the wiper.sh script located in

/usr/share/doc/hdparm/wiper/wiper.sh.gz

Unzip it and make it executable (chmod a+x) so you can do the TRIM manually with

sudo ./wiper.sh /dev/sdXX --commit

where you must replace sdXX with the partitions on your USB SSD (e.g sdb1, check the correct one via Disks application). Just run this command once a week. However, it is not necessary but it is advisable to execute that command on the unmounted partitions, then via a live system if you have installed and started Ubuntu directly from the SSD on USB.

wiper.sh_output ESCAPE='HTML'

I have also tested that TRIM is working with the method here (just run wiper.sh in place of fstrim),

dd if=/dev/urandom of=tempfile bs=1M count=3
hdparm --fibmap tempfile
hdparm --read-sector [ADDRESS] /dev/sdb
rm tempfile 
sync
sleep 120 
sudo ./wiper.sh /dev/sdb1 --commit
hdparm --read-sector [ADDRESS] /dev/sdb

and at least when wiper.sh runs on unmounted partitions, it is immediately apparent that the TRIM is working (since I get a sequence of zeros on the trimmed sectors). From what I've read here, for the fstrim command to work, the controller should support "ATA TRIM to SCSI UNMAP translation".

If you want to know more about the TRIM command please read here

I installed Ubuntu 16.04 on my SATA 850 EVO SSD with Startech.com USB312SAT3CB adapter and the boot time between grub and login screen is only 9sec or less!

PS: Other startech.com USB products that support TRIM are here.

27/06/2017