linux - What happens if I execute fstrim for a HDD instead of SSD?

08
2014-07
  • Raegdan

    Sorry for my not so good English.

    I'm preparing a Xubuntu 12.04 Clonezilla image for rapid deployment to new PCs in my company. PCs we are buying may have either HDD or SSD drives. My boss requested that computers with SSD must have TRIM enabled by default. I googled a little and found out that in Linux it's normally done by creating a cron task with fstrim aimed to a mount point. But, if I include this line into my image, computers with HDDs will do fstrim on them too.

    So, is it safe for data and for performance? Or do I need a solution to detect drive type (SSD/HDD) and to enable TRIM on SSDs only?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    Is there Linux support for TRIM on SSD drives?
  • dlux

    Does any know if there is a way to enable TRIM support on Linux for SSDs? This is included with Windows 7, and I was surprised that I couldn't find much information about it under Linux.

    Info on SSD and TRIM can be found here - http://www.anandtech.com/storage/showdoc.aspx?i=3531&p=10


  • Related Answers
  • hlovdal

    Notice that you probably need a more recent kernel than 2.6.28, see here (based on 2.6.30-rc4 with last activity in May this year). I do not know to what degree that tree has been merged, maybe you can search the [email protected] mailing list. Update: see for instance this thread (also discussed on the kernel list).

    For using TRIM you are probably interested in hdparm-9.20, released a few days ago (and I see there is even a newer wiper-1.7 release).

    Update: See also this LWN article about the relationship between filesystem, TRIM, performance and SSD disks.

  • ChrisInEdmonton

    Linux supported the TRIM command in 2.6.28, released on December 25, 2008. See here for details.

  • Pyrolistical

    I think Linux already supports Trim. Its just no SSD has support for it yet. The firmware upgrade is required for current generation OCZ and Intel drives for Trim to be enabled.

  • Flow

    For ext4 you have to add the discard option in your fstab to enable ATA Trim.

    See also this nice how-to

  • Name

    Initial support added in 2.6.28, 2.6.33 has "full" trim support... whatever that means.

  • Seasoned Advice (cooking)

    I tracked TRIM command on UBUNTU 9.10. But I can't find any TRIM Command when I'm using the kernel 2.6.31. When I generated TRIM command using the hdparm, I can find TRIM command. So, I think current linux kernel version does not support TRIM command.