Gemini 5 was NASA's first real long-duration mission. In August of 1965, Gordon Cooper and Pete Conrad spent eight days in orbit testing their spacecraft's fuel cells to make sure this new technology was up for the minimum length of a trip to the Moon. Between the two astronauts, they had four bowel movements during the flight. It wasn't pretty, and it didn't get prettier throughout the Apollo era.
Al Shepard sealed in Freedom 7
Waste management was a bit of an afterthought when the space age started. Waiting for his Redstone to launch on May 5, 1961, astronaut Al Shepard famously (or perhaps infamously) wet himself. The mission was slated to last just fifteen minutes, so mission planners reasoned he would certainly be able to hold it for a quarter of an hour. The problem NASA hadn't foreseen was that Shepard was sealed in his Freedom 7 capsule for hours before the short flight. With no urine collection system on board and no way to get him out of the spacecraft without significantly delaying the launch, Shepard was forced to urinate in his suit. He lay in his waste until the suit's cooling system evaporated the liquid.
After Freedom 7, urine collection improved. The astronauts could use simple bags to store the waste and, being a liquid, it was easy to jettison from the side of the spacecraft. Fecal containment was another matter.
The Gemini missions were the first missions long enough that astronauts would need to defecate, in spite of low-residue diets designed to minimize bowel movements. The fecal containment system, properly called a defecation device, was a rudimentary solution to this need. It was a cylindrical bag about a foot long with a 1.5-inch opening on the end covered in an adhesive. The bag came with wipe and a material that would kill bacteria and neutralize odors when added to the waste. This was an important part of the system since there was no provision to jettison solid waste. The astronauts had to store their filled defecation devices on board the spacecraft for the duration of the flight. The stowing problem was actually the biggest challenge on Gemini 5.
But there were others. We don't think about it on Earth, but gravity plays a part in defecation, namely in separating the waste from the one producing said waste. In space, everything is falling at the same rate giving the impression of floating, so waste that would fall away from the buttocks on Earth doesn't separate from the buttocks in space. To circumvent this problem, NASA added a little extension in the defecation device to help the astronauts with the separation issue. The extra material gave them a clean way to manually flick waste away from their bums.
Adding to the indignity of the act, the physical act of defecating in a bag was difficult. On Gemini flights, the defecating astronaut couldn't give his companion too much distance from the bowel movement; the spacecraft was about the size of the front seat of a small car. On Apollo missions, the astronaut needing to move his bowels would float his way into one corner while the other two men would move as far away as possible. He'd typically strip completely nude, removing rings and everything. Water was limited on board so washing fecal matter from clothing was impossible. Then he'd stick the adhesive opening to his naked buttocks and use the facilities. The whole exercise from stripping down to redressing could take more than an hour.
The Apollo fecal containment system
National Air and Space Museum, Smithsonian Institution
And it didn't always go according to plan. Rogue waste terrorized Apollo 10 on their trip back from the Moon.
LMP Gene Cernan: Where did that come from?
CDR Tom Stafford: Give me a napkin quick. There's a turd floating through the air.
CMP John Young: I didn't do it. It ain't one of mine.
LMP Cernan: I don't think it's one of mine.
CDR Stafford: Mine was a little more sticky than that. Throw that away.
CMP Young: God almighty.
All three: (Laughter)
Of course, being on the Moon doing an EVA meant an astronaut couldn't strip down to defecate in a bag. During lunar sojourns, the astronauts wore a fecal containment subsystem as part of the personal hygiene equipment. It was, in essence, a diaper. Similarly, spacewalking astronauts on shuttle missions and aboard the International Space Station can't exactly strip down to go. So they wear what NASA calls the maximum absorbency garment, which is also basically a diaper. But astronauts try not to use it, preferring to use an actual toilet.
Al Shepard's Moon diaper
National Air and Space Museum, Smithsonian Institution
With the dawn of the shuttle era, fecal disposal became much more sophisticated and more complicated. The first space toilet used a slinging mechanism to separate solid from liquid waste, the former being vacuum-frozen and stored while the former was jettisoned. And because this toilet was meant for astronauts of different shapes and sizes, NASA had to take all kinds of things into consideration designing these modern facilities.
One 1973 study for a space toilet considered the effects of pubic hair and labia in cleanly separating urine from female astronauts: "The residual urine remaining on the female vulva area with the 40 ft/sec air velocity will be removed by the use of tissue wipes. The residual will be relatively easy to wipe with a tissue because the pubic hair and the recess of the labial folds act to contain the small amount of residual in the area. The action of the pubic hair in containing the residual precludes any necessity to shave the pubic area." The same attention to detail went into the diapers. Technicians had to consider the average growth rate of pubic hair and the relative placement of genitals between men and women in creating a unisex diaper.
As sophisticated as modern space facilities are, bags are still on board the space station just in case the toilets break. Because they can break. On STS-1, the very first shuttle mission, a problem with the toilet left freeze-dried fecal material floating through the spacecraft at the end of the mission. Not the best way to come home from orbit, eh?
Sources: Swider, Waste Collection Subsystem Development; NASA, Habitability Data Handbook Volume 6 Personal Hygiene; Charlie Duke "Moonwalker"; Apollo 10 transcript; Gemini VII mission report; Smithsonian; Megan Gannon on Space.com; Stapleton et al, Development of a Universal Waste Management System.