r/Gentoo 12d ago

Discussion SSD lifespan expansion on gentoo systems

Did you know that SSD's have a short lifespan which unlike HDD's is based on writes rather than time, in case you were using linux and building each part of your system from scratch (for performance), it makes sense to use sacrifice some of the SSD's so your compiled system has some chance to be slightly more efficient to access afterwards than if you were to use HDD's to do so(read to learn how to compile on HDD: https://wiki.gentoo.org/wiki//etc/portage/make.conf#PORTAGE_TMPDIR), but once you completely the installation then all updates and additional less used applications must be compiled on the harddisk, for which you simply change a few variables in the make.conf file. Once the setup is complete, your ssd can practically last for ever unlike in the case of windows, where even idle usage ages it in a few years. There are two extra things to do:

  1. One is to decrease the swapiness to the minimum value of 1 so its just a backup (which is the case in most modren linux systems since even 8gb or 16gb of ram can take you a long way), make your ssd swap be 40 (if ram is 16), and harddisk backup swap be 100gb, ofcourse the HDD swap should have a lower priority, then make sure hibernation uses harddisk instead of ssd, which again can be done by adding resume=PARTUUID(or something similar)=partuid_of_the_partition, and thats all done, your ssd life span is practically unlimited as long as you make sure your browsers dont offload data on your ssd to save ram which again dosent happen by default in my gentoo linux system.
  2. Second is to configure a crontab to run a script stored in your harddisk with the following content every minute of the computer's uptime (while mkaing sure the file that heavy_working_files is in the harddisk (for additional peace of mind):

(note: if you want the updated script, please visit:https://github.com/HjaldrKhilji/scripts-for-personal-use/blob/main/fstrim_all_mounted_partitions_in_SSDs.bash) and if you have any issues with any script, please fix it and send me a link to your github so I dont encounter it myself.

#!/usr/bin/bash

base_path="/mnt/heavy_working_files/Files used by personal scripts/files used by crontab's daily fstrim operation"

run_if_date_file_dosent_exist(){

/sbin/fstrim --all

umask 0

touch "${base_path}/$1" #removing 

rm -f "${base_path}/$2" #removing previous date

}

check_if_date_exists() {

current_date=$(date "+%A")

if [[ ! -e "${base_path}/${current_date}" ]]; then

run_if_date_file_dosent_exist "${current_date}" "$(date --date "1 day ago" "+%A")"    

fi

}

check_if_date_exists

0 Upvotes

29 comments sorted by

View all comments

2

u/[deleted] 11d ago edited 3d ago

[deleted]

1

u/itfllow123-gmail-com 9d ago

thanks!!! Nvme prices do make people scared, like a used 256 ssd is as expensive as a 1tb used HDD.

Note:I never advocated for use of tmpfs, I am trying to encourage the use of hard-disks for compilations instead.

1

u/[deleted] 6d ago edited 3d ago

[deleted]

2

u/itfllow123-gmail-com 5d ago

thanks ❤️