trapped in "initramfs" prompt?

initramfs
Lately I was trapped in the "initramfs" prompt on a server that was rebooted. The reason for it being stuck there was obivously some hdd change due to raid failure/rebuild. After panicing for a few seconds I tried to fix the situation. I tried two different approaches. Depending on your personal situation one or the other might suffice. One situation could be solved by:
Activate LVM from initramfs prompt
# lvm vgscan
# lvm vgchange -a y
# mount -t ext4 /dev/primary_vg/root_lv /root
# exit
(Note to myself: LVM can be enabled/activated in initramfs> prompt if this is the only issue that prevents the system from booting)

Now for the more complex "the ramdisk did not recognize my md-raid right"-situation:
Assemble MD-Raid from initramfs prompt
# rm /etc/mdadm/mdadm.conf
# mdadm --assemble --scan
# mount -t ext4 /dev/md127 /root
# exit

Worked and got the system booting, but I couldn't quite fix the initramfs from there. So I restarted back into some rescue system and finally did the following:
(starting from "initramfs>" prompt)
Fix broken initramfs from rescue system
# mkdir /target
# mount /dev/md0 /target
and depending on your partitioning: # mount /dev/md1 /target/boot/
# mount -o bind /dev /target/dev
# mount -o bind /dev/pts /target/dev/pts
# mount -o bind /sys /target/sys
# mount -o bind /proc /target/proc
# chroot /target

Finalizing with:
# update-grub
# update-initramfs (maybe with opts: -k -t or -u)
Test it by rebooting, and finished.