OS easily corrupted

First off, I really love this product and use it for both my printers.

While I know it is always best to do a shutdown of Octopi/Octoprint before removing power, this is not always done or remembered.

Is there anything that can be done to mitigate the issue of powering down the printer (which powers the Raspberry Pi3b+) without a shutdown first and then on next power up the web site part of the system is corrupted. The printer control side I think is working as I use the IO pins to run an external relay which is used to power the printer and the lighting.

I also can SSH into the PI but the web app is dead. It is really frustrating and if there is anything that can be done it would be great.

I have been using the latest stable distro.


Pseudo-code for external script ~/scripts/safeShutdown

  • Shutdown OctoPrint
  • Wait
  • Toggle the relay OFF

The trick is to call this outside of the main thread of OctoPrint so that it will continue after that first step.

From your workstation, you can create a public/private keypair, push the public key to the Pi and then you're able to run commands remotely from your own workstation without providing the password.

  • ssh-copy-id -i ~/.ssh/id_rsa.pub pi@octopi.local # Assuming that you used the defaults for ssh-keygen on your workstation earlier, this pushes the public key over to the Pi
  • Add a file to /etc/sudoers.d so that the Pi user can run password-less sudo promotion of the ~/scripts/safeShutdown script
  • ssh -t pi@octopi.local "sudo ~/scripts/safeShutdown" # Remotely runs the script from your workstation, suitable for including in a Bash shell script, for example

And yet, this still doesn't shutdown Raspbian. It only shuts down OctoPrint. A better approach would be to replace your relay with a TP-Link SmartPlug device. Then you would change the third line of the pseudo-code to "Shutdown Raspbian". Your own workstation's Bash script could then toggle off power on the TP-Link device.

Or with the TPLinkSmartplug plugin and a TPLink device, set the options to use countdown timers to power off the plug after a long delay, and the system command option to shutdown raspbian before the delay set in countdown timer.

The same can be achieved with Tasmota flashed devices and the Tasmota plugin as well using the backlog option in lieu of countdown timers.

1 Like

Don't power the Raspberry Pi from (the same plug as) the printer. An idle Raspberry Pi uses very little power. Just keep it on.

I use a super-capacitor UPS on my Octoprint Pi. I can just turn the power off and the UPS shuts the Pi down correctly after a minute or so. I've been planning to use a Sonoff so the Pi can shut the printer down. But just turning the printer off is much easier :slight_smile:
I'll dig up a link to the UPS

1 Like

Which one do you use?

This was the one but looks like it's no longer available.

Info available at mfg of the board. [superiam.eu/index.php/shop/ups/raspberry-pi-ups-super-capacitor-backup-power-supply]
Does depend on using a GPIO pin to trigger shutdown and is preset to #18

Looks like they've just stopped selling it thorugh eBay then.

All that's needed to activate the shudown is the follwoing line in /boot/config.txt


Might be a problem if you usae pin 18 for something else.