15

I am running Kubuntu 18.04 on a Dell XPS 9370 laptop with no hard disk - just an SSD.

Should I turn off kernel logging to reduce the amount of writes to the FLASH memory on the SSD to prolong its life? And if so, how do I do that?

This question is prompted by press reports that early Tesla cars are now failing due to their SSDs because the imbedded Linux has logging enabled, and is continuously writing to SSD-based log files. I've often read that the number of writes to FLASH is limited, but this is the first concrete example of failure that I have heard about.

Or maybe it is possible to just log to RAM?

  • 3
    There is absolutely no need to worry about it. – Pilot6 Nov 12 at 19:15
  • 3
    @B.Tanner Modern SSDs with TRIM support are now more reliable than HDDs. No reason to go out of your way to avoid writes to SSDs. – K7AAY Nov 12 at 19:26
  • Also worth noting: cars have a lot more things to log. Telemetry data is critical for error investigations, legal defence, compliance, AI improvement, etc. Plus there's a huge difference between an SD card and a wear-levelled SSD with multiple flash chips and over-provisioned spare cells. With most typical use, your SSD will well outlive the useful lifetime of the computer (and itself). – Alexander - Reinstate Monica Nov 13 at 3:15
  • 1
    It is certainly a real issue, but you are unlikely to run into problems because of it. Those Teslas do run into it because not only do they have kernel logging enabled, but also log a shitload of other stuff, and being an american car, use the cheapest, crappy hardware (eMMC), and of course under-dimensioned because that's cheaper. On a typical (not 15 year old) SSD in a laptop, the SSD itself sets aside some extra memory for wear-levelling that you can't see already, and it likely does some limited write-mitigation (with a capactiator as buffer), and and... – Damon Nov 13 at 9:32
  • If you kernel is generating so many log entries that it matters your disks have probably failed already. In steady state you won’t see much logging. (Or you have wrongly configured apparmor/selinux or ipfilter) – eckes Nov 13 at 20:12
12

It should be preferred to silence logging instead of disabling it (otherwise you might miss something important).

For systemd prior to version 235 you can use

journalctl --priority=3

For newer versions there is parameter in

/etc/systemd/journald.conf

called ReadKMsg= that you need to enable. Make a backup and edit the file; remove the # in front of #ReadKMsg=yes and change yes to no (you can also insert a new line under this one with ReadKMsg=no.

changelog version 235:

journald.conf gained a new boolean setting ReadKMsg= which defaults to on. If turned off kernel log messages will not be read by systemd-journald or included in the logs.


I've often read that the number of writes to FLASH is limited, but this is the first concrete example of failure that I have heard about.

The change above is not going to matter a lot though in regards to writes to the SSD as writing is done sparsely. Then again every 1 less write is 1 less write :)

What might be an issue for Tesla: those SSDs they used might be pretty old disks. And the older SSDs did have issues. Nowadays... not so much.

  • They may also flush writes to disk immediately, rather than buffer or optimise operations by pages. – mckenzm Nov 14 at 4:54
10

The linux kernel is well aware of SSDs for a long time and default installations seem to work just fine "out-of-the-box".

I would leave logging and everything else to the default settings. From time to time I would monitor the life span of the SSD:

The above answer details how to check your remaining life of your SSD:

First step is to install nvme-cli because it provides the most information:

sudo apt install nvme-cli

Next gather information available from SSD:

$ sudo nvme smart-log /dev/nvme0
Smart Log for NVME device:nvme0 namespace-id:ffffffff
critical_warning                    : 0
temperature                         : 42 C
available_spare                     : 100%
available_spare_threshold           : 10%
percentage_used                     : 0%
data_units_read                     : 28,149,264
data_units_written                  : 19,392,109
host_read_commands                  : 559,538,536
host_write_commands                 : 171,732,762
controller_busy_time                : 1,352
power_cycles                        : 2,384
power_on_hours                      : 1,362
unsafe_shutdowns                    : 133
media_errors                        : 0
num_err_log_entries                 : 608
Warning Temperature Time            : 0
Critical Composite Temperature Time : 0
Temperature Sensor 1                : 42 C
Temperature Sensor 2                : 55 C

The percentage used is 0% after two years. When it hits 100% then theoretically the drive is all used up and needs replacing. But here is someone who has used up 250% which one would think impossible:

To make a long story short, chances are your SSD will outlast your computer system these days.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.