How to flash your Samsung Galaxy S II Android phone on Ubuntu

Have you got one of those nifty Samsung Galaxy S II phones? Thanks to its Android operating system it works great together with Ubuntu out of the box. But what if you want to root it or use a custom MOD? For Windows there is ODIN to flash firmware, but what do you use on Ubuntu?

You use Benjamin Dobell’s Heimdall. It does not only work on Linux, Mac and Windows, but it is also open source. The code is available from GitHub.


When you want to install a custom MOD like CyanogenMod or MIUI, you need to have the ClockwordMod ROM Manager to install. That requires a rooted kernel anyway, so whether you just want to root your phone or do more, the initial steps are the same.

First you need to pick a rooted kernel. The XDA Developers forum forum for the I9100 is a good place to look. I always use the CF-Root kernel. It already includes ClockwordMod, so you don’t have to install that from the Android Market. Download the kernel here and install it. There are *.debs available. If you wish, you can use the frontend, but I have found the command line interface (CLI) to be more reliable.

Unpack the previously download kernel: you will end up with a file named ‘zImage’. That is your kernel.

Shut down your phone. Now start it in download mode by holding the home, volume down and power buttons down at the same time. Press volume up to confirm and connect your phone to your PC with its USB cable. Realise that your (extended) warranty is void once you’ve flashed.

Open your terminal of choice and navigate to the directory you unpacked the kernel image in.

Execute this command:

sudo heimdall flash --kernel zImage

After it is done, your phone will automatically reboot. Congratulations, your phone is now rooted!

If you want to use a custom ROM, now place the downloaded ROM archive on the phone’s storage, shut the phone down and launch it in recovery mode by pressing volume up and the home button during boot. Choose the ‘install from sd card’ option. Make sure you delete the Dalvik cache and user data before restarting, or your phone will be stuck in an endless boot loop!


If you want to restore your phone to its original state, you need the official firmware and a backup of your data you naturally made before starting. On the XDA Developers forum, a great person maintains a thread with a collection of official firmware.

Unpack the download archive, open a terminal and navigate to the resulting directory. There execute this command:

sudo heimdall flash --kernel zImage --cache cache.img --factoryfs factoryfs.img --hidden hidden.img --modem modem.bin --param param.lfs

Make sure you delete the Dalvik cache and user data before restarting, or your phone will be stuck in an endless boot loop!

  1. 12.2011

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.