Why are there nulls in /var/log/kern.log

logs

I am experiencing a problem with Ubuntu 16.04 installed on an SSD. kern.log includes messages such as:

ata3: SError: { UnrecovData 10B8B BadCRC }

which I believe indicates a potential hardware fault.

But kern.log also ends with 1225 null bytes. What could be causing those? I accept that in the presence of failing hardware, anything is possible – but I'd like to rule out any other factors.

Edit: I switched SATA cables around and now the errors appear to have stopped.

Best Answer

Log messages are prepared internally as null-terminated strings. Since a null byte terminates the message, it's impossible to have one inside the message.

Finding null bytes in the log file indicates a bug somewhere, either in your software or in your hardware. Given that you're experiencing problems with the device that the logs are sorted on, these problems are likely the source of the problem with the log.

Tracing the exact way in which such symptoms relate to the root cause can be difficult. Since your storage setup is suspected of data corruption, I recommend that you stop relying on it and look for a replacement. If you make a last-minute backup, beware that some of your data may already be corrupted, so don't overwrite your existing backups.

Before you replace the SSD, keep in mind that such problems could also be due to a bad connection, so check your cables. RAM could also be the culprit, so do a memory test.

Related Question