Zwede hit the high points.
The individual mold starts with “cores”- these are molded from sand, mixed with binders like olivine or fuller’s earth and other substances to get it to retain a shape when dry, and resist the temperatures involved with casting.
The cores are pressed in simple dies, dried, and then “stacked” to represent the inner voids of the finished mold, around the more permanent exterior parts, which can be large steel mold halves. (Or can be sand molds as well.)
The molds- many hundreds of them- are run through to the foundry, where molten iron is poured in through openings called “gates”. The gates act as funnels to not only let the iron pour in, but also gasses and air to rush out, so no voids or incompletely-filled areas are formed. Gates are often poured much past “full”, so the additional metal acts as a contraction zone- when the main casting cools, the metal contracts considerably. The “gates” provide a little extra metal for the contraction, so the casting doesn’t warp or have thin spots.
Aluminum castings, like wheels or engine blocks, need rather considerable shrinkage gates due to the large density difference in “molten” and “cool” states.
The molds are typically allowed to cool fairly slowly, and are then broken open. In the old days, men with small pneumatic jackhammers and pry bars broke the sand off and scraped it out of the voids, but these days, they have huge “tumblers” that crush and crack the exterior sand, and various pressure-blaster devices for getting the sand out of the voids.
Sometimes the sand is reused, sometimes it’s not.
Once the raw casting is open and clean, the waste sections and gates are cracked off or machined off, the casting is inspected, and then sent to the machine area where the decks and transmission mating surfaces are machined, cam gallerys are bored, and so on.
The voids molded in form the water jacket, the cooling sleeves. But oil galleries are drilled into the casting, since they need to be smaller and to much greater precision.
Cast iron also tends to be porous- I’m not sure if it’s still done, but I’ve heard of old-time use of a substance called “water glass” which was swished around in the gallerys and jackets and which, when dried, would plug microscopic voids in the casting.
Fresh castings are called “green”, and can “move” as they age. IE, they can warp ever so slightly as internal stresses pull in various directions, due to thicker masses of iron at various points. Thus, most semi-raw castings are “aged”, typically in a large heat-cycle kiln (alternating hot and cool cycles) or even on devices like vibratory tables.
Old-time lathe and machine tool manufacturers would gin up the green castings, then set 'em out in the yard for a year or two. The natural daytime temperature fluctuations, and the seasonal overall temperature range change, would do the “aging” quite well.
This way, when the castings were machined, decks, for example, would remain parallel to the crank centerline, the bores would remain perpendicular to the crank, and so on. Bore concentricity was the big thing- bore a perfectly round hole in a green casting, and a year later the hole might actually be slightly egg-shaped.