Article 6QJ8H An SSD TBW Conundrum

An SSD TBW Conundrum

by
w1k0
from LinuxQuestions.org on (#6QJ8H)
I have three SSDs. The key parameter that determines their lifespan is TBW (terabytes written). Unfortunately, each of my drives uses a different standard to represent the units of data written.

1.

The newest drive SSDPR-PX500-01T-80-G2 (goodram, 1 TB, 2023, 3 years, 660 TBW) displays the following information:

# smartctl -s on -a /dev/nvme0 | grep -i written
Code: Data Units Written: 4,655,375 [2.38 TB]In its case, everything is clear. After removing the colons, I can calculate the value in terabytes:

# echo "scale=6; 512 * 4655375 / 1000 / 1000 / 1000" | bc
Code:2.383552My result matches the value displayed by smartctl.

2.

The older drive SSDPR-CL100-240-G3 (goodram, 240 GB, 2021, 3 years, 170 TBW) displays the following information:

# smartctl -s on -a /dev/sda | grep -i written
Code: 241 Total_LBAs_Written 0x0033 100 100 010 Pre-fail Always - 1701To determine the value of terabytes written, I prepared a script called 1GB:

Code: #!/bin/bash
DEVICE="$1"
smartctl -s on -i $DEVICE | egrep "Model Number:|Device Model:"
smartctl -s on -a $DEVICE | grep -i "written"
dd if=/dev/zero of=one-gigabyte count=1 bs=1GB
smartctl -s on -a $DEVICE | grep -i "written"# 1GB /dev/sda
Code: Device Model: SSDPR-CL100-240-G3
241 Total_LBAs_Written 0x0033 100 100 010 Pre-fail Always - 1701
1+0 records in
1+0 records out
1000000000 bytes (1.0 GB, 954 MiB) copied, 0.917499 s, 1.1 GB/s
241 Total_LBAs_Written 0x0033 100 100 010 Pre-fail Always - 1702# ls -l one-gigabyte
Code: -rw-r--r-- 1 root root 1000000000 Sep 7 02:41 one-gigabyteAs you can see, writing 1 GB increased the total LBAs written value by one. So in this case smartctl reports the value in gigabytes.

As a result, it is easy to convert this value to terabytes:

# echo "scale=6; 1702 / 1000" | bc
Code:1.702000
3.

The conundrum appears in the case of my oldest drive Samsung SSD 860 EVO 250 GB (Samsung, 250 GB, 2018, 5 years, 150 TBW), which displays the following information:

# smartctl -s on -a /dev/sda
Code: smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.161] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family: Samsung based SSDs
Device Model: Samsung SSD 860 EVO 250GB
Serial Number: S3YJNF0K261478T
LU WWN Device Id: 5 002538 e401d3027
Firmware Version: RVT01B6Q
User Capacity: 250,059,350,016 bytes [250 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
TRIM Command: Available, deterministic, zeroed
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-4 T13/BSR INCITS 529 revision 5
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 1.5 Gb/s)
Local Time is: Sat Sep 7 03:54:30 2024 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.

=== START OF READ SMART DATA SECTION ===
SMART Status not supported: Incomplete response, ATA output registers missing
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.

General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x53) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
No Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 85) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
9 Power_On_Hours 0x0032 096 096 000 Old_age Always - 19927
12 Power_Cycle_Count 0x0032 097 097 000 Old_age Always - 3019
177 Wear_Leveling_Count 0x0013 095 095 000 Pre-fail Always - 90
179 Used_Rsvd_Blk_Cnt_Tot 0x0013 100 100 010 Pre-fail Always - 0
181 Program_Fail_Cnt_Total 0x0032 100 100 010 Old_age Always - 0
182 Erase_Fail_Count_Total 0x0032 100 100 010 Old_age Always - 0
183 Runtime_Bad_Block 0x0013 100 100 010 Pre-fail Always - 0
187 Uncorrectable_Error_Cnt 0x0032 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0032 064 034 000 Old_age Always - 36
195 ECC_Error_Rate 0x001a 200 200 000 Old_age Always - 0
199 CRC_Error_Count 0x003e 099 099 000 Old_age Always - 11
235 POR_Recovery_Count 0x0012 099 099 000 Old_age Always - 171
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 16649770782

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.Total LBAs written value above is 16649770782.

As before I tried the 1GB script:

# 1GB /dev/sda
Code: Device Model: Samsung SSD 860 EVO 250GB
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 16649771950
1+0 records in
1+0 records out
1000000000 bytes (1.0 GB, 954 MiB) copied, 1.88237 s, 531 MB/s
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 16649869470# ls -l one-gigabyte
Code: -rw-r--r-- 1 root root 1000000000 Sep 7 03:55 one-gigabyteThe difference after writing 1 GB of data in this case is equal to:

# expr 16649869470 - 16649771950
Code:97520I could not convert this value to terabytes.

So I prepared a script called 8GB:

Code: #!/bin/bash
DEVICE="$1"
sudo /usr/sbin/smartctl -s on -i $DEVICE | egrep "Model Number:|Device Model:"
sudo /usr/sbin/smartctl -s on -a $DEVICE | grep -i "written"
dd if=/dev/zero of=eight-gigabytes count=8 bs=1GB
sudo /usr/sbin/smartctl -s on -a $DEVICE | grep -i "written"# 8GB /dev/sda
Code: Device Model: Samsung SSD 860 EVO 250GB
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 16669454870
8+0 records in
8+0 records out
8000000000 bytes (8.0 GB, 7.5 GiB) copied, 178.131 s, 44.9 MB/s
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 16683339406# ls -l eight-gigabytes
Code: -rw-r--r-- 1 root root 8000000000 Sep 7 14:06 eight-gigabytes# expr 16683339406 - 16669454870
Code:13884536As you can see, for a one-gigabyte file I get a value of 97520, and for an eight-gigabytes file I get a value of 13884536.

So let us do the math:

# echo "scale=6; 512 * 97520 / 1000 / 1000 / 1000" | bc
Code:.049930# echo "scale=6; 512 * 13884536 / 1000 / 1000 / 1000" | bc
Code:7.108882The above values are definitely too large, as 1 GB equals 0.001 TB and 8 GB equals 0.008 TB.

# echo "scale=6; 512 * 97520 / 1000 / 1000 / 1000 / 1000" | bc
Code:.000049# echo "scale=6; 512 * 13884536 / 1000 / 1000 / 1000 / 1000" | bc
Code:.007108In this case the values become much too small - especially the first one for one-gigabyte file.

I tried other calculations, omitting the multiplication by 512, dividing by 1024 instead of 1000, etc., but I could not get consistent results.

* * *

I would appreciate any advice on how to convert the values reported by my oldest drive to terabytes.

For comparison, here are the values for this drive when first used to install the 32-bit version of Slackware Linux 14.2 in 2018:

Code:Device Model: Samsung SSD 860 EVO 250GB
Serial Number: S3YJNF0K261478T
LU WWN Device Id: 5 002538 e401d3027
Firmware Version: RVT01B6Q
User Capacity: 250,059,350,016 bytes [250 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: Unknown(0x09fc), ACS-4 T13/BSR INCITS 529 revision 5
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 1.5 Gb/s)
Local Time is: Sat May 5 02:58:36 2018 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

[...]

ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 1
12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 7
177 Wear_Leveling_Count 0x0013 100 100 000 Pre-fail Always - 0
179 Used_Rsvd_Blk_Cnt_Tot 0x0013 100 100 010 Pre-fail Always - 0
181 Program_Fail_Cnt_Total 0x0032 100 100 010 Old_age Always - 0
182 Erase_Fail_Count_Total 0x0032 100 100 010 Old_age Always - 0
183 Runtime_Bad_Block 0x0013 100 100 010 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0032 065 059 000 Old_age Always - 35
195 Hardware_ECC_Recovered 0x001a 200 200 000 Old_age Always - 0
199 UDMA_CRC_Error_Count 0x003e 100 100 000 Old_age Always - 0
235 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 0
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 18784306As you can see, the total size of a full installation of this version of Slackware on my disk was 18784306 units.

Which is a mystery to me, what these units are, because I can not convert them to terabytes.

* * *

To recapitulate: the smartctl program reports 97520 units for a one-gigabyte file, 13884536 units for an eight-gigabytes file, and 18784306 units for a fresh installation of 32-bit version of Slackware Linux 14.2 - my problem is finding a consistent way to convert these units to terabytes.

Note that the version of smartctl I was using in 2018 was different than the current one. I am now using the 64-bit version of Slackware 15.0 with the generic kernel 5.15.161.

* * *

[EDIT]

The df command after installing Slackware 14.2 and adding some additional data returned the following message:

# df
Code:Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 30832636 8396132 20847256 29% /
devtmpfs 2024236 0 2024236 0% /dev
tmpfs 2024652 1036 2023616 1% /run
tmpfs 2024652 0 2024652 0% /dev/shm
cgroup_root 2024652 0 2024652 0% /sys/fs/cgroup
cgmfs 100 0 100 0% /run/cgmanager/fs
/dev/sda3 189779700 60744 180055676 1% /mnt/sda3Here is the amount of used disk space in this case in gigabytes:

# echo "scale=6; (8396132 + 60744) / 1000 / 1000" | bc
Code:8.456876So a fresh installation of 32-bit version of Slackware 14.2 took up 8.46 GB.

[/EDIT]
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments