Saving a Slice of Raspberry Pi
So of all the things on the network, the DNS and DHCP server are pretty important. Especially because my experience has been the router the ISP provided is kind of mediocre at doing the DHCP job. So when the Raspberry Pi I’ve tasked with doing the work started flaking out I was a little worried.
After some investigation, it seems the SD card had lost a sector, or whatever the equivalent thing is to a sector on flash memory. These things do have a bit of a limited life and this particular one was a small 4GB card that was a little older. Four gigabytes isn’t even above the recommended size for the Pi, but I knew I wasn’t planning on putting a lot on it. Problems arose when it started dying though. There actually isn’t much using the PiHole, some of the things my wife does with coupons and such I suspect might get blocked and I don’t want the headache of dealing with trying to manually whitelist things and complaints that this and that isn’t working. The DHCP is another issue. When the DHCP server disappears, it seems anything using it simply can’t connect to the internet. I have a lot of static assignments but there’s quite a few assigned by the server.
I may have to look into setting up a secondary backup server, maybe on one of the CHIPs even.
I started out simply re-imaged Raspbian onto a fresh card and setting things up again following the tutorial I had posted. Everything went pretty smoothly except that I was now out my old config file and would have to go through the hassle of recreating all of the changes I’d made adding and removing devices.
So I went with a new strategy, why not just clone the old card to a new one. Unfortunately, Win32 Disk Imager, the recommended tool for imaging these SD cards, couldn’t read the whole card, it got hung up and failed partway in. So I turned to my laptop and Linux hoping for something more robust, which I found in ‘dd’. It probably stands for “Disk Duplicator”, but don’t quote me on that.
I started running dd to make an image of the old card to put onto a new card, unfortunately, it also failed, like Win32DiskImager.
Back to Square One…
After some searching, I found this post suggesting something called ddrescue. Most of it wasn’t anything I needed aside from the following.
sudo apt-get install gddrescue
sudo ddrescue -v /dev/sdb /dev/sdc
A few things of note. My laptop, like many, has a build in SD slot, I added a second using my USB card reader. I opened the disk manager to get the path to each card, /dev/sdb and/dev/sdc.
This command also hit an error at the same point as both Win32DiskImager and the “dd” command, but it pushed on through, recovering everything else. At this point it’s a matter of hoping that one bad spot wasn’t int he middle of an important file.
Josh Miller aka “Ramen Junkie”. I write about my various hobbies here. Mostly coding, photography, and music. Sometimes I just write about life in general. I also post sometimes about toy collecting and video games at Lameazoid.com.