Random musings of a Geek

Downgrading Nexus 2012 to Android Kitkat (4.4.4)

Versions of Android later than Kitkat (4.4.4) seem to run really slowly (even after factory reset) on my Google Nexus (2012 version) tablet. So after some reading of the Google docs I downgraded to Kitkat.

Here are the steps I took in case anyone else needs to do the same. Note this will wipe all your data so make sure everything is backed up first.

  1. Install android tools with sudo apt-get install android-tools*
  2. make a folder called android to store images in your home directory
  3. Download KTU84P from https://developers.google.com/android/images to ~/android, I also downloaded the image my tablet was currently using so I could revert if neccessary, which was LMY47V (5.5.1)
  4. Extract the tar ball
  5. Enable USB debug mode in Android Developer settings
  6. Make sure your tablet is unlocked and powered on
  7. Run adb devices to check your device is listed (if not repeat above steps to enable USB debug mode)
  8. Run adb reboot bootloader to reboot your tablet into Android bootloader
  9. Run fastboot oem unlock to unlock the tablet so we can flash the OS
  10. Run ./flash-all.sh in the extracted OS directory (~/android/nakasi-ktu84p for me). This will install Kitkat 4.4.4 and reboot your tablet.
  11. Run fastboot oem lock, as a safety measure.

Enjoy your much more responsive tablet, and learn to not just trust upgrades in future :( I’ve learned it’s best to see what people are saying about the performance first when you’re tablet isn’t the latest and greatest version any more.

Change default browser in Thunderbird on Linux

Go to Edit -> Preferences -> Config Editor

Toggle the values of the following to true:


The next time you click on a link in an email Thunderbird will ask you to select a browser to use :)
Yay to Thunderbird for being completely awkward.

MySQL Replication Setup (using dump)

On the master, enable binary logging and set a unique server ID. Each MySQL server being replicated to must have a unique ID also. Modify my.cnf with the following, and restart MySQL.


On the Slave, edit my.cnf and add a unique server ID for the slave.


On the master, add a user for replication that has the ‘replication slave’ privilege. This should be a separate user that can only be accessed from specific hosts, for security purposes. More info at http://dev.mysql.com/doc/refman/5.1/en/replication-howto-repuser.html

Get master bin log coordinates and lock tables to prevent changes whilst synching…

Start a session on the master and run:


Using a different session, run SHOW MASTER STATUS to get the current bin log file name and position. Note these down as they are used in the ‘CHANGE MASTER TO’ slave statement later.

On the master, dump the database you’re wanting to replicate and scp it to the slave server.

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
| mysql-bin.000003 | 73 | test | manual,mysql |

mysqldump': mysqldump -u root -p TheDb > TheDb.sql
scp TheDb.sql [email protected]:

On the slave, import the DB dump from the master:

mysql -u dbuser -p < TheDb.sql

After that, run a ‘CHANGE MASTER TO’ statement:


and then start replication with:


You should now exit the session on the master that was locking the tables (or use the unlock tables statement).

Replication should now be setup

Repairing GRUB

Here is how to restore your GRUB MBR after installing Windows 7 (or any version for that matter).

  1. Grab a boot CD of Ubuntu and boot it up
  2. Open the terminal
  3. > sudo grub
  4. If you have a none standard installation (multiple installations of linux or weird partition setup) then use:
    > find /boot/grub/stage1 to discover where your root should be
  5. > root (hd0,0)
  6. > setup (hd0)
  7. > quit

reboot :)

I personally have 2 different flavours of linux installed and my root happened to be 0,4 and 1,4 as I have 2 drives and each install was on a different partition of each drive. I would recommend choosing the one that you boot into most frequently – as when you install new Kernels etc via apt it will auto configure GRUB for you.

Batch converting PSD images in linux using ImageMagick

I found myself wanting to batch convert a load of psd files to jpegs today, so I went about looking for a way to do it via the command line.

The tool I chose was Imagemagick. At first I was going to use the tool ‘mogrify’ but it doesnt seem to support the -flatten parameter even though it says it does in the manual… hmmm. The flatten param is needed when converting a psd because of course the psd is multi layer so if you try convert to jpeg without flattening it will generate a jpeg for each layer.

I opted for the standard ‘convert’ command with a little bash magic. The following little script will process all psd files in a folder to jpeg files. You could easily change it to pass in more parameteres etc.


if [ -z “$1″ ]
echo “Usage: please specify a base directory”
exit $E_NOARGS
fi for file in $1/*; do
/usr/bin/convert -quality 80 -flatten $file ${file/psd/jpg}