After buying Asus eeePC and installing Linux there, I was thinking about extending the life of the embedded ssd disks. Searching on the Internet, I found an interesting article that describes how to do it. I really liked the article and decided to translate it. If you are working in Linux from a flash drive, then there are a few things you might want to do in order to reduce the wear and tear on the flash drive you are using (as it has a limited number of rewrite cycles).
The ext3 file system defaults to writing metadata changes to disk every 5 seconds. This period can be extended by mounting the file system with the commit = N parameter, which tells the kernel to delay recording for N seconds.
The kernel writes a new access time for each file that has been read, which generates one write operation for each read. This can be disabled by mounting the file system with the noatime option.
Both of the above actions can be set by adding options noatime, commit = 120, ... to the / etc / fstab file. This can also be done for already mounted file systems by running the command:
mount -o remount,noatime,commit=120 /
The system will run updatedb every day, which creates a database for all files in the system for use in the locate command. This will also adversely affect the file system, so you may want to disable it by adding:
exit 0
previously in the /etc/cron.daily/find script.
syslogd, when installed by default, will synchronize a large number of logs to disk immediately after adding new information. You may want to change /etc/syslog.conf so that each file name starts with a “-” (minus) sign, which means that files are not synchronized instantly (this increases the risk that some messages will be lost if your system hangs). For example, such a line as: ')
kern.* /var/log/kern.log
Can be changed to:
kern.* -/var/log/kern.log
You may also want to disable some message classes in general, writing them to / dev / null instead of a file, see syslog.conf (5) for more information.
Also, syslogd likes to write lines - MARK - to the log every 20 minutes to show that the system is still working. This can be disabled by changing the SYSLOGD option in / etc / default / syslogd as follows:
SYSLOGD = "- m 0"
After you make these changes, you need to restart syslogd by running the command:
/etc/init.d/syslogd restart
If you have a swap partition or a paging file on a flash drive, you may want to constantly move it to another part of the disk to make sure that different parts of the disk wear out equally due to the frequent recordings it generates. For the paging file this can be done by creating a new paging file before deleting the old one.
If you have a swap partition or swap file stored on a flash drive, you can be sure that it is used as little as possible by setting / proc / sys / vm / swappiness to 0.
The kernel also has a setting known as laptop_mode (laptop mode), which forces it to write to disk (initially created with the intention of letting the laptop disk stop while it is not in use, hence the name). Several files in the / proc / sys / vm / directory control its (mode) operation:
/ proc / sys / vm / laptop_mode: After how many seconds after reading the data, the changed files should start writing (this is based on the assumption that the reading will cause the previously stopped disk to be unwound).
/ proc / sys / vm / dirty_writeback_centisecs: How often the kernel has to check if there is any "dirty" (changed) data to write to the disk (in cis).
/ proc / sys / vm / dirty_expire_centisecs: How “dirty” the data must be in order for the kernel to decide that it is old enough for writing to disk. In general, it is a good idea to set the same value for this option as for dirty_writeback_centisecs above.
/ proc / sys / vm / dirty_ratio: The maximum amount of memory (in percent) for storing dirty data before the process that generated it is forced to write it. Setting this parameter to a high value should not be a problem, since the recording will also occur if the system runs out of memory.
/ proc / sys / vm / dirty_background_ratio: The minimum amount of memory (in percent) where it is allowed to store different data instead of writing to disk. This parameter should be much less than dirty_ratio to allow writing pieces of dirty data in one pass.
All of the above kernel parameters can be configured using our own boot script, as in this example . Save it, for example, in /etc/init.d/kernel-params, make it executable with the command
chmod a+x /etc/init.d/kernel-params
and make sure that it is executed with the command
update-rc.d kernel-params defaults
Remark Most of these settings reduce the number of writes to disk by increasing memory usage. This increases the risk of a low memory situation (which can trigger a “process killer” in the kernel). This can occur even if there is available free memory (for example, when the kernel needs to allocate more than one continuous page, but only fragmented pages are available). Thus, with any settings, it is recommended to keep an eye on the amount of free memory and change these settings (using less aggressive caching and increasing paging) depending on the workload.