How to flash a custom recovery with heimdall (without touching the main system)? The first recommended step in the installation of CyanogenMod on Samsung Galaxy S is flashing a custom recovery like ClockworkMod or the one from Replicant with a command like:

heimdall flash --kernel path/to/recovery.img


Now I feel that the instructions might be misleading:

I have done the first step wanting just to have a custom recovery mode, without proceeding to replacing the main OS on the device.

It seems I have done that wrong, because the device now always boots into the recovery mode.

What would be the correct heimdall command to just install a custom recovery system without touching the main system?
It depends on your PIT partition file.

Before you do anything using heimdall, print the partition table of your phone. 

sudo heimdall print-pit


The output of the file is the location assigned to each partition. For example on my Galaxy S3, I have something like this:

--- Entry #20 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 19
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 491520
Partition Block Count: 32768
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: Kernel2
Flash Filename: recovery.img
FOTA Filename:


Now this tells me 3 main things:


Name the flash file: recovery.img
Location of the identifier 19
And finally the name of the recovery partition Kernel2


What does this means?

This means if I want to flash a recovery image I should use either the identifier 19, or the name Kernel2.

sudo heimdall flash --19 any-type-of-recovery.img


or 

sudo heimdall flash --Kernel2 any-type-of-recovery.img


Bottom Line: Look at the pit file to figure out where to flash your recovery.

Cheers,
Mel