Does dirty shutdowns cause loss of data? (remote media and library)


I’m using a raspberry pi 2 with the latest stable version of OSMC. It is connected to my Samsung TV via HDMI. The TV has a 1A USB port so I’m also using the TV to power my Pi2.

As you can imagine, when I turn my TV off, it cuts the power from the Pi2, causing a dirty shutdown. Most of the time it does not causes any problem but every once in a while I turn Kodi on and it has lost my library. It even hides the “Movies” and “TV Shows” menu entries.

Most of the times when it happens, a simple clean reboot solves the problem, the library is shown again. But in some cases rebooting does nothing and I have to re-add my media folders, just updating the library does nothing.

My media files are located in a network share and Kodi’s library is saved to a MySQL server on my network so I don’t understand what gets corrupted that causes the issue.

Sam Nazarko himself insisted that the problem is not the dirty shutdown but the TV not providing enough power but I dare to disagree because there’s nothing plugged on the pi except for the wired network and I’m able to play 1080p 3D SBS files without any issues so I think I’m good.

Please note:

  • Kodi just loses library information, the network continues accessible, I can even browse the VIDEOS > FILES > folder locations and actually PLAY my remote media.
  • Library data on MySQL server is still there.

PS: I know I should get a proper power supply for my Pi2 but I want to understand what gets corrupted when this happens since the library is on another server and network is OK.


Two things:

You are seriously chancing your luck. Why not just invest in a good PSU and eliminate that for sure? Powering off of a TV is never a good idea. If you are getting enough power, it’s because your TV is not complying with the USB specification. Then the question arises, what else is it not complying with? Is there significant ripple (how well regulated is the TV’s power)?

Debug logging will confirm if this is indeed a timing issue as you suspect.

A dirty shutdown can have consequences independent of the power supply, that is a separate question in my opinion. I did not say the dirty shutdown and your TV not providing enough power were mutually exclusive. What I can, and will say, is we have many users not afflicted by this issue, and I suspect we’re looking at a hardware problem here.

I want to understand what gets corrupted when this happens since the library is on another server and network is OK.

OSMC will hold references to remote libraries on a local filesystem. This could very easily get corrupted.


Yeah, I will to get rid of Samsung’s out of specification (1A, 5V USB 2.0 port made for those also out of specification external hard drives that consume more than 0.5A) ASAP. I have a 2.6A LG tablet recharger that will do the job.

Analizing the log confirmed that the network wasn’t active by the time kodi started. I’ve enabled “wait for network” in My OSMC > Network, rebooted and my library was working again.

Why this only happens after a dirty shutdown? I think that after a dirty shutdown the system tries to repare/clean up the mess during boot and it delayed the network activation. Am I right?

Thanks for taking the time to help me, mr. Nazarko, really aprreciate it.

If you are not properly powering your device, then until you do, no determination of causation for any other problems can be made. Devices running on insufficient power sources behave erratically and with a plethora of unexplainable issues. Resolving the power issue is the number one concern that must be addressed before troubleshooting any other issue.

1 Like

The problem was solved by turning on “wait for network”. I tried to reproduce the problem many times after that by doing repeatedly dirty shutdowns and no errors whatsoever. I tried disabling “wait for network” and the problems returned the next reboot, turned it back on, rebooted again and the problem was gone once more.

I really don’t understand why insist on that power question. I. read. everywere. that Pi2 power consumption is around 3.5 watts to 4 watts by itself so the 5v, 1A USB port I’m using is providing more than enough power (5 watts).

Yes, if you are using a remote MySQL server you should enable “wait for network”. This is to make sure the network connection comes up before Kodi is started. This has nothing to do with dirty shutdowns.

That doesn’t mean its a good idea to constantly subject your systems to dirty shutdowns though - don’t.

Yes, I missed kodi’s documentation tip to enable “wait for network” after moving the library to MySQL, just found it out. Whats odd is that the problem just appeared after some dirty shutdowns and never after clean reboots/shutdowns.

And also yes, dirty shutdowns are never a good idea. :blush: