3

I'm running VMware Workstation 12, and am trying to have it see SCSI0:0 as an SSD drive.

I want to have the discard mount option and fstrim / work on ext4 and btrfs.

I added the following to my .vmx file: scsi0:0.virtualSSD = 1

But in Linux (both Mint 17.2 and Manjaro 16.08, /sys/block/sda/queue/rotational contains 1, meaning it gets detected as a HDD or spindle and platter disk.

However, smartctl -a /dev/sda disagrees:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.16.0-38-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION === Vendor: VMware, Product: VMware Virtual S Revision: 1.0 User Capacity: 274,877,906,944 bytes [274 GB] Logical block size: 512 bytes Rotation Rate: Solid State Device Device type: disk Local Time is: Tue Oct 25 08:35:07 2016 ICT SMART support is: Unavailable - device lacks SMART capability.

=== START OF READ SMART DATA SECTION ===

Error Counter logging not supported

Device does not support Self Test logging

How do I get rotational to be 0 (and thence get TRIM working?)


Also asked at:

mashuptwice
  • 3,244
Tom Hale
  • 2,410
  • Are you sure VMware advertises the TRIM command for its virtual drives? What are actually trying to accomplish, auto-shrinking images? – Daniel B Nov 10 '16 at 21:55
  • Relevant source code: http://lxr.free-electrons.com/source/drivers/scsi/sd.c?v=4.7#L2731 - you could hack in a few printk to debug, see same file for example. – Daniel B Nov 10 '16 at 22:18
  • @Daniel B This seems to indicate that it should support TRIM. Yes, I'm trying to auto-shrink images - they are constantly growing in size – Tom Hale Nov 13 '16 at 03:02
  • I don’t see anything indicating TRIM support there. Indeed, the only thing I found was about vSphere 6.0, but it wasn’t about auto-shrinking images. I’m quite sure VMware Workstation doesn’t support this. – Daniel B Nov 13 '16 at 09:41
  • @DanielB Message from the future: there is 2021, vmware workstation still no support. – peterh Oct 05 '21 at 12:09
  • @mashuptwice queue/rotational has nothing to do with TRIM / discard / UNMAP, but they all depend on what exact type of emulation we are talking about. If it's SCSI (as opposed to SATA), most likely there's something bad with its VPD emulations (or response to READ CAPACITY / INQUIRY), which can be hunt down with sg3_utils. – Tom Yan Aug 04 '22 at 05:16

1 Answers1

-1

Negative answer : A TRIM issued within the VM on emulated hardware cannot be translated to a TRIM on the host (at least to my knowledge and at the moment).

In order to auto-shrinking images, the only solution might be to schedule a task for Discarding Blocks Not in Use.

The task will use virsh with the following verb:

domfstrim

Syntax:

domfstrim domain [--minimum bytes] [--mountpoint mountPoint]

Issue a fstrim command on all mounted filesystems within a running domain. It discards blocks which are not in use by the filesystem. If --minimum bytes is specified, it tells guest kernel length of contiguous free range. Smaller than this may be ignored (this is a hint and the guest may not respect it). By increasing this value, the fstrim operation will complete more quickly for filesystems with badly fragmented free space, although not all blocks will be discarded. The default value is zero, meaning "discard every free block". Moreover, if a user wants to trim only one mount point, it can be specified via optional --mountpoint parameter.

The following example trims the file system running on the guest virtual machine named guest1:

# virsh domfstrim guest1 --minimum 0
harrymc
  • 480,290