You are not logged in.

#1 2023-06-01 19:15:12

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 364

Does swapfile damage SSD?

hi,
i have a pc with 8gb ram but a certain game needs 12gb so i created a swapfile of 8gb. Is this a good idea, or do I risk damaging the SSD? I intend to play for over 50 hours.
What is the best way to create a swapfile to minimizing writes on SSD?

smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.3.4-zen1-1-zen] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Crucial/Micron Client SSDs
Device Model:     CT120BX300SSD1
Serial Number:    0000000000000
Firmware Version: M2CR010
User Capacity:    120,034,123,776 bytes [120 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
TRIM Command:     Available, deterministic, zeroed
Device is:        In smartctl database 7.3/5319
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Thu Jun  1 18:02:44 2023 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
AAM feature is:   Unavailable
APM feature is:   Unavailable
Rd look-ahead is: Enabled
Write cache is:   Enabled
DSN feature is:   Unavailable
ATA Security is:  Disabled, frozen [SEC2]

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x02)	Offline data collection activity
					was completed without error.
					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: 			 (0x71) SMART execute Offline immediate.
					No Auto Offline data collection support.
					Suspend Offline collection upon new
					command.
					No Offline surface scan supported.
					Self-test supported.
					Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:            (0x0002)	Does not save 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: 	 (   1) minutes.
Extended self-test routine
recommended polling time: 	 (   2) minutes.
Conveyance self-test routine
recommended polling time: 	 (   1) minutes.
SCT capabilities: 	       (0x0035)	SCT Status 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          FLAGS    VALUE WORST THRESH FAIL RAW_VALUE
  1 Raw_Read_Error_Rate     POSR-K   100   100   000    -    0
  5 Reallocate_NAND_Blk_Cnt -O--CK   100   100   010    -    0
  9 Power_On_Hours          -O--CK   100   100   000    -    5740
 12 Power_Cycle_Count       -O--CK   100   100   000    -    8440
171 Program_Fail_Count      -O--CK   100   100   000    -    0
172 Erase_Fail_Count        -O--CK   100   100   000    -    0
173 Ave_Block-Erase_Count   -O--CK   090   090   000    -    309
174 Unexpect_Power_Loss_Ct  -O--CK   100   100   000    -    102
180 Unused_Reserve_NAND_Blk PO--CK   100   100   000    -    41
183 SATA_Interfac_Downshift -O--CK   100   100   000    -    50
184 Error_Correction_Count  -O--CK   100   100   000    -    0
187 Reported_Uncorrect      -O--CK   100   100   000    -    0
194 Temperature_Celsius     -O---K   100   100   000    -    40 (Min/Max 0/54)
196 Reallocated_Event_Count -O--CK   100   100   000    -    0
197 Current_Pending_ECC_Cnt -O--CK   100   100   000    -    0
198 Offline_Uncorrectable   ----CK   100   100   000    -    0
199 UDMA_CRC_Error_Count    -O--CK   100   100   000    -    6
202 Percent_Lifetime_Remain ----CK   090   090   001    -    10
206 Write_Error_Rate        -OSR--   100   100   000    -    0
210 Success_RAIN_Recov_Cnt  -O--CK   100   100   000    -    0
246 Total_LBAs_Written      -O--CK   100   100   000    -    13000293351
247 Host_Program_Page_Count -O--CK   100   100   000    -    141184443
248 FTL_Program_Page_Count  -O--CK   100   100   000    -    428444852
                            ||||||_ K auto-keep
                            |||||__ C event count
                            ||||___ R error rate
                            |||____ S speed/performance
                            ||_____ O updated online
                            |______ P prefailure warning

General Purpose Log Directory Version 1
SMART           Log Directory Version 1 [multi-sector log support]
Address    Access  R/W   Size  Description
0x00       GPL,SL  R/O      1  Log Directory
0x01           SL  R/O      1  Summary SMART error log
0x02           SL  R/O      1  Comprehensive SMART error log
0x03       GPL     R/O      1  Ext. Comprehensive SMART error log
0x04       GPL,SL  R/O      8  Device Statistics log
0x06           SL  R/O      1  SMART self-test log
0x07       GPL     R/O      1  Extended self-test log
0x09           SL  R/W      1  Selective self-test log
0x10       GPL     R/O      1  NCQ Command Error log
0x11       GPL     R/O      1  SATA Phy Event Counters log
0x24       GPL     R/O     88  Current Device Internal Status Data log
0x25       GPL     R/O    128  Saved Device Internal Status Data log
0x30       GPL,SL  R/O      9  IDENTIFY DEVICE data log
0x80-0x9f  GPL,SL  R/W     16  Host vendor specific log
0xe0       GPL,SL  R/W      1  SCT Command/Status
0xe1       GPL,SL  R/W      1  SCT Data Transfer

SMART Extended Comprehensive Error Log Version: 1 (1 sectors)
No Errors Logged

