Suppose that I want to use my AutoPi with multiple cars. Is there an appropriate way of unplugging the AutoPi and minimize possible filesystem corruption. I assume that one recommendation is to turn the car engine off prior to disconnecting the unit. Is there any delay to wait before disconnecting it? Do we have to ssh in the Pi and initiate a shutdown command or simply open terminal and do a power.hibernate command?
Having look under the hood, it seems that there is a capacitor on the AutoPi that technically can provide enough time before discharging and allow the AutoPi to shutdown properly in case of power failure (AutoPi disconnected from the ODB connector). If it’s the case then it’s probably the answer to my question.
After turning of the engine, the device will keep awake for 30 minutes, and then go to sleep.
So ideally you’d wait for it to go to sleep, but you could also connect to the hotspot and then issue the following command in the local terminal.
power.sleep confirm=true
This will tell it to go to sleep the same way it will after inactivity (30 mins after engine off)
But it will also check for any updates, so it may take longer than expected.
Alternatively, you can use this instead, but this has a few gotchas (see below)
cmd.run 'poweroff'
This will turn it off, nothing else, but if you do it this way, you need to make sure to unplug the device and plug it in again, before it will start monitoring when the car is started.
But that’s not a problem if you do the above shutdown because you want to move the device to another car.
And for both ways to shut it off, you need to wait for the green light to go out.
We have done a bunch of optimisations to reduce the risk of a corrupted memory card, and we have been pretty tough on our test devices, and we have yet to see a corrupted card.
But I would still shut it down before unplugging, if possible, to not tempt fate.
Also I’m pretty sure i just jinxed it pretty badly… so…