ATA Trim
Mit dem ATA Trim Kommando teilt das Betriebssystem einer SSD mit welche Datenbereiche nicht mehr benötigt werden und damit als gelöscht angesehen werden können. Wenn die gesamte Kapazität einer SSD genutzt wird erhöht ATA Trim die Performance und Lebensdauer der SSD. Ist ATA Trim nicht möglich (wie etwa beim Einsatz von RAID Controllern) bringt ein Over-Provisioning ähnliche Vorteile - allerdings mit etwas verminderter nutzbarer Kapazität (z.B. 90%).[1]
Voraussetzungen
Damit ATA Trim funktioniert muss es von folgenden Komponenten unterstützt werden:
- von der SSD selbst
- vom Betriebssystem (z.B. Windows 7[2], Windows 8 [3] , Linux Kernel ab Version 2.6.33[4]
- vom Dateisystem
ATA Trim mit RAID Controllern
Mit Stand Mai 2015 sind uns noch keine RAID-Controller bekannt, die ATA TRIM für SSDs in RAID-Volumes unterstützen.[5][6] Das Firmware/Driver RAID von Intel unterstützt ab Rapid Storage Technology 9.6 das TRIM Kommando für Laufwerke (im AHCI Modus und im RAID Modus), die nicht Teil eines RAID-Volumes sind.[7] Für RAID 0 Verbünde unterstützt RST ab Version 11 ebenfalls ATA Trim, jedoch nur unter Windows 7.[8][9]
ATA Trim bei Linux Swap Devices
Swap Devices unter Linux unterstützen Discard:[10][11][12]
- der Linux Kernel unterstützt Discard für Trim für Swap-Devices ab Kernel 2.6.29
- da manche SSDs bei sofortigem Discard Performance-Einbußen zeigen, ist der laufende Discard seit Kernel 2.6.36 nun optional (-d Option von swapon)
- beim erstmaligen Aufruf von swapon wird aber weiterhin unabhängig von der -d Option der gesamte Swap-Bereich per Discard getrimmt
ATA Trim mit Linux Device Mapper
Ab Kernel 2.6.36 haben folgende Targets Support für Discard:
- dm-delay
- dm-linear
- dm-mpath
- dm-stripe (raid0)
Ab Kernel 2.6.38 zusätzlich:
- dm-mirror (raid1)
Ab Kernel 3.1 zusätzlich:
- dm-crypt (optional)
Ab Kernel 3.18 zusätzlich:
- dm-raid
ATA Trim mit Linux LVM
LVM basiert seit Linux Kernel 2.6 auf dem Device Mapper und verwendet dabei das dm-linear Target (siehe LVM Grundlagen - LVM und Device Mapper).
Damit unterstützt LVM seit Kernel 2.6.36 ATA Trim.
ATA Trim mit Linux Software RAID
Seit Linux Kernel 3.7 unterstützt Linux Software RAID ATA Trim.
Online oder Batched
ATA Trim kann entweder sofort zur Laufzeit beim Löschen von Dateien die entsprechenden Daten auf der SSD löschen (unter Linux als Online Discard[13][14] bezeichnet) oder zyklisch manuell durch Hilfsprogramme nicht mehr benötigte Blöcke freigeben (unter Linux mit FITRIM ioctl als Batched Discard bezeichnet), wie die Tabelle zeigt:
Betriebssystem / Dateisystem | automatisches ATA TRIM (Daten werden sofort gelöscht) |
manuelles ATA TRIM (Daten werden mit einem Tool gelöscht) |
---|---|---|
Windows Vista Windows XP Windows Server 2008 Windows Server 2003 |
- | ja, über Herstellertools wie die Intel Solid State Drive Toolbox |
Windows 7 Windows Server 2008 R2 |
ja[15][16] | ja, über Herstellertools wie die Intel Solid State Drive Toolbox |
Windows 8 Windows Server 2012 R2 |
ja[17] | ja, über Herstellertools wie die Intel Solid State Drive Toolbox |
Linux / Ext4 | ja, Online Discard ab Kernel 2.6.33 (erfordert Ext4 Option discard) |
ja, über wiper.sh[18] (nutzt hdparm)[19] oder Batched Discard ab Kernel 2.6.37 über fstrim[20][21][22] (in util-linux 2.19 und neuer enthalten)[23] Siehe auch: Wöchentliches fstrim ab Ubuntu 14.04 |
Linux / Btrfs | ja, Online Discard ab Linux Kernel 2.6.32 (das Libata Subsystem unterstützt Discard ab Kernel 2.6.33) (erfordert Btrfs Option discard) |
ja, Batched Discard ab Kernel 2.6.39 |
Beispiel: ATA Trim in Ubuntu 10.10
Damit Sie ATA Trim nutzen können, muss die SSD selbst ATA TRIM unterstützen, wie auch in diesem Beispiel hier (der * zeigt, dass die Option verfügbar ist):
root@ubuntu-10-10:~# hdparm -I /dev/sda | grep -i trim * Data Set Management TRIM supported * Deterministic read ZEROs after TRIM root@ubuntu-10-10:~#
Standardkonfiguration ohne ATA Trim
In diesem Test schreiben wir die Buchstabenkette ABCDEFGHIJKLMNOPQRSTUVWXYZ in eine Datei. Beim Lesen des Sektors mit hdparm werden die entsprechenden ASCII-Codes[24] im Hex-Format sichtbar.
Anmerkung: bei manchen SSDs (z.B. Intel 320 Series SSDs) ist nach dem echo
Kommando Aufruf von sync
notwendig, damit hdparm --fibmap
LBA Grenzen ausgibt.
root@ubuntu-10-10:~# echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > /root/testfile1.txt root@ubuntu-10-10:~# hdparm --fibmap /root/testfile1.txt /root/testfile1.txt: filesystem blocksize 4096, begins at LBA 61052928; assuming 512 byte sectors. byte_offset begin_LBA end_LBA sectors 0 66989472 66989479 8 root@ubuntu-10-10:~# hdparm --read-sector 66989472 /dev/sda /dev/sda: reading sector 66989472: succeeded 4241 4443 4645 4847 4a49 4c4b 4e4d 504f 5251 5453 5655 5857 5a59 000a 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 [...] root@ubuntu-10-10:~# rm /root/testfile1.txt root@ubuntu-10-10:~# sync root@ubuntu-10-10:~# hdparm --read-sector 66989472 /dev/sda /dev/sda: reading sector 66989472: succeeded 4241 4443 4645 4847 4a49 4c4b 4e4d 504f 5251 5453 5655 5857 5a59 000a 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 [...] root@ubuntu-10-10:~#
Konfiguration mit ATA Trim mit Online Discard
Mit der aktivierten ext4 Mount Option discard schickt das ext4 Dateisystem discard/TRIM Kommandos an das darunter liegende Storage Device. Die Option muss derzeit allerdings noch manuell in /etc/fstab aktiviert werden, da discard in der Standardkonfiguration deaktiviert ist:[25]
- discard: Controls whether ext4 should issue discard/TRIM commands to the underlying block device when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done.
Die Option discard kann einfach als Option in /etc/fstab ergänzt werden:
[...] # / was on /dev/sda3 during installation UUID=1b7be627-fcb5-43b4-a9fb-72c112041c53 / ext4 errors=remount-ro,discard 0 1 [...]
Nach einem Reboot ist die Option für die /-Partition nun aktiv:
root@ubuntu-10-10:~# mount /dev/sda3 on / type ext4 (rw,errors=remount-ro,discard,commit=600) [...] root@ubuntu-10-10:~#
Beim Löschen von Dateien werden die entsprechenden Daten nun tatsächlich auf der SSD entfernt:
root@ubuntu-10-10:~# echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > /root/testfile2.txt root@ubuntu-10-10:~# sync root@ubuntu-10-10:~# hdparm --fibmap /root/testfile2.txt /root/testfile2.txt: filesystem blocksize 4096, begins at LBA 61052928; assuming 512 byte sectors. byte_offset begin_LBA end_LBA sectors 0 73902760 73902767 8 root@ubuntu-10-10:~# hdparm --read-sector 73902760 /dev/sda /dev/sda: reading sector 73902760: succeeded 4241 4443 4645 4847 4a49 4c4b 4e4d 504f 5251 5453 5655 5857 5a59 000a 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 [...] root@ubuntu-10-10:~# rm /root/testfile2.txt root@ubuntu-10-10:~# sync root@ubuntu-10-10:~# hdparm --read-sector 73902760 /dev/sda /dev/sda: reading sector 73902760: succeeded 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 [...] root@ubuntu-10-10:~#
Weitere Informationen zu ATA Trim unter Linux
- SSD discard (trim) support (en.opensuse.org)
- Ubuntu 10.04 LTS enthält Kernel 2.6.32 und wird keinen backported Online Discard Support bekommen: Trim support missing from Linux kernel (bugs.launchpad.net)
- Does Ubuntu have support for the TRIM command for use with SSD? (askubuntu.com)
- wiper.sh and TRIM on an SSD (ubuntuforums.org)
- How to enable TRIM? (askubuntu.com)
- HOWTO: Configure Ext4 to Enable TRIM Support for SSDs on Ubuntu and Other Distributions (lightrush's Web Nest, 17.10.2010)
- Performance evaluation of Linux Discard Support (Präsentation von Lukas Czerner (Red Hat), 12.02.2011)
- Enabling and Testing SSD TRIM Support Under Linux (techgage.com, 06.05.2011)
- TRIM (wiki.ubuntuusers.de)
Einzelnachweise
- ↑ Re: Software RAID and TRIM (spinics.net) As long as your SSDs have some over-provisioning (or you only partition something like 90% of the drive), and it's got good garbage collection, then TRIM will have minimal effect.
- ↑ Engineering Windows 7 (blogs.msdn.com, 05.05.2009)
- ↑ Windows und SSD - Konfiguration und Optimierung (answers.microsoft.com, 31.07.2013)
- ↑ Trimmen (heise.de, 24.02.2010)
- ↑ Kein Trim-Befehl im SSD-RAID? (heise.de)
- ↑ SSD TRIM command support and Adaptec RAID controllers (ask.adaptec.com, Answer ID 16994)
- ↑ Intel® Rapid Storage Technology: RAID features by chipset/controller hub (intel.com)
- ↑ Intel Brings TRIM to RAID-0 SSD Arrays on 7-Series Motherboards, We Test It (anandtech.com, 16.08.2012)
- ↑ Intel Solid-State Drive Toolbox (downloadcenter.intel.com) Optimize the performance of an Intel SSD in RAID 0 using Trim functionality Intel® Rapid Storage Technology (Intel® RST) 11.0 or greater. NOTE: Trim on RAID 0 is not supported on Windows 8* or Windows Server 2012
- ↑ swap: discard while swapping only if SWAP_FLAG_DISCARD (git.kernel.org)
- ↑ discard change to swapon(2) and swapon(8) (spinics.net, 24.10.2010)
- ↑ Re: discard change to swapon(2) and swapon(8) (spinics.net, 09.11.2010)
- ↑ Kernel realtime discard support (en.opensuse.org)
- ↑ Patchwork (2/6) libata: Report supported TRIM payload size (patchwork.ozlabs.org)The bigger problem for now is that the block layer does not export a way to pass in a vectorized list of ranges to discard.
- ↑ http://en.wikipedia.org/wiki/TRIM#Operating_system_and_SSD_support (en.wikipedia.org)
- ↑ http://www.heise.de/newsticker/meldung/SSD-Hersteller-optimieren-Firmware-fuer-Windows-7-2-Update-842820.html (heise.de, 27.10.2009)
- ↑ http://redmondmag.com/articles/2013/06/19/win-server-2012-r2-additions.aspx (redmondmag.com, 21.06.2013)
- ↑ hdparm (sourceforge.net)
- ↑ Re: (PATCH 2/6) libata: Report supported TRIM payload size (spinics.net, 19.08.2010) The fundamental problem with hdparm is that because it bypasses most of the kernel i/o stack, it is not compatible with DM/LVM, but I think its a great prototype of what the kernel could do eventually.
- ↑ Ext4: batched discard support (lwn.net, 19.04.2010)
- ↑ Kernel-Log – Was 2.6.37 bringt (2): Dateisysteme (heise.de, 05.12.2010)
- ↑ Fstrim (sourceforge.net)
- ↑ fstrim: add new command (git.kernel.org)
- ↑ ASCII-Tabelle (de.wikipedia.org)
- ↑ Ext4 Filesystem (kernel.org)
Autor: Werner Fischer Werner Fischer arbeitet im Product Management Team von Thomas-Krenn. Er evaluiert dabei neueste Technologien und teilt sein Wissen in Fachartikeln, bei Konferenzen und im Thomas-Krenn Wiki. Bereits 2005 - ein Jahr nach seinem Abschluss des Studiums zu Computer- und Mediensicherheit an der FH Hagenberg - heuerte er beim bayerischen Server-Hersteller an. Als Öffi-Fan nutzt er gerne Bus & Bahn und genießt seinen morgendlichen Spaziergang ins Büro.
|