Difference between revisions of "Solid state drive"

From ArchWiki
Jump to navigation Jump to search
m (TRIM: adapt note: filesystems' articles do not contain further details regarding TRIM support)
(Remove section I added on WD drives, seems common problem with multiple brands to have to add nvme_core.default_ps_max_latency_us=5500)
 
(50 intermediate revisions by 20 users not shown)
Line 1: Line 1:
 
[[Category:Storage]]
 
[[Category:Storage]]
[[it:Solid State Drives]]
+
[[it:Solid state drive]]
 
[[ja:ソリッドステートドライブ]]
 
[[ja:ソリッドステートドライブ]]
[[ru:Solid State Drives]]
+
[[ru:Solid state drive]]
[[zh-hans:Solid State Drives]]
+
[[zh-hans:Solid state drive]]
[[zh-hant:Solid State Drives]]
+
[[zh-hant:Solid state drive]]
 
{{Related articles start}}
 
{{Related articles start}}
{{Related|Solid State Drives/NVMe}}
+
{{Related|Solid state drive/NVMe}}
{{Related|Solid State Drives/Memory cell clearing}}
+
{{Related|Solid state drive/Memory cell clearing}}
 
{{Related|Benchmarking/Data storage devices}}
 
{{Related|Benchmarking/Data storage devices}}
 
{{Related|Improving performance#Storage devices}}
 
{{Related|Improving performance#Storage devices}}
 +
{{Related|Flashcache}}
 
{{Related articles end}}
 
{{Related articles end}}
This article covers special topics for operating [[w:Solid State Drive]]s (SSDs) and other flash-memory based storage devices. If you want to partition an SSD for a specific purpose, it may be useful to consider the [[w:List_of_file_systems#File_systems_optimized_for_flash_memory.2C_solid_state_media|List of file systems optimized for flash memory]]. For general usage, you should simply choose your preferred [[filesystem]].
+
This article covers special topics for operating [[Wikipedia:Solid-state drive|solid state drives]] (SSDs) and other flash-memory based storage devices. If you want to partition an SSD for a specific purpose, it may be useful to consider the [[Wikipedia:List of file systems#File systems optimized for flash memory, solid state media|List of file systems optimized for flash memory]]. For general usage, you should simply choose your preferred [[filesystem]].
  
 
== Usage ==
 
== Usage ==
 +
 
=== TRIM ===
 
=== TRIM ===
  
Most SSDs support the [[wikipedia:TRIM|ATA_TRIM command]] for sustained long-term performance and wear-leveling. A [http://www.techspot.com/review/737-ocz-vector-150-ssd/page9.html techspot] article shows performance benchmark examples of before and after filling an SSD with data.
+
Most SSDs support the [[wikipedia:TRIM|ATA_TRIM command]] for sustained long-term performance and wear-leveling. A [https://www.techspot.com/review/737-ocz-vector-150-ssd/page9.html techspot article] shows performance benchmark examples of before and after filling an SSD with data.
  
 
As of Linux kernel version 3.8 onwards, support for TRIM was continually added for the different [[filesystems]]. See the following table for an indicative overview:
 
As of Linux kernel version 3.8 onwards, support for TRIM was continually added for the different [[filesystems]]. See the following table for an indicative overview:
Line 25: Line 27:
 
| [[Ext3]] || {{No}} || {{META Table cell|?}} ||  
 
| [[Ext3]] || {{No}} || {{META Table cell|?}} ||  
 
|-
 
|-
| [[Ext4]] || {{Yes}} || {{Yes}} || [http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/ext4.txt#n344]
+
| [[Ext4]] || {{Yes}} || {{Yes}} || [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/ext4.txt?id=5012284700775a4e6e3fbe7eac4c543c4874b559#n342]
 
|-
 
|-
 
| [[Btrfs]] || {{Yes}} || {{Yes}} ||
 
| [[Btrfs]] || {{Yes}} || {{Yes}} ||
 
|-
 
|-
| [[JFS]] || {{Yes}} || {{Yes}} || [http://www.phoronix.com/scan.php?page=news_item&px=MTE5ODY]
+
| [[JFS]] || {{Yes}} || {{Yes}} || [https://www.phoronix.com/scan.php?page=news_item&px=MTE5ODY]
 
|-
 
|-
 
| [[XFS]] || {{Yes}} || {{Yes}} || [http://xfs.org/index.php/FITRIM/discard]
 
| [[XFS]] || {{Yes}} || {{Yes}} || [http://xfs.org/index.php/FITRIM/discard]
Line 35: Line 37:
 
| [[F2FS]] || {{Yes}} || {{Yes}} ||
 
| [[F2FS]] || {{Yes}} || {{Yes}} ||
 
|-
 
|-
| [[VFAT]] || {{Yes}} || {{No}} ||
+
| [[VFAT]] || {{Yes}} || {{Yes}} || ''fstrim'' is supported since kernel 4.19
 
|-
 
|-
| {{Pkg|ntfs-3g}} || {{No}} || {{Yes}} || since version 2015.3.14, [http://permalink.gmane.org/gmane.comp.file-systems.ntfs-3g.devel/1101]
+
| [[NTFS-3G]] || {{No}} || {{Yes}} || since version 2015.3.14, [http://permalink.gmane.org/gmane.comp.file-systems.ntfs-3g.devel/1101]
 
|}
 
|}
  
Line 44: Line 46:
 
To verify TRIM support, run:
 
To verify TRIM support, run:
  
  # lsblk -D
+
  $ lsblk --discard
  
And check the values of DISC-GRAN and DISC-MAX columns. Non-zero values indicate TRIM support.
+
And check the values of DISC-GRAN (discard granularity) and DISC-MAX (discard max bytes) columns. Non-zero values indicate TRIM support.
  
Or [[install]] {{Pkg|hdparm}} package and run:
+
Alternatively, [[install]] {{Pkg|hdparm}} package and run:
  
# hdparm -I /dev/sda | grep TRIM
+
{{hc|# hdparm -I /dev/sda {{!}} grep TRIM|
        *    Data Set Management TRIM supported (limit 1 block)
+
        *    Data Set Management TRIM supported (limit 1 block)
 +
}}
  
{{Note|There are different types of TRIM support defined by the specification. Hence, the output may differ depending what the drive supports. See [[w:TRIM#ATA]] for more information.}}
+
{{Note|There are different types of TRIM support defined by the specification. Hence, the output may differ depending what the drive supports. See [[Wikipedia:TRIM#ATA]] for more information.}}
  
 
==== Periodic TRIM ====
 
==== Periodic TRIM ====
Line 65: Line 68:
 
==== Continuous TRIM ====
 
==== Continuous TRIM ====
  
{{Warning|Unfortunately, there are wide quality gaps of SSD's bios' to perform continuous TRIM, which is also why using the {{ic|discard}} mount flag is [https://forums.freebsd.org/threads/56951/#post-328912 recommended against] generally by ext filesystem developer Theodore Ts'o. If in doubt about your hardware, apply [[#Periodic TRIM]] instead.}}
+
{{Note|There is no need to enable continuous TRIM if you run {{ic|fstrim}} periodically. If you want to use TRIM, use either periodic TRIM or continuous TRIM.}}
 +
 
 +
Instead of issuing TRIM commands once in a while (by default once a week if using {{ic|fstrim.timer}}), it is also possible to issue TRIM commands each time files are deleted instead. The latter is known as the continuous TRIM.
  
{{Note|Before [[w:Serial_ATA#SATA_revision_3.1|SATA 3.1]] all TRIM commands were synchronous, so continuous trimming would produce frequent system freezes. In this case, applying [[#Periodic TRIM]] less often is better alternative. Similar issue holds also for a [https://github.com/torvalds/linux/blob/master/drivers/ata/libata-core.c#L4403-L4417 number of devices], for which queued TRIM command execution was blacklisted due to [https://blog.algolia.com/when-solid-state-drives-are-not-that-solid/ serious data corruption]. See [[Wikipedia:Trim (computing)#Shortcomings]] for details.}}
+
{{Warning|Before [[Wikipedia:Serial ATA#SATA revision 3.1|SATA 3.1]] all TRIM commands were non-queued, so continuous trimming would produce frequent system freezes. In this case, applying [[#Periodic TRIM]] less often is better alternative. Similar issue holds also for a [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/libata-core.c#n4522 number of devices], for which queued TRIM command execution was blacklisted due to [https://blog.algolia.com/when-solid-state-drives-are-not-that-solid/ serious data corruption]. In such case, depending on the device, the system may be forced to send non-queued TRIM commands the SSD instead of queued TRIM. See [[Wikipedia:Trim_(computing)#Disadvantages]] for details.}}
 +
 
 +
{{Note|Continuous TRIM is not the most preferred way to issue TRIM commands among the Linux community. For example, Ubuntu enables periodic TRIM by default [https://askubuntu.com/questions/1034169/is-trim-enabled-on-my-ubuntu-18-04-installation], Debian does not recommend using continuous TRIM [https://wiki.debian.org/SSDOptimization#Mounting_SSD_filesystems] and Red Hat recommends using periodic TRIM over using continuous TRIM if feasible. [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Storage_Administration_Guide/ch02s04.html]}}
  
 
Using the {{ic|discard}} option for a mount in {{ic|/etc/fstab}} enables continuous TRIM in device operations:
 
Using the {{ic|discard}} option for a mount in {{ic|/etc/fstab}} enables continuous TRIM in device operations:
Line 73: Line 80:
 
  /dev/sda1  /          ext4  defaults,'''discard'''  0  1
 
  /dev/sda1  /          ext4  defaults,'''discard'''  0  1
  
The main benefit of continuous TRIM is speed; an SSD can perform more efficient [http://arstechnica.com/gadgets/2015/04/ask-ars-my-ssd-does-garbage-collection-so-i-dont-need-trim-right/ garbage collection]. However, results vary and particularly earlier SSD generations may also show just the opposite effect. Also for this reason, some distributions decided against using it (e.g. Ubuntu: see [http://www.phoronix.com/scan.php?page=news_item&px=MTUxOTY this article] and the [https://blueprints.launchpad.net/ubuntu/+spec/core-1311-ssd-trimming related blueprint]).
+
{{Note|1=Specifying the discard mount option in {{ic|/etc/fstab}} does not work with an XFS {{ic|/}} partition. According to [https://bbs.archlinux.org/viewtopic.php?id=143254 this thread], it has to be set using the {{ic|1=rootflags=discard}} [[kernel parameter]].}}
 
 
{{Note|There is no need for the {{ic|discard}} flag if you run {{ic|fstrim}} periodically.}}
 
  
 
On the ext4 filesystem, the {{ic|discard}} flag can also be set as a [[Access_Control_Lists#Enabling_ACL|default mount option]] using ''tune2fs'':
 
On the ext4 filesystem, the {{ic|discard}} flag can also be set as a [[Access_Control_Lists#Enabling_ACL|default mount option]] using ''tune2fs'':
Line 81: Line 86:
 
  # tune2fs -o discard /dev/sd'''XY'''
 
  # tune2fs -o discard /dev/sd'''XY'''
  
Using the default mount options instead of an entry in {{ic|/etc/fstab}} is useful for external drives, because such partition will be mounted with the default options also on other machines. There is no need to edit {{ic|/etc/fstab}} on every machine.
+
Using the default mount options instead of an entry in {{ic|/etc/fstab}} is particularly useful for external drives, because such partition will be mounted with the default options also on other machines. This way, there is no need to edit {{ic|/etc/fstab}} on every machine.
  
 
{{Note|The default mount options are not listed in {{ic|/proc/mounts}}.}}
 
{{Note|The default mount options are not listed in {{ic|/proc/mounts}}.}}
Line 101: Line 106:
 
==== dm-crypt ====
 
==== dm-crypt ====
  
{{Warning|The discard option allows discard requests to be passed through the encrypted block device. This improves performance on SSD storage but has security implications. See [[Dm-crypt/Specialties#Discard.2FTRIM_support_for_solid_state_drives_.28SSD.29|Dm-crypt/TRIM support for SSD]] for more information.}}
+
{{Warning|The discard option allows discard requests to be passed through the encrypted block device. This improves performance on SSD storage but has security implications. See [[dm-crypt/Specialties#Discard/TRIM support for solid state drives (SSD)]] for more information.}}
  
For non-root filesystems, configure {{ic|/etc/crypttab}} to include {{ic|discard}} in the list of options for encrypted block devices located on an SSD (see [[Dm-crypt/System configuration#crypttab]]).
+
For non-root filesystems, configure {{ic|/etc/crypttab}} to include {{ic|discard}} in the list of options for encrypted block devices located on an SSD (see [[dm-crypt/System configuration#crypttab]]).
  
For the root filesystem, follow the instructions from [[Dm-crypt/Specialties#Discard.2FTRIM_support_for_solid_state_drives_.28SSD.29|Dm-crypt/TRIM support for SSD]] to add the right kernel parameter to the bootloader configuration.
+
For the root filesystem, follow the instructions from [[dm-crypt/Specialties#Discard/TRIM support for solid state drives (SSD)]] to add the right kernel parameter to the bootloader configuration.
  
 
=== Maximizing performance ===
 
=== Maximizing performance ===
Line 126: Line 131:
 
  not expired: security count
 
  not expired: security count
 
  supported: enhanced erase
 
  supported: enhanced erase
  4min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT. }}
+
  4min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.
 +
}}
  
 
Operations like formatting the device or installing operating systems are not affected by the "security freeze".  
 
Operations like formatting the device or installing operating systems are not affected by the "security freeze".  
Line 132: Line 138:
 
The above output shows the device is '''not locked''' by a HDD-password on boot and the '''frozen''' state safeguards the device against malwares which may try to lock it by setting a password to it at runtime.  
 
The above output shows the device is '''not locked''' by a HDD-password on boot and the '''frozen''' state safeguards the device against malwares which may try to lock it by setting a password to it at runtime.  
  
If you intend to set a password to a "frozen" device yourself, a motherboard BIOS with support for it is required. A lot of notebooks have support, because it is required for [[Wikipedia:Hardware-based_full_disk_encryption|hardware encryption]], but support may not be trivial for a desktop/server board. For the Intel DH67CL/BL motherboard, for example, the motherboard has to be set to "maintenance mode" by a physical jumper to access the settings (see [http://sstahlman.blogspot.in/2014/07/hardware-fde-with-intel-ssd-330-on.html?showComment=1411193181867#c4579383928221016762], [https://communities.intel.com/message/251978#251978]).  
+
If you intend to set a password to a "frozen" device yourself, a motherboard BIOS with support for it is required. A lot of notebooks have support, because it is required for [[Wikipedia:Hardware-based_full_disk_encryption|hardware encryption]], but support may not be trivial for a desktop/server board. For the Intel DH67CL/BL motherboard, for example, the motherboard has to be set to "maintenance mode" by a physical jumper to access the settings (see [https://sstahlman.blogspot.in/2014/07/hardware-fde-with-intel-ssd-330-on.html?showComment=1411193181867#c4579383928221016762], [https://communities.intel.com/message/251978#251978]).  
  
 
{{Warning|Do not try to change the above '''lock''' security settings with {{ic|hdparm}} unless you know exactly what you are doing.}}
 
{{Warning|Do not try to change the above '''lock''' security settings with {{ic|hdparm}} unless you know exactly what you are doing.}}
Line 140: Line 146:
 
==== SSD memory cell clearing ====
 
==== SSD memory cell clearing ====
  
On occasion, users may wish to completely reset an SSD's cells to the same virgin state they were at the time the device was installed thus restoring it to its [http://www.anandtech.com/storage/showdoc.aspx?i=3531&p=8 factory default write performance]. Write performance is known to degrade over time even on SSDs with native TRIM support. TRIM only safeguards against file deletes, not replacements such as an incremental save.
+
On occasion, users may wish to completely reset an SSD's cells to the same virgin state they were at the time the device was installed thus restoring it to its [https://www.anandtech.com/show/2738/8 factory default write performance]. Write performance is known to degrade over time even on SSDs with native TRIM support. TRIM only safeguards against file deletes, not replacements such as an incremental save.
  
 
The reset is easily accomplished in a three step procedure denoted on the [[SSD memory cell clearing]] wiki article. If the reason for the reset is to wipe data, you may not want to rely on the SSD bios to perform it securely. See [[Securely wipe disk#Flash memory]] for further information and examples to perform a wipe.
 
The reset is easily accomplished in a three step procedure denoted on the [[SSD memory cell clearing]] wiki article. If the reason for the reset is to wipe data, you may not want to rely on the SSD bios to perform it securely. See [[Securely wipe disk#Flash memory]] for further information and examples to perform a wipe.
Line 146: Line 152:
 
==== Hardware encryption ====
 
==== Hardware encryption ====
  
As noted in [[#Hdparm shows "frozen" state|#Hdparm shows frozen state]] setting a password for a storage device (SSD/HDD) in the BIOS may also initialize the hardware encryption of devices supporting it. If the device also conforms to the OPAL standard, this may also be achieved without a respective BIOS feature to set the passphrase, see [[Self-Encrypting Drives]].
+
As noted in [[#Hdparm shows "frozen" state]] setting a password for a storage device (SSD/HDD) in the BIOS may also initialize the hardware encryption of devices supporting it. If the device also conforms to the OPAL standard, this may also be achieved without a respective BIOS feature to set the passphrase, see [[Self-Encrypting Drives]].
  
 
== Troubleshooting ==
 
== Troubleshooting ==
  
 
It is possible that the issue you are encountering is a firmware bug which is not Linux specific, so before trying to troubleshoot an issue affecting the SSD device, you should first check if updates are available for:
 
It is possible that the issue you are encountering is a firmware bug which is not Linux specific, so before trying to troubleshoot an issue affecting the SSD device, you should first check if updates are available for:
* The [[Solid State Drives/Firmware|SSD's firmware]]
+
 
 +
* The [[#Firmware|SSD's firmware]]
 
* The [[Flashing_BIOS_from_Linux|motherboard's BIOS/UEFI firmware]]
 
* The [[Flashing_BIOS_from_Linux|motherboard's BIOS/UEFI firmware]]
  
Line 165: Line 172:
 
  [ 9.115557] res 40/00:18:d3:82:85/00:00:1f:00:00/40 Emask 0x4 (timeout)
 
  [ 9.115557] res 40/00:18:d3:82:85/00:00:1f:00:00/40 Emask 0x4 (timeout)
  
To disable NCQ on boot, add {{ic|1=libata.force=noncq}} to the kernel command line in the [[bootloader]] configuration. To disable NCQ only for disk 0 on port 1 use: {{ic|1=libata.force=1.00:noncq}}
+
To disable NCQ on boot, add {{ic|1=libata.force=noncq}} to the kernel command line in the [[bootloader]] configuration. To disable NCQ only for disk 0 on port 9 use: {{ic|1=libata.force=9.00:noncq}}
  
 
Alternatively, you may disable NCQ for a specific drive without rebooting via sysfs:
 
Alternatively, you may disable NCQ for a specific drive without rebooting via sysfs:
  
{{bc|
+
# echo 1 > /sys/block/sdX/device/queue_depth
# echo 1 > /sys/block/sdX/device/queue_depth
 
}}
 
  
 
If this (and also updating the firmware) does not resolves the problem or cause other issues, then [[Reporting bug guidelines|file a bug report]].
 
If this (and also updating the firmware) does not resolves the problem or cause other issues, then [[Reporting bug guidelines|file a bug report]].
Line 177: Line 182:
 
=== Resolving SATA power management related errors ===
 
=== Resolving SATA power management related errors ===
  
Some SSDs (e.g. Transcend MTS400) are failing when SATA Active Link Power Management, [[wikipedia:Aggressive_Link_Power_Management|ALPM]], is enabled.
+
Some SSDs (e.g. Transcend MTS400) are failing when SATA Active Link Power Management, [[wikipedia:Aggressive Link Power Management|ALPM]], is enabled.
 
ALPM is disabled by default and enabled by a power saving daemon (e.g. [[TLP]], [[Laptop Mode Tools]]).
 
ALPM is disabled by default and enabled by a power saving daemon (e.g. [[TLP]], [[Laptop Mode Tools]]).
  
 
If you are starting to encounter SATA related errors when using such a daemon, you should try to disable ALPM by setting its state to {{ic|max_performance}} for both battery and AC powered profiles.
 
If you are starting to encounter SATA related errors when using such a daemon, you should try to disable ALPM by setting its state to {{ic|max_performance}} for both battery and AC powered profiles.
 +
 +
=== External SSD with TRIM support ===
 +
 +
Several USB-SATA Bridge Chips, like VL715, VL716 etc, support TRIM. But {{ic|lsblk --discard}} may return:
 +
 +
NAME          DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
 +
sdX                  0        0B      0B        0
 +
 +
According to https://www.dpreview.com/forums/thread/4302710, in this situation, a [[udev]] rule is needed:
 +
 +
ACTION=="add|change", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="61f5", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
 +
 +
{{Tip|Vendor and product IDs can be easily found from {{ic|lsusb}}.}}
  
 
== Firmware ==
 
== Firmware ==
Line 186: Line 204:
 
=== ADATA ===
 
=== ADATA ===
  
ADATA has a utility available for Linux (i686) on their support page [http://www.adata.com.tw/index.php?action=ss_main&page=ss_content_driver&lan=en here]. The link to latest firmware will appear after selecting the model.  The latest Linux update utility is packed with firmware and needs to be run as root. One may need to set correct permissions for binary file first.
+
ADATA has a utility available for Linux (i686) on their [http://www.adata.com.tw/index.php?action=ss_main&page=ss_content_driver&lan=en support page]. The link to latest firmware will appear after selecting the model.  The latest Linux update utility is packed with firmware and needs to be run as root. One may need to set correct permissions for binary file first.
  
 
=== Crucial ===
 
=== Crucial ===
  
Crucial provides an option for updating the firmware with an ISO image. These images can be found after selecting the product [http://www.crucial.com/usa/en/support-ssd here] and downloading the "Manual Boot File."   
+
Crucial provides an option for updating the firmware with an ISO image. These images can be found after selecting the product on their [http://www.crucial.com/usa/en/support-ssd SSD support page] and downloading the "Manual Boot File."   
  
{{Note|ISO images provided by Crucial does not seem to be hybrid. If you will use just the {{ic|dd}} command to copy the image to some device, the [[MBR]] won't be present, making such device unbootable.}}
+
{{Note|ISO images provided by Crucial do not seem to be hybrid. If you will use just the {{ic|dd}} command to copy the image to some device, the [[MBR]] will not be present, making such device unbootable.}}
  
 
Owners of an M4 Crucial model, may check if a firmware upgrade is needed with {{ic|smartctl}}.
 
Owners of an M4 Crucial model, may check if a firmware upgrade is needed with {{ic|smartctl}}.
Line 212: Line 230:
 
=== Kingston ===
 
=== Kingston ===
  
Kingston has a Linux utility to update the firmware of Sandforce controller based drives:  [http://www.kingston.com/en/support/technical/category/ssd SSD support page].  Click the images on the page to go to a support page for your SSD model.  Support specifically for, e.g. the SH100S3 SSD, can be found here:  [http://www.hyperxgaming.com/us/support/technical/products?model=sh100s3 support page].
+
KFU tool is available on the AUR for the Sandforce based drives, {{AUR|kingston_fw_updater}}.
  
 
=== Mushkin ===
 
=== Mushkin ===
  
The lesser known Mushkin brand Solid State drives also use Sandforce controllers, and have a Linux utility (nearly identical to Kingston's) to update the firmware.
+
The lesser known Mushkin brand solid state drives also use Sandforce controllers, and have a Linux utility (nearly identical to Kingston's) to update the firmware.
  
 
=== OCZ ===
 
=== OCZ ===
  
OCZ has a command line utility available for Linux (i686 and x86_64) on their forum [http://www.ocztechnology.com/ssd_tools/ here]. The AUR provides {{AUR|ocz-ssd-utility}}, {{AUR|ocztoolbox}} and {{AUR|oczclout}}.
+
OCZ has a [https://www.ocz.com/us/download/clout Command Line Online Update Tool (CLOUT)] available for Linux. The AUR provides {{AUR|ocz-ssd-utility}}, {{AUR|ocztoolbox}} and {{AUR|oczclout}}.
  
 
=== Samsung ===
 
=== Samsung ===
  
Samsung notes that update methods other than using their Magician Software are "not supported," but it is possible. The Magician Software can be used to make a USB drive bootable with the firmware update. Samsung provides pre-made [http://www.samsung.com/global/business/semiconductor/samsungssd/downloads.html bootable ISO images] that can be used to update the firmware. Another option is to use Samsung's {{AUR|samsung_magician}}, which is available in the AUR. Magician only supports Samsung-branded SSDs; those manufactured by Samsung for OEMs (e.g., Lenovo) are not supported.
+
Samsung notes that update methods other than using their Magician Software are "not supported", but it is possible. The Magician Software can be used to make a USB drive bootable with the firmware update. Samsung provides pre-made [https://www.samsung.com/semiconductor/minisite/ssd/download/tools.html bootable ISO images] that can be used to update the firmware. Another option is to use Samsung's {{AUR|samsung_magician-consumer-ssd}}, which is available in the AUR. Magician only supports Samsung-branded SSDs; those manufactured by Samsung for OEMs (e.g., Lenovo) are not supported.
  
 
{{Note|Samsung does not make it obvious at all that they actually provide these. They seem to have 4 different firmware update pages, and each references different ways of doing things.}}
 
{{Note|Samsung does not make it obvious at all that they actually provide these. They seem to have 4 different firmware update pages, and each references different ways of doing things.}}
  
Users preferring to run the firmware update from a live USB created under Linux (without using Samsung's "Magician" software under Microsoft Windows) can refer to [http://fomori.org/blog/?p=933 this post] for reference.
+
Users preferring to run the firmware update from a live USB created under Linux (without using Samsung's "Magician" software under Microsoft Windows) can refer to [https://web.archive.org/web/20160322230114/fomori.org/blog/?p=933 this post] for reference.
  
==== Native upgrade ====
+
==== Upgrade under Linux ====
  
 
{{Style|Assumes use of [[udisks]]; loop mounts can be done directly via [[mount]]}}
 
{{Style|Assumes use of [[udisks]]; loop mounts can be done directly via [[mount]]}}
  
Alternatively, the firmware can be upgraded natively, without making a bootable USB stick, as shown below.
+
Alternatively, the firmware can be upgraded natively, without making a bootable USB stick, as shown below. First visit the [https://www.samsung.com/semiconductor/minisite/ssd/download/tools.html Samsung downloads page] and download the latest firmware for Windows, which is available as a disk image. In the following, {{ic|Samsung_SSD_840_EVO_EXT0DB6Q.iso}} is used as an example file name, adjust it accordingly.
  
First visit the [http://www.samsung.com/global/business/semiconductor/minisite/SSD/global/html/support/downloads.html Samsung downloads page] and download the latest firmware for Windows, which is available as a disk image. In the following, {{ic|Samsung_SSD_840_EVO_EXT0DB6Q.iso}} is used as an example file name, adjust it accordingly.
+
Setup the disk image:
  
Setup the disk image:
 
 
  $ udisksctl loop-setup -r -f Samsung_SSD_840_EVO_EXT0DB6Q.iso
 
  $ udisksctl loop-setup -r -f Samsung_SSD_840_EVO_EXT0DB6Q.iso
  
 
This will make the ISO available as a loop device, and display the device path. Assuming it was {{ic|/dev/loop0}}:
 
This will make the ISO available as a loop device, and display the device path. Assuming it was {{ic|/dev/loop0}}:
 +
 
  $ udisksctl mount -b /dev/loop0
 
  $ udisksctl mount -b /dev/loop0
  
 
Get the contents of the disk:
 
Get the contents of the disk:
 +
 
  $ mkdir Samsung_SSD_840_EVO_EXT0DB6Q
 
  $ mkdir Samsung_SSD_840_EVO_EXT0DB6Q
 
  $ cp -r /run/media/$USER/CDROM/isolinux/ Samsung_SSD_840_EVO_EXT0DB6Q
 
  $ cp -r /run/media/$USER/CDROM/isolinux/ Samsung_SSD_840_EVO_EXT0DB6Q
  
 
Unmount the iso:
 
Unmount the iso:
 +
 
  $ udisksctl unmount -b /dev/loop0
 
  $ udisksctl unmount -b /dev/loop0
 
  $ cd Samsung_SSD_840_EVO_EXT0DB6Q/isolinux
 
  $ cd Samsung_SSD_840_EVO_EXT0DB6Q/isolinux
  
 
There is a FreeDOS image here that contains the firmware. Mount the image as before:
 
There is a FreeDOS image here that contains the firmware. Mount the image as before:
 +
 
  $ udisksctl loop-setup -r -f btdsk.img
 
  $ udisksctl loop-setup -r -f btdsk.img
 
  $ udisksctl mount -b /dev/loop1
 
  $ udisksctl mount -b /dev/loop1
Line 259: Line 280:
  
 
Get the disk number from magician:
 
Get the disk number from magician:
 +
 
  # magician -L
 
  # magician -L
  
 
Assuming it was 0:
 
Assuming it was 0:
 +
 
  # magician --disk 0 -F -p DSRD
 
  # magician --disk 0 -F -p DSRD
  
 
Verify that the latest firmware has been installed:
 
Verify that the latest firmware has been installed:
 +
 
  # magician -L
 
  # magician -L
  
Line 271: Line 295:
 
=== SanDisk ===
 
=== SanDisk ===
  
SanDisk makes '''ISO firmware images''' to allow SSD firmware update on operating systems that are unsupported by their SanDisk SSD Toolkit. One must choose the firmware for the right ''SSD model'', as well as for the ''capacity'' that it has (e.g. 60GB, '''or''' 256GB). After burning the adequate ISO firmware image, simply restart the PC to boot with the newly created CD/DVD boot disk (may work from a USB stick).
+
SanDisk makes ISO firmware images to allow SSD firmware update on operating systems that are unsupported by their SanDisk SSD Toolkit.
 +
 
 +
One must choose the firmware for the correct ''SSD model'', '''and''' the correct ''capacity'' that it has (e.g. 60GB, '''or''' 256GB). After burning the ISO firmware image, simply restart the PC to boot with the newly created CD/DVD boot disk (may work from a USB stick).
  
 
The iso images just contain a linux kernel and an initrd. Extract them to {{ic|/boot}} partition and boot them with [[GRUB]] or [[Syslinux]] to update the firmware.
 
The iso images just contain a linux kernel and an initrd. Extract them to {{ic|/boot}} partition and boot them with [[GRUB]] or [[Syslinux]] to update the firmware.
Line 277: Line 303:
 
See also:
 
See also:
  
SanDisk Extreme SSD [http://kb.sandisk.com/app/answers/detail/a_id/10127 Firmware Release notes] and [http://kb.sandisk.com/app/answers/detail/a_id/10476 Manual Firmware update version R211]  
+
SanDisk Extreme SSD [https://kb.sandisk.com/app/answers/detail/a_id/10127 Firmware Release notes] and [https://kb.sandisk.com/app/answers/detail/a_id/10476 Manual Firmware update version R211]
 +
 
 +
SanDisk Ultra SSD [https://kb.sandisk.com/app/answers/detail/a_id/10192 Firmware release notes] and [https://kb.sandisk.com/app/answers/detail/a_id/10477 Manual Firmware update version 365A13F0]
  
SanDisk Ultra SSD [http://kb.sandisk.com/app/answers/detail/a_id/10192 Firmware release notes] and [http://kb.sandisk.com/app/answers/detail/a_id/10477 Manual Firmware update version 365A13F0]
+
SanDisk Ultra+ SSD [https://kb.sandisk.com/app/answers/detail/a_id/12763 Firmware release notes] and [https://kb.sandisk.com/app/answers/detail/a_id/12762 Manual Firmware update version X2316RL] - use {{ic|smartctl -a /dev/sdX}} to determine if a "H2" or "HP" model is used.
  
 
== See also ==
 
== See also ==
  
* [http://www.reddit.com/r/archlinux/comments/rkwjm/what_should_i_keep_in_mind_when_installing_on_ssd/ Discussion on Reddit about installing Arch on an SSD]
+
* [https://www.reddit.com/r/archlinux/comments/rkwjm/what_should_i_keep_in_mind_when_installing_on_ssd/ Discussion on Reddit about installing Arch on an SSD]
* See the [[Flashcache]] article for advanced information on using solid-state with rotational drives for top performance.
 
 
* [http://permalink.gmane.org/gmane.comp.file-systems.btrfs/19446 Re: Varying Leafsize and Nodesize in Btrfs]
 
* [http://permalink.gmane.org/gmane.comp.file-systems.btrfs/19446 Re: Varying Leafsize and Nodesize in Btrfs]
 
* [http://thread.gmane.org/gmane.comp.file-systems.btrfs/19650/focus=19667 Re: SSD alignment and Btrfs sector size]
 
* [http://thread.gmane.org/gmane.comp.file-systems.btrfs/19650/focus=19667 Re: SSD alignment and Btrfs sector size]
* [http://forums.anandtech.com/showthread.php?t=2266113 Erase Block (Alignment) Misinformation?]
+
* [https://forums.anandtech.com/threads/erase-block-alignment-misinformation.2266113/ Erase Block (Alignment) Misinformation?]
* [http://superuser.com/questions/492084/is-alignment-to-erase-block-size-needed-for-modern-ssds Is alignment to erase block size needed for modern SSD's?]
+
* [https://superuser.com/questions/492084/is-alignment-to-erase-block-size-needed-for-modern-ssds Is alignment to erase block size needed for modern SSD's?]
 
* [http://thread.gmane.org/gmane.comp.file-systems.btrfs/15646 Btrfs support for efficient SSD operation (data blocks alignment)]
 
* [http://thread.gmane.org/gmane.comp.file-systems.btrfs/15646 Btrfs support for efficient SSD operation (data blocks alignment)]
* [http://serverfault.com/questions/356534/ssd-erase-block-size-lvm-pv-on-raw-device-alignment SSD, Erase Block Size & LVM: PV on raw device, Alignment]
+
* [https://serverfault.com/questions/356534/ssd-erase-block-size-lvm-pv-on-raw-device-alignment SSD, Erase Block Size & LVM: PV on raw device, Alignment]

Latest revision as of 08:06, 30 July 2019

This article covers special topics for operating solid state drives (SSDs) and other flash-memory based storage devices. If you want to partition an SSD for a specific purpose, it may be useful to consider the List of file systems optimized for flash memory. For general usage, you should simply choose your preferred filesystem.

Usage

TRIM

Most SSDs support the ATA_TRIM command for sustained long-term performance and wear-leveling. A techspot article shows performance benchmark examples of before and after filling an SSD with data.

As of Linux kernel version 3.8 onwards, support for TRIM was continually added for the different filesystems. See the following table for an indicative overview:

File system Continuous TRIM
(discard option)
Periodic TRIM
(fstrim)
References
and notes
Ext3 No ?
Ext4 Yes Yes [1]
Btrfs Yes Yes
JFS Yes Yes [2]
XFS Yes Yes [3]
F2FS Yes Yes
VFAT Yes Yes fstrim is supported since kernel 4.19
NTFS-3G No Yes since version 2015.3.14, [4]
Warning: Users need to be certain that their SSD supports TRIM before attempting to use it. Data loss can occur otherwise!

To verify TRIM support, run:

$ lsblk --discard

And check the values of DISC-GRAN (discard granularity) and DISC-MAX (discard max bytes) columns. Non-zero values indicate TRIM support.

Alternatively, install hdparm package and run:

# hdparm -I /dev/sda | grep TRIM
        *    Data Set Management TRIM supported (limit 1 block)
Note: There are different types of TRIM support defined by the specification. Hence, the output may differ depending what the drive supports. See Wikipedia:TRIM#ATA for more information.

Periodic TRIM

The util-linux package provides fstrim.service and fstrim.timer systemd unit files. Enabling the timer will activate the service weekly. The service executes fstrim(8) on all mounted filesystems on devices that support the discard operation.

The timer relies on the timestamp of /var/lib/systemd/timers/stamp-fstrim.timer (which it will create upon first invocation) to know whether a week has elapsed since it last ran. Therefore there is no need to worry about too frequent invocations, in an anacron-like fashion.

To query the units activity and status, see journalctl. To change the periodicity of the timer or the command run, edit the provided unit files.

Continuous TRIM

Note: There is no need to enable continuous TRIM if you run fstrim periodically. If you want to use TRIM, use either periodic TRIM or continuous TRIM.

Instead of issuing TRIM commands once in a while (by default once a week if using fstrim.timer), it is also possible to issue TRIM commands each time files are deleted instead. The latter is known as the continuous TRIM.

Warning: Before SATA 3.1 all TRIM commands were non-queued, so continuous trimming would produce frequent system freezes. In this case, applying #Periodic TRIM less often is better alternative. Similar issue holds also for a number of devices, for which queued TRIM command execution was blacklisted due to serious data corruption. In such case, depending on the device, the system may be forced to send non-queued TRIM commands the SSD instead of queued TRIM. See Wikipedia:Trim_(computing)#Disadvantages for details.
Note: Continuous TRIM is not the most preferred way to issue TRIM commands among the Linux community. For example, Ubuntu enables periodic TRIM by default [5], Debian does not recommend using continuous TRIM [6] and Red Hat recommends using periodic TRIM over using continuous TRIM if feasible. [7]

Using the discard option for a mount in /etc/fstab enables continuous TRIM in device operations:

/dev/sda1  /           ext4  defaults,discard   0  1
Note: Specifying the discard mount option in /etc/fstab does not work with an XFS / partition. According to this thread, it has to be set using the rootflags=discard kernel parameter.

On the ext4 filesystem, the discard flag can also be set as a default mount option using tune2fs:

# tune2fs -o discard /dev/sdXY

Using the default mount options instead of an entry in /etc/fstab is particularly useful for external drives, because such partition will be mounted with the default options also on other machines. This way, there is no need to edit /etc/fstab on every machine.

Note: The default mount options are not listed in /proc/mounts.

Trim an entire device

If you want to trim your entire SSD at once, e.g. for a new install, or you want to sell your SSD, you can use the blkdiscard command, which will instantly discard all blocks on a device.

Warning: all data on the device will be lost!
# blkdiscard /dev/sdX

LVM

Change the value of issue_discards option from 0 to 1 in /etc/lvm/lvm.conf.

Note: Enabling this option will "issue discards to a logical volumes's underlying physical volume(s) when the logical volume is no longer using the physical volumes' space (e.g. lvremove, lvreduce, etc)" (see lvm.conf(5) and/or inline comments in /etc/lvm/lvm.conf). As such it does not seem to be required for "regular" TRIM requests (file deletions inside a filesystem) to be functional.

dm-crypt

Warning: The discard option allows discard requests to be passed through the encrypted block device. This improves performance on SSD storage but has security implications. See dm-crypt/Specialties#Discard/TRIM support for solid state drives (SSD) for more information.

For non-root filesystems, configure /etc/crypttab to include discard in the list of options for encrypted block devices located on an SSD (see dm-crypt/System configuration#crypttab).

For the root filesystem, follow the instructions from dm-crypt/Specialties#Discard/TRIM support for solid state drives (SSD) to add the right kernel parameter to the bootloader configuration.

Maximizing performance

Follow the tips in Improving performance#Storage devices to maximize the performance of your drives.

Security

Hdparm shows "frozen" state

Some motherboard BIOS' issue a "security freeze" command to attached storage devices on initialization. Likewise some SSD (and HDD) BIOS' are set to "security freeze" in the factory already. Both result in the device's password security settings to be set to frozen, as shown in below output:

# hdparm -I /dev/sda
Security: 
 	Master password revision code = 65534
 		supported
 	not	enabled
 	not	locked
 		frozen
 	not	expired: security count
 		supported: enhanced erase
 	4min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.

Operations like formatting the device or installing operating systems are not affected by the "security freeze".

The above output shows the device is not locked by a HDD-password on boot and the frozen state safeguards the device against malwares which may try to lock it by setting a password to it at runtime.

If you intend to set a password to a "frozen" device yourself, a motherboard BIOS with support for it is required. A lot of notebooks have support, because it is required for hardware encryption, but support may not be trivial for a desktop/server board. For the Intel DH67CL/BL motherboard, for example, the motherboard has to be set to "maintenance mode" by a physical jumper to access the settings (see [8], [9]).

Warning: Do not try to change the above lock security settings with hdparm unless you know exactly what you are doing.

If you intend to erase the SSD, see Securely wipe disk#hdparm and #SSD memory cell clearing below.

SSD memory cell clearing

On occasion, users may wish to completely reset an SSD's cells to the same virgin state they were at the time the device was installed thus restoring it to its factory default write performance. Write performance is known to degrade over time even on SSDs with native TRIM support. TRIM only safeguards against file deletes, not replacements such as an incremental save.

The reset is easily accomplished in a three step procedure denoted on the SSD memory cell clearing wiki article. If the reason for the reset is to wipe data, you may not want to rely on the SSD bios to perform it securely. See Securely wipe disk#Flash memory for further information and examples to perform a wipe.

Hardware encryption

As noted in #Hdparm shows "frozen" state setting a password for a storage device (SSD/HDD) in the BIOS may also initialize the hardware encryption of devices supporting it. If the device also conforms to the OPAL standard, this may also be achieved without a respective BIOS feature to set the passphrase, see Self-Encrypting Drives.

Troubleshooting

It is possible that the issue you are encountering is a firmware bug which is not Linux specific, so before trying to troubleshoot an issue affecting the SSD device, you should first check if updates are available for:

Even if it is a firmware bug it might be possible to avoid it, so if there are no updates to the firmware or you hesitant on updating firmware then the following might help.

Resolving NCQ errors

Some SSDs and SATA chipsets do not work properly with Linux Native Command Queueing (NCQ). The tell-tale dmesg errors look like this:

[ 9.115544] ata9: exception Emask 0x0 SAct 0xf SErr 0x0 action 0x10 frozen
[ 9.115550] ata9.00: failed command: READ FPDMA QUEUED
[ 9.115556] ata9.00: cmd 60/04:00:d4:82:85/00:00:1f:00:00/40 tag 0 ncq 2048 in
[ 9.115557] res 40/00:18:d3:82:85/00:00:1f:00:00/40 Emask 0x4 (timeout)

To disable NCQ on boot, add libata.force=noncq to the kernel command line in the bootloader configuration. To disable NCQ only for disk 0 on port 9 use: libata.force=9.00:noncq

Alternatively, you may disable NCQ for a specific drive without rebooting via sysfs:

# echo 1 > /sys/block/sdX/device/queue_depth

If this (and also updating the firmware) does not resolves the problem or cause other issues, then file a bug report.

Resolving SATA power management related errors

Some SSDs (e.g. Transcend MTS400) are failing when SATA Active Link Power Management, ALPM, is enabled. ALPM is disabled by default and enabled by a power saving daemon (e.g. TLP, Laptop Mode Tools).

If you are starting to encounter SATA related errors when using such a daemon, you should try to disable ALPM by setting its state to max_performance for both battery and AC powered profiles.

External SSD with TRIM support

Several USB-SATA Bridge Chips, like VL715, VL716 etc, support TRIM. But lsblk --discard may return:

NAME          DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sdX                  0        0B       0B         0

According to https://www.dpreview.com/forums/thread/4302710, in this situation, a udev rule is needed:

ACTION=="add|change", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="61f5", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
Tip: Vendor and product IDs can be easily found from lsusb.

Firmware

ADATA

ADATA has a utility available for Linux (i686) on their support page. The link to latest firmware will appear after selecting the model. The latest Linux update utility is packed with firmware and needs to be run as root. One may need to set correct permissions for binary file first.

Crucial

Crucial provides an option for updating the firmware with an ISO image. These images can be found after selecting the product on their SSD support page and downloading the "Manual Boot File."

Note: ISO images provided by Crucial do not seem to be hybrid. If you will use just the dd command to copy the image to some device, the MBR will not be present, making such device unbootable.

Owners of an M4 Crucial model, may check if a firmware upgrade is needed with smartctl.

$ smartctl --all /dev/sdX
==> WARNING: This drive may hang after 5184 hours of power-on time:
http://www.tomshardware.com/news/Crucial-m4-Firmware-BSOD,14544.html
See the following web pages for firmware updates:
http://www.crucial.com/support/firmware.aspx
http://www.micron.com/products/solid-state-storage/client-ssd#software

Users seeing this warning are advised to backup all sensible data and consider upgrading immediately. Check this instructions to update Crucial MX100 firmware by using the ISO image and Grub.

Intel

Intel has a Linux live system based Firmware Update Tool for operating systems that are not compatible with its Intel® Solid-State Drive Toolbox software.

Kingston

KFU tool is available on the AUR for the Sandforce based drives, kingston_fw_updaterAUR.

Mushkin

The lesser known Mushkin brand solid state drives also use Sandforce controllers, and have a Linux utility (nearly identical to Kingston's) to update the firmware.

OCZ

OCZ has a Command Line Online Update Tool (CLOUT) available for Linux. The AUR provides ocz-ssd-utilityAUR, ocztoolboxAUR and oczcloutAUR.

Samsung

Samsung notes that update methods other than using their Magician Software are "not supported", but it is possible. The Magician Software can be used to make a USB drive bootable with the firmware update. Samsung provides pre-made bootable ISO images that can be used to update the firmware. Another option is to use Samsung's samsung_magician-consumer-ssdAUR, which is available in the AUR. Magician only supports Samsung-branded SSDs; those manufactured by Samsung for OEMs (e.g., Lenovo) are not supported.

Note: Samsung does not make it obvious at all that they actually provide these. They seem to have 4 different firmware update pages, and each references different ways of doing things.

Users preferring to run the firmware update from a live USB created under Linux (without using Samsung's "Magician" software under Microsoft Windows) can refer to this post for reference.

Upgrade under Linux

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Assumes use of udisks; loop mounts can be done directly via mount (Discuss in Talk:Solid state drive#)

Alternatively, the firmware can be upgraded natively, without making a bootable USB stick, as shown below. First visit the Samsung downloads page and download the latest firmware for Windows, which is available as a disk image. In the following, Samsung_SSD_840_EVO_EXT0DB6Q.iso is used as an example file name, adjust it accordingly.

Setup the disk image:

$ udisksctl loop-setup -r -f Samsung_SSD_840_EVO_EXT0DB6Q.iso

This will make the ISO available as a loop device, and display the device path. Assuming it was /dev/loop0:

$ udisksctl mount -b /dev/loop0

Get the contents of the disk:

$ mkdir Samsung_SSD_840_EVO_EXT0DB6Q
$ cp -r /run/media/$USER/CDROM/isolinux/ Samsung_SSD_840_EVO_EXT0DB6Q

Unmount the iso:

$ udisksctl unmount -b /dev/loop0
$ cd Samsung_SSD_840_EVO_EXT0DB6Q/isolinux

There is a FreeDOS image here that contains the firmware. Mount the image as before:

$ udisksctl loop-setup -r -f btdsk.img
$ udisksctl mount -b /dev/loop1
$ cp -r /run/media/$USER/C04D-1342/ Samsung_SSD_840_EVO_EXT0DB6Q
$ cd Samsung_SSD_840_EVO_EXT0DB6Q/C04D-1342/samsung

Get the disk number from magician:

# magician -L

Assuming it was 0:

# magician --disk 0 -F -p DSRD

Verify that the latest firmware has been installed:

# magician -L

Finally reboot.

SanDisk

SanDisk makes ISO firmware images to allow SSD firmware update on operating systems that are unsupported by their SanDisk SSD Toolkit.

One must choose the firmware for the correct SSD model, and the correct capacity that it has (e.g. 60GB, or 256GB). After burning the ISO firmware image, simply restart the PC to boot with the newly created CD/DVD boot disk (may work from a USB stick).

The iso images just contain a linux kernel and an initrd. Extract them to /boot partition and boot them with GRUB or Syslinux to update the firmware.

See also:

SanDisk Extreme SSD Firmware Release notes and Manual Firmware update version R211

SanDisk Ultra SSD Firmware release notes and Manual Firmware update version 365A13F0

SanDisk Ultra+ SSD Firmware release notes and Manual Firmware update version X2316RL - use smartctl -a /dev/sdX to determine if a "H2" or "HP" model is used.

See also