This weekend I was learning Go, set up a pi-hole, and was doing data rescue
Busy weekend of learning Golang, rescuing data from unreadable disk (ongoing), and setting up an online ad blackhole.
So here’s the background for the learning Go thing:
- learn golang
— Gabor Javorszky 🇬🇧 (@javorszky) January 3, 2018
- launch own saas
- launch company saas
- get to work on a tropical island in between surfing sessions
- continually push industry for better inclusion
- and better security
- get quoted in a print magazine
- become a google certified data engineer#DevDiscuss https://t.co/2abKIIDZgP
I’ve gone through the golang bootcamp book, watched a video of the difference between concurrency and parallelism, and uh... set up my system and VSCode to handle go code, and had a few tutorial projects. Nothing major.
Programming in Go is so nice. It literally tells me, right there in the editor, if my code was going to fail. And it formats my code automatically. None of that “which code style should we use” nonsense.
Fun fact: I can use unicode characters, like kanji, to name my variables. I can’t use other unicode characters, like 💩, to name variables or functions.
😔
Data rescue
This is a lot larger topic, because it’s also more important, and also something I have more... usefullness related. Or warm fuzzy feels.
Basically I am handed two damaged DVDs that are scratched, and there are images on them – images that are 1) important, and 2) there are no other copies of them, and 3) obviously the DVD drives can’t read them if you just chuck the disc into Mac or Windows.
Technically they can, until you want to get files off of it.
enter ddrescue
ddrescue
is a GNU utility which basically, if I understand it correctly, tries to copy the raw data off of a disk block by block (or sector by sector?) onto a new image file.
It’s also a utility which is available on Unix-like systems, so either OSX or a linux.
And then there was my setup: a MacBook Pro 13" from, uh... 2014 I think with no optical drive, and a PC with an optical drive running Windows 10.
I can’t run ddrescue
on the laptop for lack of DVD drive. It doesn’t work if I share my PC’s optical drive over the network, because it needs direct access to the drive. I can’t use Windows, because ddrescue
is not available on it, and I didn’t feel like experimenting with W10’s built in linux thing.
I asked for, and got given, an older external LiteOn DVD drive (thx, Brie!), which I hooked up to the Mac, however that had problems reading the disc to begin with, so alternatives had to happen.
linux-on-a-stick
A suggestion was to put a ubuntu on a USB stick, boot from the stick on the hardware of the PC, et voila, I have a running linux.
That proved less painful than I had imagined, so I followed the guide by ubuntu on how to create a usb stick, and now I have a bootable linux.
The one thing that I wasn’t sure about is whether it would try to install itself automatically or not. It won’t. It will ask whether you want to Try Ubuntu (YES), or install Ubuntu (NO).
Getting set up on the stick required a wee bit more juggling of things. First off, ddrescue
wasn’t available to start with, so I had to install it. To do that, I had to add the universe repository to the system.
Stack Overflow about that: https://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository
Then I had to update the list of available packages, and install ddrescue
.
Then I had to mount one of the hard drives on the PC hardware so I can save the rescued data TO somewhere. Because I have a 2 Tb hard drive which I mainly use to store Steam games on; I decided that’s as good a place as any.
Stack Overflow: https://askubuntu.com/questions/177825/how-to-mount-an-external-hdd
Essentially:
- find what linux knows the disk by with
lsblk
andfindmnt -D
- mount it with
sudo mount /dev/disk_identifier ~/rescue/directory_I_made
After that, I needed to run ddrescue
. The guide I’m following is this one: https://www.linux.com/learn/intro-to-linux/2017/3/GNU-DDRESCUE-BEST-DAMAGED-DRIVE-RESCUE
TLDR
- find dvd rom with
lsblk
- run
sudo ddrescue -f --no-split /dev/device_id ~/rescue/subdir/imagefile.img logfile
Here imagefile.img
does not need to exist. It will be created. logfile
should definitely not exist, it will be used later on to refer to the same disc, the same data. This is where ddrescue
stores where bad sectors are, and so on.
Also run ddrescue
on the device, not any of the partitions! ie sdb
, and not sdb1
or sdb2
for example.
Currently the process has been running for a while. See this here screenshot (if I can do this on a linux)...
Yeah, so it’s been running for 2 days now. The disc is 4.4G. 3.7G is saved already. It’s now going backwards.
Lightbulb moment also came because now that I have a bootable linux on a stick, I could just plug that into any other Windows laptop around the house with a DVD drive in it, and it should Just Work™.
That, and I have my old MacBook pro from 2011 or so which is still working perfectly.
Therefore I can just move the image and log files, and start recovery from a different computer using a different optical drive in the hopes of the others being able to read things that the one this one runs currently can’t.
It’s probably going to take me a week to either get all data off of the disc, or say, with a high degree of confidence, that no other data can be saved.
I also need to try running over the error data only with multiple retries.
However if that works, I can open up another line of business: attempting to rescue people’s data from discs!
pi-hole
I have a first generation raspberry pi B. I haven’t been using it for... pretty much anything. Last time I used it I set up BitTorrent Sync so I could use that instead of Dropbox, but then I moved, and I didn’t really want to deal with setting up everything again.
So I nuked the system on the pi, installed a new version of raspbian, and put pi-hole on it. It’s great.
Except for sites that are now broken because their javascript is set up in such a way that it assumes that google analytics is there, and if that happens to be undefined, all js functionality is bricked.
Uh yeah... as always, drop me a line on twitter or write me an email, see footer for address.
Photo by Peter Hershey on Unsplash