最後更新: 2019-02-21


找出系上的 SSD


# To check if the kernel knows about SSDs try:

grep . /sys/block/sd?/queue/rotational



為 SSD 設定 Disk 的 scheduler


# 查看 scheduler 設定

grep . /sys/block/sd?/queue/scheduler

/sys/block/sda/queue/scheduler:noop [deadline] cfq
/sys/block/sdb/queue/scheduler:noop [deadline] cfq
/sys/block/sdc/queue/scheduler:noop deadline [cfq]

# set deadline scheduler for non-rotating disks

# /etc/udev/rules.d/10-ssd.rules

# echo "block/sdX/queue/scheduler = deadline" >> /etc/sysfs.conf

ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"


定期 trim (fstrim)


日子久了 => degradation of write operations on SSDs

原因: 刪除了的資料沒有真正進行資料清空(erase)

OS >= Windows 7

The util-linux package provides fstrim

fstrim - discard unused blocks on a mounted filesystem


# By default, fstrim will discard all unused blocks in the filesystem.

fstrim [-o offset] [-l length] [-m minimum-free-extent] [-v] mountpoint


-m, --minimum minimum-free-extent              # Minimum contiguous free range to discard (Default value is zero => ALL )
                                                                    # (Free ranges smaller than this will be ignored.)

-v, --verbose


(2^N) suffixes KiB, MiB, GiB


fstrim -v /ssd/xpenology

/ssd/xpenology: 6.4 GiB (6856876032 bytes) trimmed




The TRIM command should be translated from one layer to another until reaching the SSD.


ext4 -> lvm -> ssd

=> 每一層都要 support TRIM


fs btrfs, ext4 trim (Continuous TRIM)



# ext4
# commit=nrsec ( Default value is 5 seconds)
# This means that if you lose your power, you will lose  as much as the latest 5 seconds of work

/dev/mapper/goofy-root /               ext4     discard,noatime,commit=600,errors=remount-ro 0       1

Using the discard mount option for continuous TRIM in device operations

# btrfs

/dev/mapper/goofy-chroot /srv/chroot   btrfs    ssd,discard,noatime 0       2

 * There is no need for the discard flag if you run fstrim periodically.




2015 HW:

Samsung SSD 850 EVO 250GB

Cache Memory

Samsung SSD 850 EVO 250GB: Samsung 512 MB Low Power DDR3 SDRAM

Total/Terrabytes Bytes Written (TBW)

Samsung SSD 850 EVO 250GB: 75 TBW


V = SMART attribute #241 (Total_LBAs_Written)

V X 512 / 1024^4 = N gb

Wear_Leveling_Count (ID 177)

Samsung V-NAND 3bit MLC

This attribute represents the number of media program and erase operations
(the number of times a block has been erased).
This value is directly related to the lifetime of the SSD.
The raw value of this attribute shows the total count of P/E Cycles.

SLC: 100,000
MLC: 3,000

 * The ssd will die from other reasons before wearing out.


A count of the number of sudden power off cases.

the firmware must recover all of the mapping and user data during the next power on


Window 's tuning


關閉 Superfetch 服務

關閉 Windows Search 服務

Click on your SSD and right click on it.

Click properties then uncheck “Allow files on this drive to have contents indexed in addition to file properties“.

 * 關閉休眠(hibernate)功能

powercfg -h off

 * Disable 碎片整理 (會認到係 SSD)[每更]

 * Turn Off the Page File

Verify TRIM is Functioning:

fsutil behavior query DisableDeleteNotify

If it’s set to “1”, TRIM is disabled and you need to enable it. This is rare, however.




If you are planning on doing a huge amount of writes (more than 40-50 GB per day), it is advised to avoid SSDs that use TLC NAND.