When experimenting with dracut custom initrd builds for Linux to support Dell megaraid, I came across some errors. If you're using dracut to build an initrd for a different system, you may need to add hostonly=no to your command line arguments.
Without this approach, you may get errors such as
root@localhost # dracut -N -f --add-drivers "sunrpc" ~/foobar3.img
`dracut module 'anaconda' cannot be found or installed`
(even though dracut --list-modules | grep anaconda
shows the module to be available).
e.g. you could instead use the below successfully
root@localhost # dracut -N -f --hostonly=no --add-drivers "sunrpc" ~/foobar3.img
You can also add some of these options to the dracut.conf file (useful if repeatedly performing the same rebuilds, iterating through lots of experimental builds etc).
e.g.
...
add_dracutmodules+="anaconda nfs network base"
# additional kernel modules to the default
#add_drivers+=""
add_drivers+="/usr/lib/modules/`uname -r`/extra/megaraid_sas/megaraid_sas"
...