So you deleted your Windows 10 partition table… now what?

You know the scene. You are helping a friend with a couple of corrupted/dead microSD cards. You want to access tools on a Linux machine but you moved to Windows a long while back.

You only have your trusty Windows 10 laptop that you’ve had a year onto which you have meticulously set-up your data and apps and other custom bits and pieces (ssh scripts, Virtual Machines). So what do you do?

My first thought was to use an existing Debian VirtualBox to do this. However I soon found out that VirtualBox does not yet support microSD device pass-through. USB devices work fine but not microSD… :(

So what now? Being an experienced Software Engineer you insert a SystemsRescueCD liveCD USB into your Windows 10 laptop and then boot into a SystemRescue system. You then fire up gParted, plug in each microSD card in turn and proceed to examine the state of each card.

For the first card you spot some oddities and use “dd” to write zero’s to the whole device. Once that is done you create a new partition table. Eject and insert it. There are still weird things happening. You still see the old partition layout. Curious. You give up and declare this microSD card unusable.

Next you try the other microSD card your friend has given you. It’s late, 2131hrs, and you’re tired, it’s a working day and tomorrow is a Friday. Yay end of a busy week. With gParted open you insert the microSD card and without thinking much, proceed to delete the partition table and answer “Yes, I really want to do this destructive action” to the dialog prompt…

Hmm, something odd. Where is the card in the device list from /proc/devices … Oh no. No no no. The device was not detected by the system. Therefore it did not appear as the default device in gParted. Therefore I just deleted the partition table… of my perfectly fine and working laptop HDD. Arghhhhhhhhhhhh!

OK… calm down. Do not panic. I have a running system and that system happens to be SystemRescue OS. I can recover from this if I just keep my head straight.

The data is still present on disk it’s just the disk layout table, telling the OS where to find each partition is just not there.

Thankfully, I had SystemRescue USB at hand. On this are handy tools to help recover from just such an eventuality. After all it does not have “rescue” in the name for nothing!

After some Googling of similar problems I discovered the tool I needed is called “testdisk” –
this attempts to scan an entire disk to find partitions (and guess it’s type). In running this myself I found that one can simply just use the defaults options it gives me.

In other words, the default options “just work”. Just let it run and find the partitions. It will present a candidate partition table to you. You can use the “p” key to view the contents of each partition it finds as an extra check (examples from all three partitions below).

img_20181026_113606 img_20181026_113556 img_20181026_113536

Make sure you also make the first partition bootable (indicated by the asterisk *).

img_20181026_113647

Windows 10 normally will have three partitions: a boot partition, the system (where Windows 10 actually lives, all your apps, photos, userdata, etc) and a recovery partition.

After checking that everything looks OK, accept the partition table and write it to the hard disc.

This is what your partition table should look like post-write by testdisk
This is what your partition table should look like post-write by testdisk

Now at this stage if you boot the system you will probably see some scary black or blue screens. You need to do another step which is to rebuild the “Boot Configuration Data”.

img_20181026_113315

img_20181026_114321

The way I did this was to get a Windows 10 install media USB (or CD), boot into it and follow this guide to get to the command prompt.

At this point I did:

bootrec /rebuildbcd

…then reboot. For me that fixed it. Phew! Thank Zangief for that!

I've never seen such a beautiful sight :)
I’ve never seen such a beautiful sight :)

If that does not work for you I recommend trying these in order:

 bootrec /FixMbr
 bootrec /FixBoot
 bootrec /RebuildBcd

More info here

Moral of the story is: do not do sysadmin work as root when you’re tired (obvious in hindsight!)

Note: I did an additional un-needed step after I wrote the candidate partition table to the HDD. This was to use “testdisk” to “Write TestDisk MBR code to first sector”. This was not needed since we will use the Windows 10 install media to write the MBR.

Sublime Text 2 on Debian Linux

sublime-text-the-text-editor-youll-fall-in-love-with-opera_002

