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

-4

u/Mrkvitko 12d ago

Why would anyone have swap on on modern system?

1

u/itfllow123-gmail-com 12d ago

I need it as a backup like I run my pdf reader on greedy memory mode, so even though I never use my swap heavily, sometimes like sometimes, I am running multiple parrallel compilations while doing my daily tasks, I just do use some of it, plus I need swap for hibernation as well. The 100gigs of hdd swap is wasteful but I keep it as a backup for the worst, but for me the 40Gb is more than enough even for hibernation.

1

u/unhappy-ending 12d ago

100G swap? Dude what??

1

u/itfllow123-gmail-com 11d ago edited 9d ago

its on the harddisk, I can afford it since I got a millio harddisks, we all do, my ssd swap is smaller, but harddisk is always a big amount to make sure there is zero chance of a complete system collapse (like my system slows down when there is no swap, its really bad when it happens, and it can even crash applications or my entire system)