I'm creating a "bare bones" livecd linux distribution as a hobby. Currently it boots into ram (copies the contents of an initrd file into /dev/ram0). Now, at the moment it uses almost 12mb of ram space uncompressed. This is not what we want especially in a low resources situation. This isn't how a livecd works anyway.

Here is what I want it to do:
1. Boot (using grub) with an initrd file that uses about 5mb.
2. Then, detect where the cd is e.g /dev/sr0 etc
3. Using UnionFS mount the uncompressed contents of the cd on /

I can do all except number 2. Can someone please advise me of a shell script (for bash) that can detect where the cd is located.