Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Does that SSD Trim, and why is it important?

By: hoakley
13 November 2025 at 15:30

Trim is one of the Dark Arts of SSDs. It’s important if not essential, but it’s not easy to discover whether an SSD is Trimming properly. Some say that you need to enable Trim for external SSDs, yet others don’t and never seem to encounter a problem.

Why Trim?

Data stored on a hard disk doesn’t need to be erased before the space it takes can be reused, but SSDs work differently. Before a page of SSD memory can be reused, it must be erased, and that’s the part that takes time. If a fast SSD had to erase each page when it needed to write to it, that SSD wouldn’t be much faster than a good hard disk.

To overcome this problem, when the file system has pages that no longer contain data in use, it should tell the SSD that they’re free so they can be erased to prepare them for reuse. In SATA SSDs that’s performed by the TRIM command, and its equivalent for faster NVMe SSDs is DEALLOCATE, although it’s the older command whose name has stuck.

Modern SSDs also perform their own housekeeping, and in many cases may not need to be Trimmed at all. However, when an operating system and SSD both support Trim (or DEALLOCATE), that should ensure optimum performance.

When an SSD doesn’t get Trimmed and can’t compensate for that with its own housekeeping routines, its performance suffers noticeably. This is most commonly seen with SATA SSDs that would normally have write speeds of around 500 MB/s. When they need a good Trim, that can fall to around 100 MB/s, the same speed you’d expect from a hard disk. But this doesn’t affect read speeds at all, so one way of telling whether an SSD needs Trimming is to measure its read and write speeds.

Which SSDs are Trimmed?

You’ll be delighted to know that, for their relatively high cost, all Apple internal SSDs Trim reliably, without any need for tweaking any settings.

As a rule, external SSDs don’t Trim by default if they have a SATA interface, giving them read and write speeds of about 500 MB/s. Those with faster NVMe interfaces, including those connected by Thunderbolt 3-5 or USB4, should Trim by default when they’re formatted in APFS.

System Information normally lists a drive’s Trim support, if you can find the right section. Browse its Hardware section to discover the protocols the drive supports. These can be confusing, as the SSD and its enclosure may well have multiple entries in different headings, and some of the information may appear conflicting.

trim01

USB4 drives operating in Thunderbolt 3 mode can also be confusing. When connected to an Intel Mac (which doesn’t support USB4 itself) they may be reported in the Thunderbolt/USB4 device tree as being USB4.0 operating in Thunderbolt 3 mode, with a link speed of up to 40 Gbit/s, then in the NVMExpress device tree with a link width of x4 and speed of 8.0 GT/s.

SATA drives should appear in the Serial-ATA device tree, even though they might be connected via Thunderbolt 3, and you may see a statement of Trim support.

trim02

Device trees worth inspecting include: NVMExpress, PCI, SATA, Storage, Thunderbolt/USB4 and USB.

Which file systems Trim?

Trim is well-demonstrated in SSDs formatted in APFS, and is known to occur in HFS+. However, old PC files systems like ExFAT don’t have any Trim support, and it can’t be enabled in a Mac at least.

Unfortunately, as HFS+ is now an old Mac filesystem, it can’t readily be seen in log entries, while those from APFS contain valuable detail that makes them suitable for use when testing for Trim.

How to verify Trim

Use Mints to verify whether your external drive does get trimmed correctly when it’s mounted, using its Disk Mount feature. In essence, what you do is:

  1. Eject and disconnect the external drive.
  2. Connect the drive at a known time, according to the Mac’s clock.
  3. Leave the Mac alone until all that disk’s volumes have been mounted.
  4. 20 seconds after connecting the drive, or 10 seconds after the last of its volumes has mounted, open the Mints app.
  5. Click on the Disk Mount button, and set the time in its log window to the time at which you connected the drive.
  6. Set the period to a minimum of 20 seconds, long enough to cover the period up to 10 seconds after the last volume mounted.
  7. Uncheck all the category checkboxes except the first, APFS +.
  8. Click the Get log button.
  9. When log entries are displayed, scroll to the end and look back for APFS trim entries.

This only works for APFS, though, as log entries for HFS+ don’t appear to show Trimming in this way.

trim05

Those entries are characteristically of the form
23-03-25 19:01:06.930 apfs spaceman_scan_free_blocks:3311: disk5 scan took 0.030901 s (no trims)
23-03-25 19:01:10.960 apfs spaceman_scan_free_blocks:3293: disk5 scan took 4.030544 s, trims took 3.944665 s
23-03-25 19:01:10.960 apfs spaceman_scan_free_blocks:3295: disk5 471965989 blocks free in 9131 extents
23-03-25 19:01:10.960 apfs spaceman_scan_free_blocks:3303: disk5 471965989 blocks trimmed in 9131 extents (432 us/trim, 2314 trims/s)
23-03-25 19:01:10.960 apfs spaceman_scan_free_blocks:3306: disk5 trim distribution 1:1461 2+:1267 4+:4121 16+:785 64+:822 256+:675

