Black-out

The other day my neighborhood remained in the dark for a 2 hour for blackout. My raspberry when energy is returned has made several attempts to restart idle, then work again "apparently" on a regular mode. In earlier (many and many) times when it was switched off by disconnecting the power, however, it was always started with a normal boot.

Today another blackout caused a restart with a dozen empty attempts.

What may have happened?

Raspberry-pi model B Raspbian wheezy with all update.

... Sorry for google traslate!

Reply to
BIG Umberto
Loading thread data ...

When you get a blackout the power usually doesn't cut off cleanly, and often doesn't return cleanly either. Depending on your power supply the voltage could make several rapid attempts to rise and fall again. This can easily corrupt files/settings.

The solution is either a small UPS, or a power supply that can hold it's voltage steady for a long time after power goes.

--
W J G
Reply to
Folderol

Just because you've got away with pulling the plug in the past is no guarantee that it will work the next time.

The blackout may very well have corrupted the SD card. If the card was 'wear levelling', which involves remapping its sectors and isn't an instant operation, the blackout happened may have terminally corrupted the SD card.

Get another card, download the latest Raspbian image and install it on the new card. If your RPi boots off that, then card corruption was the problem and you can get your stuff back by reloading /home/* from your latest backup.

No backup?

- Plug in a USB SD card reader

- put the old card in it

- run fsck against its biggest (type 83) partition. There are two partitions on the disk. The 56MB one is just the boot partition. The other, bigger, type 83 one contains the Raspbian filing system.

If fsck reports no errors:

- get another new SD card

- use fdisk on the RPi or gparted (on a Linux or Windows system) to delete the FAT 32 partition on it and create a type 83 Linux partition occupying the whole card.

- mount the old, damaged SD card in the RPi using a second USB SD card reader.

- use dd to copy the Linux partition from the old card onto the card you just reformatted.

You can now use an SD card reader to mount the card containing the copied filing system on your RPi and copy any files and programs you need from your old filing system into the newly installed Raspbian system, but unless you know exactly what you're doing *DON'T* copy anything that isn't in /home or /usr/local, i.e. no config files from /etc or you're likely to mess up Raspbian or, worst case, misconfigure it so badly it becomes impossible to boot.

You can also try reformatting the original SD card. If the problem is just a damaged filing system you'll be able to recreate the partition(s), reformat them and use the card for something else. If you can't do that, its junk, so bin it.

Now get at least another two SD cards, use fdisk to put a single single type 83 Linux partition on each of them, reformat that and use them for backups. In future make backups more frequently.

I turn Raspbian automatic updating off so I can't be surprised by an update 'just happening', and every week I make a backup immediately before running a manual upgrade using apt-get.

Backing up before doing the upgrade makes sense but you may also want to make more frequent backups. I use a version control system (cvs, though git may be better) to capture changes to my various projects. The master repository is on one of my Linux desktops which runs an overnight backup every night, so no matter what happens short of a house fire, I can't loose more than 12 hours of work.

For slightly more elaborate backup schemes, look here:

formatting link
formatting link
formatting link

The last two describe what I do on my Fedora systems but are equally applicable to Raspbian: I've done the same for my RPi.

Good luck.

----------

--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
org       |
Reply to
Martin Gregorie

Pulling the power can leave the dirty bit set. I find that running fsck on a desktop usually fixes it.

Reply to
Bob Martin

The only time I ever crashed a disk beyond repair was when a brownout caused a reboot, and a second brownout crashed the machine mid auto-reboot at the time as massive disk access.

If possible do9nty have machines that auto-reboot after power cuts. Wait till the power is stable and then go for it.

With a pi, run it off batteries that are constantly charged by the mains ...:-)

--
?Some people like to travel by train because it combines the slowness of  
a car with the cramped public exposure of ?an airplane.? 

Dennis Miller
Reply to
The Natural Philosopher

Also that a Pi is a pretty light electrical load. So it doesn't take much power for it to start up. It will depend on whatever USB power supply you have, but it's possible it could work from perhaps 90v or lower, with a very low AC current. A regular PC might be a more substantial load and so not start up, while the Pi might bounce up and down a few times as the AC restarts, and as the AC flails about and eventually disconnects in the case of a grid fault (eg if the fault was power lines in the wind, a bouncing circuit breaker, or something similar).

Theo

Reply to
Theo

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.