As good as GEdit is, sometimes you want the polish and power of a actively-maintained, fully-functional text editor that excels at both coding duties and regular note taking – especially in Markdown.

For this reason, my choice for the last few years has been Sublime Text 2 – which although is available on a trial license is well worth paying a personal license for.

It’s available for Linux, Windows and OSX/Mac. Here I detail how to install from the tarball on a Debian Linux but the same instructions will work on any Linux flavour.

dropbox-gaming-mame-md-sublime-text-2_001

Update: I have written a script to automate these steps and you don’t even need root access, take a look here

Step 1 – Get tarball

Grab tarball from website www.sublimetext.com

Step 2 – Extract to /usr/local/src

You may already have your own preference on where you install third-party software on a Linux system (/opt perhaps?), so this is an optional step. However if anything comes as a tarball then I prefer to install them in /usr/local/src

First make it owned by you by changing to root and running this:

chown <username>. /usr/local/src

while we changing directory ownerships, lets do the same to /usr/local/bin (we’ll come back to this in a bit)

chown <username>. /usr/local/bin

Now we are ready to extract the freshly downloaded tarball to the directory

tar -xjvf SublimeText2.tar.bz -C /usr/local/src

Step 3 – Create a launcher

In order to easily launch Sublime Text like any other installed app, we now create a symlink from the Sublime Text 2 program to /usr/local/bin – this will mean that we can launch Sublime Text 2 by simply invoking `sublime_text` on the command line:

cd /usr/local/bin
ln -s /usr/local/src/Sublime\ Text\ 2/sublime_text

Next create a .desktop file for Sublime Text 2 like this:

╰─○ cat ./.local/share/applications/sublime_text.desktop
[Desktop Entry]
Version=1.0
Name=Sublime Text
Type=Application
Comment=GUI Text Editor
StartupNotify=true
MimeType=text/plain;
Terminal=false
Exec=sublime_text %U
Icon=sublime_text.png
Categories=TextEditor;Utility;
GenericName=Sublime Text

Then set an icon for the launcher, luckily these are already provided in the tarball:

cd /usr/local/src/Sublime Text 2/Icon 
cp 128x128/sublime_text.png ~/.icons

…and thats it! All being well, you can now tap the “overview” key (mapped to Windows logo key) and start typing “sublime” and it will match Sublime Text 2

screenshot-from-2017-09-06-15-58-58

…and from here you can drag it into the Favourites bar

screenshot-from-2017-09-06-13-48-20

A Weekend at OggCamp August 2017 in Canterbury, United Kingdom

Imagine a technical conference with a twist – all the talks are delivered by the delegates. In other words, the talks are delivered by the normal everyday people who have turned up at the event. Amazing as it seems this idea is not new, this format of conference is known as an “unconference”.

One such unconference is known as “OggCamp” and it occurs every year in the UK. You turn up to face a blank conference schedule and a bunch of post-it notes with a marker pen. To offer a talk is simply a matter of writing it on a post-it and placing it under your preferred slot as below…

The unconference takes shape... ticks signify votes for talks offered on post-it notes.
The unconference takes shape… ticks signify votes for talks offered on post-it notes.

There are a variety of talks “slots” so some pople talked for 20 minutes, some for 45 minutes and there was a special slot for “lightning talks” – no, not talks about the atomoshperic electrical disturbances :) they are… well check the image caption below for an explanation.

Lightning talks are short talks lasting no more than 5 minutes with only one audience question allowed. It's an oppurtunity for some "off-the-wall" topics but the ones here are all pretty standard :)
Lightning talks are short talks lasting no more than 5 minutes with only one audience question allowed. It’s an oppurtunity for some “off-the-wall” topics but the ones here are all pretty standard :)

I went to the most recent OggCamp in Canterbury and this article blogs my experience about it.

img_20170819_100102948

Firstly, I cannot write this article without mentioning the amazing host city of Canterbury – it has such amazing character and some of the streets look like they are out of Harry Potter. There are names like Sun Street, Mercer Lane (a “mercer” is an old English word meaning “trader in textiles”), Butchery Lane and St Radiguns Street.

