Sunday, March 9, 2014

Reduce the stress on SSD

If you have an SSD, you better do some adjustments to increase the lifetime of your harddrive.

1) Mounting your partitions with trim support.

/dev/sda1       /               ext4                  defaults,relatime,noatime,discard            0 1 
/dev/sda2       /               ext4                  defaults,relatime,noatime,discard            0 1 


2) Use your ram for temp files.

tmpfs             /tmp        tmpfs                  noatime,nodiratime,size=6G           0 0 


 3) If you are running gentoo (sabayon) on desktop, many programs, using X windows systems (like: chromium, firefox, skype) are making frequent disk I/O every few seconds to cache. Default cache dir is ~/.cache, which is on hard drive.

Edit 
/etc/env.d/30xdg-data-local and add line: 
XDG_CACHE_HOME="/tmp/.cache" 

Reboot

TEST TRIM

Now it is time to test trim on SSD. As root,

su
dd if=/dev/urandom of=tempfile count=100 bs=512k oflag=direct

Check the starting LBA address of the file:

hdparm --fibmap tempfile

Read the first address of the file, note that you need to put the first LBA in place of [ADDRESS]:

hdparm --read-sector [ADDRESS] /dev/sdX

Now remove the file and synchronize the filesystem:

rm tempfile
sync

Use the same command to re-read the LBA:

hdparm --read-sector [ADDRESS] /dev/sdX

If TRIM is properly working the result of the last command should be a bunch of zeros. If the output is not zeros, then something could be wrong with your kernel/Ext4 configuration and TRIM may not be working.

References
1) https://wiki.gentoo.org/wiki/SSD

No comments:

Post a Comment