SMART Extended Self-test Log Version: 1 (1 sectors)
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%      5740         -
# 2  Short offline       Self-test routine in progress 90%      5740         -
# 3  Offline             Completed without error       00%      5740         -
# 4  Short offline       Completed without error       00%      3434         -
# 5  Offline             Self-test routine in progress 90%      3434         -
# 6  Offline             Completed without error       00%        17         -
# 7  Offline             Completed without error       00%        17         -

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
    7        0    65535  Read_scanning was completed without error
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.

SCT Status Version:                  3
SCT Version (vendor specific):       0 (0x0000)
Device State:                        Active (0)
Current Temperature:                     0 Celsius
Power Cycle Min/Max Temperature:     33/40 Celsius
Lifetime    Min/Max Temperature:      0/54 Celsius
Under/Over Temperature Limit Count:   0/0

SCT Temperature History Version:     2
Temperature Sampling Period:         1 minute
Temperature Logging Interval:        1 minute
Min/Max recommended Temperature:      0/100 Celsius
Min/Max Temperature Limit:            0/100 Celsius
Temperature History Size (Index):    128 (10)

Index    Estimated Time   Temperature Celsius
  11    2023-06-01 15:55    40  *********************
  12    2023-06-01 15:56    41  **********************
  13    2023-06-01 15:57    41  **********************
  14    2023-06-01 15:58    40  *********************
 ...    ..( 24 skipped).    ..  *********************
  39    2023-06-01 16:23    40  *********************
  40    2023-06-01 16:24    41  **********************
  41    2023-06-01 16:25    40  *********************
  42    2023-06-01 16:26    40  *********************
  43    2023-06-01 16:27    41  **********************
  44    2023-06-01 16:28    41  **********************
  45    2023-06-01 16:29    41  **********************
  46    2023-06-01 16:30    40  *********************
  47    2023-06-01 16:31    41  **********************
  48    2023-06-01 16:32    41  **********************
  49    2023-06-01 16:33    40  *********************
  50    2023-06-01 16:34    41  **********************
  51    2023-06-01 16:35    40  *********************
  52    2023-06-01 16:36    40  *********************
  53    2023-06-01 16:37    41  **********************
 ...    ..( 11 skipped).    ..  **********************
  65    2023-06-01 16:49    41  **********************
  66    2023-06-01 16:50    35  ****************
  67    2023-06-01 16:51    36  *****************
  68    2023-06-01 16:52    36  *****************
  69    2023-06-01 16:53    38  *******************
 ...    ..(  4 skipped).    ..  *******************
  74    2023-06-01 16:58    38  *******************
  75    2023-06-01 16:59    40  *********************
 ...    ..( 28 skipped).    ..  *********************
 104    2023-06-01 17:28    40  *********************
 105    2023-06-01 17:29    33  **************
 106    2023-06-01 17:30    35  ****************
 107    2023-06-01 17:31    36  *****************
 108    2023-06-01 17:32    36  *****************
 109    2023-06-01 17:33    36  *****************
 110    2023-06-01 17:34    38  *******************
 111    2023-06-01 17:35    38  *******************
 112    2023-06-01 17:36    33  **************
 113    2023-06-01 17:37    35  ****************
 114    2023-06-01 17:38    35  ****************
 115    2023-06-01 17:39    36  *****************
 116    2023-06-01 17:40    36  *****************
 117    2023-06-01 17:41    38  *******************
 ...    ..(  5 skipped).    ..  *******************
 123    2023-06-01 17:47    38  *******************
 124    2023-06-01 17:48    40  *********************
 ...    ..( 12 skipped).    ..  *********************
   9    2023-06-01 18:01    40  *********************
  10    2023-06-01 18:02    41  **********************

SCT Error Recovery Control command not supported

Device Statistics (GP Log 0x04)
Page  Offset Size        Value Flags Description
0x01  =====  =               =  ===  == General Statistics (rev 2) ==
0x01  0x008  4            8440  ---  Lifetime Power-On Resets
0x01  0x010  4            5740  ---  Power-on Hours
0x01  0x018  6       115391463  ---  Logical Sectors Written
0x01  0x020  6       148686334  ---  Number of Write Commands
0x01  0x028  6      1577639787  ---  Logical Sectors Read
0x01  0x030  6       320974756  ---  Number of Read Commands
0x04  =====  =               =  ===  == General Errors Statistics (rev 1) ==
0x04  0x008  4               0  ---  Number of Reported Uncorrectable Errors
0x04  0x010  4             110  ---  Resets Between Cmd Acceptance and Completion
0x06  =====  =               =  ===  == Transport Statistics (rev 1) ==
0x06  0x008  4           34464  ---  Number of Hardware Resets
0x06  0x018  4               0  ---  Number of Interface CRC Errors
0x07  =====  =               =  ===  == Solid State Device Statistics (rev 1) ==
0x07  0x008  1              10  ---  Percentage Used Endurance Indicator
                                |||_ C monitored condition met
                                ||__ D supports DSN
                                |___ N normalized value