img_20170819_201310863

img_20170818_204023225

img_20170819_224951583

There is the famous Canterbury Cathedral of course (which incidentally seems like a sister cathedral to the one in Winchester) but arrayed around it are various Roman-era walls and forts through and under which modern 21st century roads still run! It was a eye-opener driving into the city for the first time. We had really good weather that weekend and I must have done ~5 hours of walking around the city and venue at Canterbury University. Of note is one metal bridge over the river Stour between where I was staying and the city centre – I have coined it the “Bat bridge” because during the evening I was treated to a frenzy of flying bats making the most of a plentiful supply of insects hovering in clouds under the trees!

img_20170819_200606134

Back to OggCamp – the talks mainly feature on what is known as “free culture” – what that means is any creative work that is shared in an open or free manner. One famous example is the Linux operating system but there are a wide ranging as are the talks.

img_20170819_141707198

The stand-out talks to me were one guy who made his own programmable dance floor made up of hundreds of home-brew LED lights with a ping-pong ball acting as a diffuser. Another was a project called matrix.org which seeks to create a two-way bridge between different forms of communication networks (eg. Slack and Telegram). Yet another was on how to keep mentally healthy in a digital world.

img_20170819_161854607

The attendee’s tend to be an interesting lot too – there are  children, semi-retired people, slightly awkward middle-class white male nerds and among them are some friendly, pleasant and really likable dudes (hello Tom if he’s reading this! I watched “Logan’s Run” and “Ex Machina” as you recommended). This to me is one of the reasons to go – to be among decent quality people of a like mind who share some deep interest in this amazing free culture movement. The sharing of ideas and cheerful chats over a beer, lunch or just a coffee while waiting for a talk to start.

My talk went well with it being shown in the main auditorium (photo below) so I had a massive projector screen and premium sound system with which to showcase our work on Project Nemo.

The translation project talk was not all my own work. I have to credit the project leader, “DragonSpike” for his support and time in my preparation for the talk – he not only spent time helping me refine my slides but also put together a special game-play video to showcase the translation work of the International Edition. I salute you sir! Check out the project blog for his thoughts and musings on the project.

Here is my mid-flow talking about Project Nemo. If AC3 were real, I would have Rena, Erich, Fi and Cynthia sitting in the colour-coded seats behind me. Dision would have been invited but the military prison would not have given him a day release :/
Here is me mid-flow talking about Project Nemo. If AC3 were real, I would have Rena, Erich, Fi and Cynthia sitting in the colour-coded seats behind me. Dision would have been invited but the military prison would not have given him a day release pass :/

One observation about OggCamp is that I was encouraged to see female attendees and some non-white folks too – I feel this is important to promote these kinds of events and culture as “open to all” and hopefully to discourage a homogeneous population.

Canterbury University campus grounds - this looks like the kind of place they would film an episode of Star Trek: The Next  Generation
Canterbury University campus grounds – this looks like the kind of place they would film an episode of Star Trek: The Next Generation

The venue was excellent – it was Canterbury University. All the three talk rooms were close to each other and accomodated everyone who wanted to attend. Each had good working audio-video and there was always a crew member on hand in every talk. Very well-run and professional indeed.

I also discovered that the canteen was opened just for the event and we benefited from a hot meal both days – yumza!

In terms of people numbers, I think I detected a smaller number of folks compared to the last one I went to in Oxford. I would estimate 150 people. I think the location was a factor and the fact that some of the bigger names in the podcast/Opensource scene (eg. Linux Outlaws, LUGRadio) were not in attendance.

So a big, big thanks to John “The Nice Guy” Spriggs, Mark Johnson and the rest of the crew at OggCamp for such an amazing event. <austrian accent>”I’ll be back.”</austrian accent>

All in all a very enjoyable weekend and I want to thank my AirBnB host Paul for making a comfortable stay for me. Check out his property if you’re ever staying in Canterbury.