Solid State Drives
This article covers special topics for operating w:Solid State Drives (SSDs) and other flash-memory based storage devices. If you want to partition a 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.
- 1 Usage
- 2 Troubleshooting
- 3 Firmware
- 4 See also
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 and the respective filesystems' articles for further details:
|File system|| Continuous TRIM
| Periodic TRIM
|No||Yes||since version 2015.3.14, |
To verify TRIM support, run:
# lsblk -D
And check the values of DISC-GRAN and DISC-MAX columns. Non-zero values indicate TRIM support.
Or install package and run:
# hdparm -I /dev/sda | grep TRIM * Data Set Management TRIM supported (limit 1 block)
fstrim.timer systemd unit files. Enabling the timer will activate the service weekly. The service executes 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.
discard option for a mount in
/etc/fstab enables continuous TRIM in device operations:
/dev/sda2 /boot ext4 defaults,discard 0 2 /dev/sda1 /boot/efi vfat defaults,discard 0 2 /dev/sda3 / ext4 defaults,discard 0 2
The main benefit of continuous TRIM is speed; an SSD can perform more efficient 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 this article and the related blueprint).
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 useful for external drives, because such partition will be mounted with the default options also on other machines. There is no need to edit
/etc/fstab on every machine.
Change the value of
issue_discards option from 0 to 1 in
For non-root filesystems, configure
/etc/crypttab to include
discard in the list of options for encrypted block devices located on a SSD (see Dm-crypt/System configuration#crypttab).
For the root filesystem, follow the instructions from Dm-crypt/TRIM support for SSD to add the right kernel parameter to the bootloader configuration.
Follow the tips in Improving performance#Storage devices to maximize the performance of your drives.
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 , ).
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.
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.
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 1 use:
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.
If you starting to encounter SATA related errors when using such daemon then you should try to disable ALPM by setting its state to
max_performance for both battery and AC powered profiles.
ADATA has a utility available for Linux (i686) on their support page 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.
Crucial provides an option for updating the firmware with an ISO image. These images can be found after selecting the product here and downloading the "Manual Boot File."
Owners of an M4 Crucial model, may check if a firmware upgrade is needed with
$ 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.
Kingston has a Linux utility to update the firmware of Sandforce controller based drives: 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: support page.
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 has a command line utility available for Linux (i686 and x86_64) on their forum here. The AUR provides AUR, AUR and AUR.
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 AUR, which is available in the AUR. Magician only supports Samsung-branded SSDs; those manufactured by Samsung for OEMs (e.g., Lenovo) are not supported.
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.
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
$ 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
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).
- 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.
- Re: Varying Leafsize and Nodesize in Btrfs
- Re: SSD alignment and Btrfs sector size
- Erase Block (Alignment) Misinformation?
- Is alignment to erase block size needed for modern SSD's?
- Btrfs support for efficient SSD operation (data blocks alignment)
- SSD, Erase Block Size & LVM: PV on raw device, Alignment