SATA Phy Event Counters (GP Log 0x11)
ID      Size     Value  Description
0x0001  2            0  Command failed due to ICRC error
0x0002  2            0  R_ERR response for data FIS
0x0003  2            0  R_ERR response for device-to-host data FIS
0x0004  2            0  R_ERR response for host-to-device data FIS
0x0005  2            0  R_ERR response for non-data FIS
0x0006  2            0  R_ERR response for device-to-host non-data FIS
0x0007  2            0  R_ERR response for host-to-device non-data FIS
0x0008  2            0  Device-to-host non-data FIS retries
0x0009  2            0  Transition from drive PhyRdy to drive PhyNRdy
0x000a  2            2  Device-to-host register FISes sent due to a COMRESET
0x000b  2            0  CRC errors within host-to-device FIS
0x000d  2            0  Non-CRC errors within host-to-device FIS
0x000f  2            0  R_ERR response for host-to-device data FIS, CRC
0x0010  2            0  R_ERR response for host-to-device data FIS, non-CRC
0x0012  2            0  R_ERR response for host-to-device non-data FIS, CRC
0x0013  2            0  R_ERR response for host-to-device non-data FIS, non-CRC

sorry for my bad english

Offline

#2 2023-06-01 19:46:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,695

Re: Does swapfile damage SSD?

You risk to die when you live, but chances to ruin your SSD this way are low.
The best way to create a swapfile that minimizes SSD writes is to create it on a HDD.

Other than that (and a bit more serious) you could lower vm.swappiness (20? That number is based on "my gut told me") to favor dropping file caches over swapping out anon pages, since their re-read is a read-only operation.
There's nothing special about a swap file, the wear leveling happens on a lower level ie. even rewriting (into) the same file over and over and over and over and … again will not write the same NAND cells.

PS: don't get too fancy about vm.swappiness, too low values set you up for thrashing (ie. file gets dropped from cache to immediately get re-read then dropped again - which is bad for performance and likely will heat up the SSD as well)

Offline

#3 2023-06-02 09:48:10

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 364

Re: Does swapfile damage SSD?

seth wrote:

You risk to die when you live, but chances to ruin your SSD this way are low.
The best way to create a swapfile that minimizes SSD writes is to create it on a HDD.

Other than that (and a bit more serious) you could lower vm.swappiness (20? That number is based on "my gut told me") to favor dropping file caches over swapping out anon pages, since their re-read is a read-only operation.
There's nothing special about a swap file, the wear leveling happens on a lower level ie. even rewriting (into) the same file over and over and over and over and … again will not write the same NAND cells.

PS: don't get too fancy about vm.swappiness, too low values set you up for thrashing (ie. file gets dropped from cache to immediately get re-read then dropped again - which is bad for performance and likely will heat up the SSD as well)

thanks, i have set swappiness to 20.

anyway, I tried to do an experiment: I did a smartctl test before playing, after 30 minutes of playing and then after 1 hour.
These are the values of the "Total_LBAs_Written":

Before: 13011690759 (6661.99GB)
After 30 mins: 13017522391 (6664.97GB)
After 1 hour: 13022370543 (6667.45GB)

Basically after 1 hour of game it wrote 5.64GB on SSD.

Last edited by quellen (2023-06-02 09:48:46)


sorry for my bad english

Offline

#4 2023-06-02 11:48:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,695

Re: Does swapfile damage SSD?

According to https://www.disctech.com/Crucial-BX300- … tate-Drive the drive is graded for 55TB, so you used up 0.01% of its total endurance. (Meaning you can play the game for 10.000h or 416 days straight before you need to expect the drive to fail)

The other question is how this scales - whether it's more like 100MB/m or 6GB per session.
You've 8GB RAM and the game requires 12, so you can expect 4+ GB to be swapped out for any instance of the game - you're not getting around that but
- get more RAM
- don't play the game

Offline

#5 2023-06-11 16:34:40

gary8588
Member
Registered: 2022-08-09
Posts: 39

Re: Does swapfile damage SSD?

seth wrote:

Other than that (and a bit more serious) you could lower vm.swappiness (20? That number is based on "my gut told me") to favor dropping file caches over swapping out anon pages, since their re-read is a read-only operation.

This is a part I still fail to understand. Why would the kernel decide to swap out literal files and write it to swap anyway? They are already written somewhere on the drive. Whats the purpose putting file pages like "very_important_notes.txt" into swap?

Offline

#6 2023-06-11 16:39:38

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,695

Re: Does swapfile damage SSD?

It doesn't. Like. At all.
Anon pages are the exact opposite of file backed pages.

Offline

Board footer

Powered by FluxBB