For long voyages, how was water transported and/or desalinated?
My answer will focus mostly on the Age of Exploration ships and expeditions in the 15th and 16th century.
One of the first options was to just fill enough barrels and casks and jars in the hold and keep them like that for most of the voyage. The amount of water carried would vary from voyage on voyage, but could be large and enough to cover multiple months which was enough for most of voyages, like the ones between most European ports, or even between Europe and North America. But not for all.
We have surviving orders given to Cabral in his 1500 voyage to India that upon reaching Santiago island in Cape Verde:
if at the time that they arrive there, they have sufficient water for four months, they need not stop at the said island, nor make any delay, but when they have the wind behind them make their way towards the south
When they reached the said mark, the fleet proceeded without stopping which would indicate they deemed they had at least 4 months worth of water. Luckily for them (and the Portuguese king) this wouldn't be tested as they stumbled upon Brazil. There, the fleet stayed for some time, with some of the crew surveying the land and interacting with the locals, while others were occupied by the important task of collecting wood, water, food and other supplies.
Collection of "wood and water" was a regular and common activity when a ship would reach land, especially if it was far from a friendly resupply port. Water is obvious why it was needed, but wood was actually almost equally important. The "wood" mostly meant was firewood for cooking, and only to a small degree wood for repairs, although that also was commonly collected. Of course, whether or not the ship(s) would stop and resupply depended on multiple factors not least of each is if it was considered safe enough to spend few days filling the barrels at a water source, and ferrying them back and forth from beaches to ships via boats.
The above shows the most common method of acquiring water - landing and filling water from a direct source. Of course this is worth nothing if there is no land in sight. Then the options were limited, but one often used was to collect rain water to fill the barrels. We have multiple references to rainwater being used in our sources. For example in the return leg of the same above mentioned Cabral's expeditions, ships separated and one caravel traveled alone for some time, during which time it ran out of water. It had too few men to risk and accomplish landing and resupplying so they proceeded as they could. Their chance reunion with the fleet was described:
And thus the ship came with only six men, most of them ill, and they had nothing to drink but water which they collected in the ship when it rained.
The above is far for only such story. Especially interesting is Portuguese friar’s Francisco’s Alvarez experience on the return from Indian Ocean (Abyssinia to be exact) to Lisbon in 1527.
In the south Atlantic his ship missed the resupply island of St. Helen, and was dangerously close to running out of water. Francisco describes the events:
The two ships which had left us fetched the said island, and we on Easter Sunday, which was the 21st of April 1527 ran by the island in the night which ended on Monday. And as at midnight, a little more or less, there came a heavy shower, some said that then we ran by the island, because the shower came from the land; others said that it was still a-head of us. We remained some days in this doubt, until we saw signs that we were beyond the island, and we ran very short of water ; already we did not boil anything from want of water. Here the Lord succoured us with his mercy, giving us three days and three nights heavy rain during which much good water was taken. They took thirty pipes of water for the ship, and for me they took three, and so also each one took what he wanted in whatever he had got, and we remained with abundance of water. From this time forward we made our usual meals.
So according to our source, the ship managed to collect 30+ pipes of water in 3 days and night heavy rain. Pipes or pipas were barrel containers which in year 1800 (not very close, but closest I have) were about 570 litres. According to some resources 30 pipas amount would be roughly enough for about 30 days water for around 200 people. Both the value of pipas and the numbers for my calution came from Filipe Castro: Outfitting the pepper wreck. PDF source.
The best references for use of rainwater come from Spanish expedition of Pedro Fernandez de Quiros in the Pacific at the end of 16th century, start of 17th. Quotes:
STILL with a westerly course we proceeded, with much anxiety arising from the confusion in determining the distance of our ships from the port of Lima, and still more owing to the allowance being so short that neither our thirst was quenched nor our hunger satisfied. At last God sent us a good shower of rain, and plenty of water was collected.
WITH the wind S.E., which had now broken its fury, they continued to navigate until the eve of St. John the Baptist. On that day God was served by giving us a great shower of rain. With twenty-eight sheets stretched all over the ship, we collected, from this and another rainfall, three hundred jars of water : a relief for our necessities, and a great consolation for all the people.
In this part, in a higher latitude, we had some rain, especially one shower, which filled all the jars that were empty, and it was drunk without doing the least harm, nor did it ever get bad. In short, after God, the rain showers saved our lives.
Final reference of rainwater usages is in the next pages and it mentions in short both the collection of rainwater ( in maybe not such a dire situation) and men fishing and catching fishes on their voyage:
On the 5th we had the wind aft and ran before it, with an E. course, for nearly three days, then more northerly as far as 25 N. This day, which was that of St. Lawrence, they collected from a shower of rain fifty jars full of water, Certain albacore and bonito, in a large shoal, had hitherto followed the ship, and every day the men fished with nets, fizgigs, and harpoons, catching ten, twenty, thirty, even fifty, some of them weighing 3, 4, and 5 arrobas. We ate them fresh, and salted them down, filling many jars. About 2,500 arrobas^ of fish supplied the place of meat, and lasted until we reached the port of Acapulco, with some over.
The above passages show that the crew of a ship could collect rainwater in case of rain by spreading sheets to collect rainwater in their jars, and that quite a lot of water could be gather that way.
However it seems collecting rainwater was not a standard procedure each time there was rain, but more of an emergency measure in dire situations, and depended again on the luck of the weather.
The above mentioned voyage of Pedro Fernandez de Quiros also introduces another part of your question: desalination.
That expedition carried an experimental desalination device, which burned wood to distill and condense water. The machine worked for several days, creating barely enough water to cover drinking needs of the reduced ration, and definitely not the full ration that covered the needs of water for cooking and other usages. Despite this, the opinion of the device was positive, but as noted it needed improvement of efficiency. It burned too much wood to get small amounts of water, and in the middle of the ocean wood was equally hard, if not harder, to get by as fresh water was. You could possibly cannibalize the ship, but it was a very short term prolongation of the inevitable.
Here is the full excrept from the log:
The Captain, considering that on all these seven newly- discovered islands neither a port nor water could be found, and finding that there were fewer water-jars than he ordered to be embarked, he made some discourses with respect to the time and the present state of affairs, and deemed it necessary to reduce, as he did reduce, the allowance of water. Twelve or fifteen jars of water that were consumed each day he reduced to three or four jars. He was present when it was served out, saw the hatchway closed, and kept the keys.
Presently he ordered a brick oven to be built over one of the hearths, in order to make sweet water from sea water, with a copper instrument he had with him, by means of distillation. They got two or three jars full every day, very good and wholesome. On the least productive day there was a jar and a-half, and altogether fifty jars. This inven- tion, with certain improvements, promises, with little expenditure of fuel, to turn out in fifteen hours eight, nine, and ten jars of fresh water, and more if it is necessary.