-
Notifications
You must be signed in to change notification settings - Fork 1
/
SSD.txt
151 lines (108 loc) · 5.33 KB
/
SSD.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2016-10-23T15:55:48+02:00
====== SSD ======
Created søndag 23 oktober 2016
**Some tools and configuration for Disk optimization. **
===== I/O Top =====
**# Follow what, and how often, an application writes to the disk.**
$ pacman -S iotop
**# invoke it with**
$ iotop -boqqq
===== Smartmontools =====
**# **//smartmontools//** can be used to monitor disk health state through the S.M.A.R.T monitoring**
$ pacman -S smartmontools
**# The SMART monitoring is probably already running, **
**# but we wan't to exclude SCSI commands since we are on a ATA device**
$ smartctl --smart=on --device=ata /dev/sda
==== Usage ====
**# You can get the devices connected with; **//lsblk//
**# Get some device information - change **//X//** accordingly throughout **
$ smartctl -i /dev/sd//X //
== Daemon ==
**# **//smartd//** can automatically run test and notify is issues is reported **
**# This requires you to have setup Dunst (notifications) and the SSMTP (mail)**
**# Enable the Daemon service file**
$ systemctl enable smartd.service
**# The configuration file is stored in **///etc/smartd.conf//
**# Only 1 line will be outcommented - comment this line and define this line instead**
{{{code: lang="texinfo" linenumbers="True"
/dev/sda -a -n standby,q -W 4,35,45 -s (S/../.././02|L/../../6/03) -m jeppesen@tutanota.com -M /usr/local/bin/smartnotify
}}}
**# The above line will monitor on **//sda//** (change accordingly) **
//-a //**= all errors**
//-n //** = disable checking if disk is in standby**
//-W//** = alert on temperature too. **
**It will log on 4degree change and 35degree hit, and alert at 45degree**
//-s//** = scheduled self test, each day between 2-3am, and Saturdays between 3-4am**
//-m//** = send mail to this address - change accordingly **
//-M //**= execute this script (notification and mail content)**
**# Copy this script to **///usr/local/bin/smartnotify//
**# Change the user and userId (**//stick //**and **//1000//**) accordingly. You can get userId with;**// id//
{{{code: lang="texinfo" linenumbers="True"
#! /bin/sh
# Send mail
echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" "$SMARTD_ADDRESS"
# Notify user
wall "$SMARTD_MESSAGE"
# Desktop notification
sudo -u stick DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" -u critical --icon=dialog-warning
}}}
**# And make it executable **
$ chmod +x /usr/local/bin/smartnotify
== Test the disk (safe) ==
**# You can see what tests your disk is capable to run **
$ smartctl -c /dev/sd//X//
**# The above (in my case) might produce something like**
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 10) minutes.
**# So here we are able to test with **//Short//** and **Extended** - it also shows how long the test will take^**
**# The **//Short//** test should catch most error**
$ smartctl -t short /dev/sd//X//
**# This will start the test in the background.**
**# You'll have to wait x-minutes (2min ex, will be posted) to see the result.**
**# Once time has elapsed, you can view the health result with**
$ smartctl -H /dev/sd//X//
**# To view recent reports **
$ smartctl -l selftest /dev/sd//X//
**# Or a more verbose report **
$ smartctl -a /dev/sd//X//
**# If the report show Failing Health Status, it has already failed or predicted within 24hours**
**# Make a backup asap^**
===== TRIM =====
**# Trim is used for sustained long term performance and wear-leveling. **
**# Your SSD supports TRIM. To verify TRIM support for a SSD**
$ hdparm -I /dev/sda | grep TRIM
**#** **Enable the fstrim.timer service for TRIM to take place once a week **
$ systemctl enable fstrim.timer
**#** **Change value in LVM;**
**# Edit** ///etc/lvm/lvm.conf //**and change the value of** issue_discards **from** //0// **to** //1//
===== Fstab atime options =====
**# Edit the** ///etc/fstab// **to change the** //atime// **options - which writes time to a file every time it's read.**
**# Change the** <option> **line for each of the partitions. A** <option> **field may look like the following**
rw,realtime,discard,data=ordered
**#** **atime options : **
**realtime = **Writes changes depending on previous access time was earlier than last modify time.
**noatime = **Do not allow time writes to a file.
===== Reduce swap writes =====
**# Swappiness determines how happy you are with writing from the RAM to swap partition. **
**#** **Default is 60.**
**# To see current swappiness value**
$ cat /proc/sys/vm/swappiness
**#** **Add a sysctl configuration file **
**# Add and edit a file,** /etc/sysctl.d/99-sysctl.conf **and add the following **
{{{code: lang="texinfo" linenumbers="True"
vm.swappiness=10
}}}
===== Kernel Parameters =====
**# To add kernel parameters, edit** ///etc/default/grub //**and add to the** //GRUB_CMDLINE_LINUX_DEFAULT=//
**# Ex. **//GRUB_CMDLINE_LINUX_DEFAULT="quiet splash //parameter1 parameter2//"//
**# Grub needs to generate a new configuration file afterwords**
$ //grub-mkconfig -o /boot/grub/grub.cfg//
== Enable zswap ==
**#** **Compresses and stores swap cache in RAM, instead of writing it to the disk.**
{{{code: lang="texinfo" linenumbers="True"
GRUB_CMDLINE_LINUX_DEFAULT="zswap.enabled=1"
}}}