My system seems to crash from time to time. I still don't know what causes it.
If I leave it untouched for a few hours, sometimes, it crashes.
To resume, I have to force a reboot by unplugging the power cable (not even pressing the power button for N seconds seems to work).
Then, it seems to work just fine (after displaying some error messages about lost or orphaned inodes at boot). Until, one day, it happens again. When? I never know. It seems to follow some strange and unpredictable pattern.
Certainly seems like a hardware issue, but there's no easy answer to this one. It could be your power supply, motherboard, CPU, memory, even the video card. The power-button issue makes me lean towards power supply or motherboard though (assuming you've verified the power button works after a fresh boot).
If you have other parts on hand (even from another running system) you could swap components until you identify the culprit. If you find it's your power supply, make sure you replace it with a decent quality one, NOT one of those $25 units you find everywhere, or you'll have even more problems followed by a rapid failure in another year.
Then it could still be the power supply or motherboard. It takes a lot to override the hardware power switch and the power supply itself is usually one of the biggest culprits to random lockups. Beyond that I can't offer much, I don't know of any way to test the components unless you could afford thousands of dollars for specialized equipment. I've always had multiple machines available to swap parts so I don't have a different strategy for troubleshooting.
Only when it’s idle for a while? That would point to power saving or suspend. You could try changing those to see if it affects the situation.
That's my feeling as well. It's set to suspend after 20mn and the power button in set to suspend, so maybe if I try to suspend and wake back up several times, one of the times it will fail... God! I am really not in the mood for that!... Let's see...
But yes, hardware. And I would suspect the display controller in particular. I’ve seen many that glitch when in power saving.
I would check system level logs to start like dmesg and syslog.
Someone else might have better tips of what to grep for in the logs. One thing you could do is try to ssh into the system when it’s locked up and check the logs to see what’s being reported during or immediately before the lockup.
Once you get a sense for what’s going on at a system level you can start to look in more specific logs.
I was hoping for some log that could maybe save some info when in a hurry, sensing an eminent crash or an emergency, but that doesn't really make sense, does it? - If it crashes, it crashes. There's probably no time to dump anything to disk. Otherwise the crash would have been prevented.
Anyway, some paths have been opened for when I have time to dig in a little bit deeper.
I'll quickly find something else to annoy you ASAP. ;-)
It would be worth looking through your journal. There is usually some amount of logging even in the event of a hardware issue. See journalctl.
As others suggest, does sound related to sleep / suspend. If that is the case, you could have a problem like I did where my motherboard BIOS incorrectly reports usb capabilities which results in an immediate resume from sleep. That abrupt change causes the amdgpu driver to crash, and the system hangs soon after. My workaround is to disable features on the offending usb host controller.
Journalctl has a bunch of filter options that you should take advantage of when troubleshooting. For example, journalctl -b -1 will show you only the messages from the last boot (not the current). I used this article for a quick couple of need to know commands. Enjoy! :D