Assuming that I do not have keyboard or ssh access to my Pi, but I do have physical access. What is the safest way to power it off and preserve the SD card? (This is the case if I've just done a silent install and need to power off the pi, and I don't have a USB keyboard or wifi access configured yet.)
I can imagine a few approaches:
- Turn off the power at mains. Maybe this is bad because the 5v power supply will drop relatively slowly, causing bad things to happen electronically. (I am not an electrical engineer)
- Unplug the micro usb power plug. Maybe this is better than the above because the power will drop more abruptly.
- Eject the SD card first, then power off using 1 or 2 above. Maybe this is good because I see that the contacts on SD cards are different lengths. Maybe this is so that power to the SD card is lost in an orderly fashion as the different pins lose contact in a defined order when ejected.
- Some other way I've not thought of.
Edit: I do not believe this is a duplicate of the questions suggested:
In my case I'm talking about when I do not have ssh or keyboard access in order to type shutdown commands such as sudo poweroff
. I called out in my question that this is the case immediately after doing a silent install of an OS, and you may not have network configured yet.
In these cases I found I had to uncleanly power off, plug the SD card into another machine in order to edit files in /etc
to configure the network, then plug back into the Pi and boot. So, just once or twice I found I had to uncleanly power off my Pi, and I would like to know the safest way of doing that. I think this is a reasonable question to ask, and is different from the suggested duplicates which are about how to switch off your Pi in the normal day-to-day case.