trim06

Check that the named disk, here disk5, is the SSD or APFS container on the SSD that you’re checking. If it has entries reporting that blocks have been trimmed, this confirms that the SSD has been trimmed as expected. Disks that don’t trim normally only show the first of that series, ending in the words no trims.

It’s possible to enable Trim for all external storage using the trimforce command, but you should normally verify that your external SSD does Trim correctly when mounted.

If you have an SSD that hasn’t been Trimming and is suffering poor write performance, you may be able to help it recover by copying its contents to another disk, then erasing its volumes, or the whole container. Those should return their whole contents as free space, and so enable the SSD’s own housekeeping to erase them in readiness for reuse.

个人备份指北

By: Lucky
14 June 2022 at 22:30

备份的意义

我想大家都多多少少遇到过设备死机、进水、被偷,甚至被黑客勒索的事情吧。从概率上来说,数据丢失只是早晚的事情。这就是为什么要备份,不然可能青春的回忆,各种美好就再也不见了,那会很痛,可能比失恋还痛。

「不同裝置都有相同的資料才叫作資料備份,只是換個裝置存放不叫做備份[1]

我和一些网络上厉害的家伙聊过,发现他们也没有做到真正的备份。把数据一股脑丢进硬盘,把数据丢进各种网盘/云服务,甚至程序员也只是把代码放在 GitHub 上。这些都不是备份,国内的网盘不说了,诸如 iCloud 和 Google Drive,本质是个同步盘。历史上不管是 iCloud 还是 Google Drive 都出现过宕机问题,不把鸡蛋放在一个篮子里,要狡兔三窟。

备份的目的是为了可以「无损」还原,如果不能还原,储存再多的数据也没有意义。

备份类型

  • 全部备份(Full Backup,包括系统)备份数据量大,备份所需时间长。
  • 增量备份(Incremental Backup)自上一次完全备份后有变化数据的备份
  • 差异备份 (Differential backup) 提供完整备份后变更的文件

第一种全盘备份,举个例子,从一台电脑上一模一样搬迁到另一台电脑上。有些备份是不包括系统设置数据的,还原数据后需要重新设定应用设置、字体大小、系统语言啊,种种……准备系统备份的好处在于带有一个开机系统,比如 Windows 的 WinPE,macOS 的可引导安装器

差异备份与增量备份的区别在于前者包括上一次完全备份、差异备份或增量备份,后者仅是上一次完全备份后有变化。挺绕的……

3-2-1-1-0 原则

  • 至少做三份数据副本(一份本体,两份 copy)
  • 存储在至少两种不同类型的存储介质
  • 在异地位置保留一份备份副本

在 3-2-1 原则再加两点[2]

  • 将一份媒体副本离线或隔空
  • 确保所有可恢复性解决方案没有错误(刚说备份之目的)

在这个科技高度发展的年代,其实最安全的储存方式还是用磁带保存,埋在一个角落(比如 GitHub 埋在北极的胶片[3])。

云备份

当然我们不用这么极端,用个靠谱的云备份就行了,也是一种异地备份。刚刚讲过,常规的那些网盘不算备份,要选择专门用来备份的云存储服务,那么靠谱的备份服务有哪些呢,可选的不多。

大家公认的有 Backblaze Personal Backup。每月 $7,不限备份容量,从 2007 年运营至今,稳定。懒人首选,只要后台开着软件就可以无感备份,手机端有 App 也可以备份。

对于国内用户来说由于网络封锁,需要耗费代理流量,第一次备份需要注意流量。从国内访问,稳定性一定要考虑,可是目前无解。

还有一个严格意义来说不算提供云储存服务的软件——Arq, 2009 年运营,$49.99 买断单设备,Premium $59.99/year(提供 1 TB 云空间,不推荐)

搭配第三方云端空间使用,官方描述:Use it for encrypted, versioned backups of your important files. 有加密功能不错。

相当于一个云服务整合管理器

硬盘备份

推荐用硬盘来储存,硬盘分为 HDD(机械硬盘)和 SSD(固态硬盘),硬盘可是大有学问,这里不展开了,感兴趣的可以在本 blog 搜索 SSD

相比之下 SSD 的优势在:

  1. SSD 读取写入速度快,快就是王道
  2. SSD 的寿命(写入和擦除)长
  3. SSD 可以在使用中移动

缺点:

  1. 售价贵
  2. 恢复数据困难

不管是 HDD 还是 SSD,「任何的存储装置都是消耗品」,说不定哪天就挂掉了,所以多准备一块硬盘吧。虽然 SSD 也能抢救资料,但是恢复难度大(要看硬盘哪里损坏)关键是数据恢复又贵(基本 ¥2000 以上)又麻烦还不安全(冠希哥艳照门)。

Time Machine

用 Mac 的同学可以用一下这个,免费,但是不太好用,设定逻辑太简单,Apple 没有好好做,所以有下面的软件推荐。

搭配硬盘使用的备份软件

  • SuperDuper (2004 年 $27.95 买断制,有免费版功能少一点也可以用,优点是可以把 SSD 作为一个启动盘,支持差异备份。

  • Carbon Copy Cloner 6 $39.99 更加老牌的一个软件,官方的口号是「A leader in Mac backups since 2002」,速度和稳定性比 Time Machine 好,口碑不错。

上述备份软件和 Backblaze 都提供试用,可以选择一款适合自己的。

NAS 备份

我没有使用 NAS,这方面不了解,根据需求选择。用 NAS 也要有双保险,做好异地备份。虽然硬盘不怕坏了,但是也有一些不可抗力因素。

备份内容

除了全盘备份,还需要注意保存在云上的数据,比如我存在 Bitwarden 上的密码。暂时好像没有别的了。


看了那么多,今天你备份了吗?Just do it!

参考

PrimoCache:让固态硬盘作为缓存给机械硬盘加速

By: 胡中元
29 May 2018 at 13:22

对于电脑硬盘,固态肯定是全方面优于机械硬盘的选择,不过按照马克思主义矛盾论的观点,这就存在一个 “低速的 HDD 与高价的 SSD” 之间的矛盾。目前我的笔记本使用 128G+1T 的组合,处于并将长期处于 “个人电脑硬盘的基本矛盾” 之中。

直到,我遇到了 PrimoCache 这款软件。推荐给大家。

PrimoCache 是一款可以将物理内存、SSD 硬盘或闪存盘等虚拟成硬盘缓存的软件。它可以自动将硬盘中读取的数据存入物理内存等速度较快的设备,当系统再次需要该数据时它可以很快从缓存设备中读取,而无需再次访问速度较慢的硬盘,从而有效提升物理硬盘的访问性能。

中文官网:http://www.romexsoftware.com/zh-cn/primo-cache/index.html
平台:Windows(其实 *nix 下也有类似的)
软件类型:共享软件

两个月后更新:

经过 2 个月的实际体验,这款软件并没有宣传的那么完美。少数软件一运行就会完全死机(跑跑卡丁车,并确定是由该软件造成的),整个系统也似乎有一种不稳定的感觉(偶尔弹出一些意义不明的错误提示)。另外还有额外的内存占用。

总之,不推荐将系统盘加速,也不推荐大多数情况下的使用。除非你有一些常玩的游戏,但由于几十 GB 的体积巨大不能放入 SSD,才值得使用此软件。

缓存技术

这种理念我认为非常好,Cache 技术也是计算机硬件软件当中一个使用非常广泛的技术。这和最初的英特尔快速存储技术(RST)以及英特尔傲腾技术类似。都是使用少量高速的 SSD 作为缓存,为低速的 HDD 加速, 使得电脑拥有 HDD 的大容量的同时,拥有接近于 SSD 的速度。

至于什么数据会被缓存到 SDD 中?这是由算法控制的,自动选择 HDD 中最常用的那些数据。

PrimoCache 与 RST 或者傲腾的区别在于,这款软件不需要你使用最新的 Intel 主板,或者是购买 Intel 家的傲腾内存,它兼容一切现有的 SSD。

PrimoCache 还支持使用内存作为一级缓存,SSD 作为二级缓存

是的,这也是 PrimoCache 的一个特有的功能,内存的每秒读写速度单位在 GB 级别,比 SSD 高了一个量级,能有效为 SSD 加速。(不过我还没有直观感受到差异,大概在这时瓶颈已经不在 IO 了)

效果展示

我现在终于可以把动辄几十 G 的游戏放心的放在机械硬盘了,然后使用 PrimoCache 让他们拥有令人满意的读取速度。

我使用了 12G SSD 作为二级缓存,1G RAM 作为一级缓存,运行测速工具对机械硬盘测速结果如下:

未使用缓存:

使用缓存:

注意,由于缓存的原理是将常用数据放在 SSD、RAM 中,需要时快速获取,所以使用测试软件随机读取或写入时并没有预存这个过程,并不能反映实际效果。
但是我们也可以看到明显的进步了。

注意事项

发现的缺点:

  • 使用二级缓存 SSD 时,需要占用一定量的内存用于存储映射。
  • 这是一个收费软件,虽然有破解版。
  • 之前出现了一次显卡被降频,关闭该软件后恢复。但后来开启该软件又没有出现类似状态。

此外,虽然我的 RAM 有 16GB,但我也只使用了不到 2GB 作为硬盘缓存,因为我觉得目前大多数大型软件都会使用 RAM 为自己加速,我们没必要多此一举。并且充裕的 RAM 本身也是提升电脑响应速度的途径。

❌
❌