Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have three questions for Ubuntu and TRIM/SSD experts.

  1. I've got SSD drive (SanDisk SDSSDP128G 128Gb).
  2. Currently, it is the only hard drive. Connected via SATA cable however in BIOS using IDE mode rather than AHCI.
  3. Installed WinXP SP2 on the first partition (16 GiB, NTFS), and then aligned it to SSD blocks using gparted live CD
  4. Installed Ubuntu 12.04 LTS on the second partition (16 GiB, ext4, immediately after the previous partition)
  5. The rest of the drive is unpartitioned for now; grub is used as OS loader.
  6. Ubuntu mounts the first NTFS partition on startup (as done by Ubuntu install, I have not touched that)
  7. Got confirmation from hdparm that drive supports TRIM
  8. Enabled TRIM in Ubuntu using "fstrim /" which runs by cron

Now, I spent weeks trying to get this info from the web. Some sources say NTFS does support TRIM, others say Win7 supports it (while using NTFS). Some sources say fstrim TRIMs the whole physical drive while others say it only TRIMs the current partition.

  1. Is "fstrim /" in the scenario above applies to 16 GiB ext4 partition only, or to the whole 128Gb drive?

  2. If it only applies to the ext4 partition, is it possible at all to TRIM the first NTFS partition (from either Ubuntu or WinXP, but only using Ubuntu native or Win built-in tools, without dodgy downloads)? Could hdparm and moving/copying physical sectors do anything to help? Partition cloning whatever?

  3. What is the worst-case scenario if TRIM is not possible for NTFS: are there any firmware garbage collectors that could do similar thing without OS commands?

Please do not recommend switching to Win 7 whatsoever - I'm still happy with the development environment under Win XP. I'm still happy to use "out-of-date" OS if it boots in 7 seconds, gives immediate response to anything you do, and loads Photoshop in 3 seconds (for the first run:)

Thank you in advance, Yaroslav

share|improve this question
Welcome to Ask Ubuntu! It is preferred if you can post separate questions instead of combining your questions into one. That way, it helps the people answering your question and also others hunting for atleast one of your questions. Thanks! – Danatela Mar 18 '14 at 10:10
Sorry, I've assumed anyone in my situation would have all three questions together! Should I leave this for now or remove it and create three separate threads instead? – user259452 Mar 18 '14 at 10:15

3 Answers 3

TRIM is a filesystem level operation. It needs to know which sectors of the disk are free so that it can inform the hardware. Neither "Discard" nor "Trim" are documented features of the ntfs-3g driver so I would suggest that no, this probably isn't possible.

There have also been a few separate calls for this but it's a feature that would only really affect a few people.

My only real long-term solutions are:

  • Stick it in a Windows machine (or boot to Windows) once every few months (I'm not sure what your churn rate is).
  • Use a real filesystem. Nothing makes people jealous like a nicely formatted ext4 partition. You'll need to juggle the data though.
share|improve this answer
ntfs-3g now supports discard on filesystems that live on disk partitions. It didn't when you wrote this. – Peter Cordes May 4 at 19:03

Yes, it only applies to the one partition you run it on, and it should work just fine if you run it on your ntfs partition isntead of /.

share|improve this answer
When I run it as "sudo fstrim -v /media/System/" (where System is label for NTFS partition), it fails with the message "Inappropriate ioctl for device" – user259452 Mar 18 '14 at 21:48
@masterofsql, darn... looks like a bug in ntfs-3g. Try using the old kernel ntfs driver. Umount the partition and mount it using mount -t ntfs -i /dev/whatever /path. – psusi Mar 19 '14 at 14:02

Update, looks like NTFS-3g got fstrim support in a patch from 2014-June.

Ubuntu 15.04 worked fine with fstrim on a loopback-mounted NTFS filesystem image I wanted to make sparser. If 15.04's version of ntfs-3g includes that patch, it should work on mounted partitions, too.

Other than that, ntfs-3g includes an ntfswipe command, which writes zeros over all unused space. Don't use that on an SSD, it would increase wear. I considered using it, then running fallocate --dig-holes (to sparse-ify all 4k blocks that were all zeros). IDK fallocate maps to discard/trim when used on a block device, but it may. Anyway, use fstrim to discard WITHOUT writing with zeroes first, since that works now.

What is the worst-case scenario if TRIM is not possible for NTFS: are there any firmware garbage collectors that could do similar thing without OS commands?

No, trimming the free space of an NTFS filesystem requires a tool that understands NTFS. Nobody's crazy enough to put something like that into SSD firmware, since it's a job better done by whatever software on the computer is reading the NTFS.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.