I heard that the vikings used to carry dried cods with them for food. How did they prepare these? I can't imagine them simply nibbling on them for the entirety of their journey (unless they had absolutely nothing else to eat). Did they cook them in any ways?
Well, there are no written documents from Viking Age Scandinavia, and since nobody carved their favorite cod recipe into a runestone, we've got no definite evidence, which is usually the case. The best we can usually do then is to extrapolate back from the Scandinavian Middle Ages. (corresponding to the European High-Late Middle Ages, because we've inserted the Viking Age c800-1050)
First, let's talk a bit about salt. There are no natural salt deposits in Scandinavia, with the possible exception of the tiny Danish part of Friesland (which I'll get to). The Baltic Sea is bracken, a mere 0.8% salt versus about 3.5% in the Atlantic. But the climate on the Atlantic coast is temperate at best and wet, evaporating salt in the open is a non-starter. So the only 'domestic' method of producing salt is by boiling seawater, which requires an abundance of wood to be possible, and is labour-intensive. A clue this method was in use already during the Viking Age is in Egil's Saga, (written at latest the early 13th century but depicting events supposedly happening centuries earlier) which says that after Harald Fairhair conquered Norway, all the "saltkarlarnir" (salt men) among some other professionals owed him allegiance.
The wood supply would be too small in present-day Denmark and so we're talking about Norway and the Halland coast of Sweden, which was Danish then. Kong Valdemars jordebog of 1231 mentions taxes being paid in salt in Halland, which implies salt production. The Swedes, or rather the Västgötar only held the mouth of the Götaälv river (present-day Gothenburg) and were out of luck and had to import, as did most Danes. During the Viking age Western European salt trading was in full swing. Medieval Scandinavian records commonly list two kinds of salt "trave salt" coming from the Trave river, i.e. Lübeck and ultimately the Lüneburg salt works, and "Baie salt" from the Baie de Bourgneuf on the French Atlantic coast. Smaller amounts were also produced in Frisia by burning salt-containing coastal peat and seaweed to "salt ash". Which in the Middle Ages seems to have been referred to as "ryber solte" in Low German, after Ribe in Denmark (southwest Jutland, near Frisia). This salt isn't referred to so much despite apparently being valued at less than half of what other salt cost - so the salt ash was clearly considered an inferior product. There's also a reference to "Vinland traveller salt" (vinlanz faru salt) which I'm afraid is extremely unlikely to have anything to do with the Vikings who went to Newfoundland, and is more likely a reference to France and thus the Baie salt.
So salt was imported and/or produced from labor-intensive boiling or peat burning. It was big business for the Haneatic League later and a major import for the Scandinavians, even estimated at 25% of Sweden's entire imports by the late Middle Ages. Much of which would be re-exported in barrels of salted herring. (You need a barrel of salt for three barrels of herring)
What this all boils down to (ooh witty) is that salt is believed to have been quite sparingly during the Viking age. Drying fish with salt (klippfisk) did not become commonplace until the early modern period, when imports had gotten cheap enough. So methods used include the drying you mention. But there's drying with salt and there's drying without salt, and the old Scandinavian way then was to dry without salt - producing what's called stockfish, which is not the dry salted cod you might be thinking of, but a product of both drying and fermentation. There are drying racks all along the Norwegian coast. As far as we know it's probably produced the same way (it's such a simple process) but I believe the first depiction of the process it is in Olaus Magnus 16th century Historia de gentibus septentrionalibus.
This process doesn't as well for oily fishes like herring, mackrel and salmon. The ways those were preserved, using little or no salt, was primarily smoking them - and there's archaelogical evidence that there was plenty of fish-smoking going on during the Viking Age. (we're less sure if it was hot smoke to dry the fish, cold smoke to cure it, or both)
The other method would be fermentation. This survives in various forms like the infamous Icelandc hákarl , Norwegian rakfisk, Swedish surströmming and the pan-Nordic gravlax. Hákarl is produced by burying shark in the ground, while gravlax ( grav = grave, ditch, lax = salmon) was originally produced in a similar way as the name implies, but is a different dish now.
Rakfisk and surströmming are fermented with salt, but far less salt than would stop all decomposition. There's a story in Sweden that surströmming came about because of a salt shortage during Gustav Vasa's reign, leading people to try to use less salt. This is a myth. Salt was after all always in short supply and surströmming existed already. A notable person from Umeå in Vasa's day was Erik Ångerman Sursill (Ångerman because he was from Ångermanland, and the nickname 'Sursill' means 'sour herring' i.e. likely surströmming - 'sill' and 'strömming' are just dialectal variants for herring). Sursill is known because they've traced thousands of people in Finland as his descendants in the work 'Genealogia Sursilliana'. (a title that's a wonderful mix of haughty Latin and the somewhat-derogatory Swedish nickname)
Another figure I mentioned in a post recently is the Norwegian Olaf Gravlax mentioned in a letter in 1348, and that would be referring to the older kind of gravlax. It's possible surströmming and rakfisk are this old - but that may depend on how you define them. In any case, fermented fish of some form along those lines probably existed in the Viking Age.
How did they eat it? That's one of those "everone knows" kind of things that nobody writes down and so nobody know centuries later. But we do have an medieval eyewitness account of preparation and eating of stockfish from the Venitian Pietro Querini, who was shipwrecked off Lofoten in 1432. Here's his account. (p148, 'I stochfisi seccano al..). Having now looked up the obscure Venitian words like 'manara' it reads something like (my apologies in advance to Italianists):
The stochfisi is dried in the wind and sun without salt, and because these are fishes with little fat-moisture(? humidità grassa ) they become hard as wood. When they want to eat them, they beat them with the back of an axe so they become thready like nerves, then add butter and spices to give flavor.
It's not exactly a recipe but it does give an idea, and tells you it's not a long procedure as with preparing lutefish from dried fish. Speaking of lutefish, despite being a uniquely Norwegian-Swedish-Finnish tradition now, the origins of that dish are thought to be north Germany around the late middle ages. Not all weird Nordic fish dishes have Viking Age or even Scandinavian origins.
So stockfish, and dried/smoked fish certainly existed in the Viking Age, as did fermented fishes along the lines of hákarl and what gravlax used to be. Surströmming/rakfisk is medieval at the latest. Dried and salted fish (klippfisk) on the other hand was introduced to Scandinavia only in the 17th-18th centuries.
Mind you, stockfish is edible as-is too. You can get it as a snack in Norway). (If you're in the mood for something all-natural, protein-rich and disgusting-tasting) The fermented fishes are eaten essentially as-is (not cooked) too, with some garnish.
The one thing I've not mentioned here is the rather obvious option of reconstituting dried fish by boiling or soaking it. That'd done today, and the lutefish process also involves that, but I just don't know a medieval account of it. If I'm allowed a tad of speculation, it does seem like a less likey preparation option for men on a boat with a limited water supply though.
So there do not exist any specific recipes we use today. (nor reconstructed ones like people have done with garum ) You can't say any specific fish is a 'viking' dish, but you can say that the present stockfish, smoked fish and fermented fish traditions evolved out of practices that go back to the Viking Age (or further).
Some sources:
Pietro Querini's account in Ramusio's Delle navigationi et viaggi, linked above.
Hugo Yrwing, Salt och saltförsörjning i det medeltida Sverige (Scandia 1968, s. 219-242)
Alfa Olsson, Om allmogens kosthåll, 1958