Many of these proposals are very complex, so I would just like to indulge myself. This is not quite thermodynamically viable, but then, photosynthesis is rarely more than 1% efficient in nature on the surface. For underground crops to be viable with only 10% of the population devoted to production, we have to fudge a little.
I think it would be reasonable to require one season out of the year of your underground farm to be fertilized for the other three to grow, prompting a 'crop rotation' mechanism that we presently don't see. Land needed to lie fallow on the surface before industrialized agriculture, and bringing that mechanism into play would help address the realism problems.
Two resources are heaping up in my fortress without a use for them, and one resource would make me nearly surface-dependant. They are bones, chunks, and trees. Bones are made out of minerals; calcium, magnesium, sodium, potassium; ect. Bone is presently an economically valuable material for carving, decorating and weapons manufacture, however, bone meal is also listed in the stockpiles. I have never found bone meal, but I do see a use for it as a mineral-rich base for a fertilizer.
A second resource is chunks. We all get chunks, have no use for them, and their disposal is largely a nuisance to be solved with magma or really deep pits. I propose instead that chunks be a vital element of farming as the source of compost. Chunks require no processing, only the time needed to rot. This requires underground storage of chunks and careful design to allow for miasma. For example, a vertical shaft could be dug next to your butcher's shop, then all chunks thrown down the shaft as the nearest garbage dump. At the bottom they fester into rotten chunks. A new zone designation, 'Compost site' (for the compost stockpile) or 'Compost dump' (for a dumping shaft that doesn't flag items forbidden) could aide this as the automatic handling of chunks (and anything else that rots, which would be a handy way to recycle rotten plump helmet roasts). Rotten chunks would then be gathered in a later step.
Potash is already used as a fertilizer, so naturally its inclusion in underground farms is mandatory. The wood/ash/potash chain is one I've yet to master, mostly because it can be utterly bypassed. One never runs out of farmable land, and rarely runs out of peasantry, thus yields do not need to be increased per tile. Potash provides potassium or phosphate, I don't recall which; but they're very important to plant growth on the surface. However, we're talking about the underground. Photosynthesis is not being used, as it is only 1-2% efficient on the surface in natural conditions. Underground it would be meaningless. So while potash may be the only fertilizer needed for surface farming (and requiring fertilizer or two fallow seasons every year for the surface would be nice too, I think) it becomes another agent of the final product.
And that final product is created in the poor, neglected Farmer's Workshop. 'Make Fertilizer' would prompt a dwarf to gather potash, a rotting stack of chunks, and a unit of bone meal into the workshop. There little Urist mixes the whole foul concoction up with a butter churn until its properly rank, and stores it in a Fertilizer Barrel. These get stockpiled up and can be viewed as a direct measurement of your ability to resist siege. After a few seasons, one of the fields are designated for fertilizing and Urist heads back out to fertilize it. One barrel full of fertilizer should be enough for a 3x3 plot or so. Once the fertilizer is sown, the plot remains unusable until after the season has fully passed since this goo has to seep into the existing substrate of mud. Should a field not be fertilized for three seasons, the field will be listed as BARREN with the Q key.
This proposal solves several problems. First, rotting, spammy chunks from our cat butchering industries can go to good use. Creatures not flagged as butcherable cannot have their chunks used, as this may constitute cannibalism and could endear us to elves. Secondly, bone spam (if your dining hall looks like my dining hall, and that's just from my two fisherdwarves, its universally a problem) is removed through productive labor rather than the export of semi-worthless bone trinkets or endless heaps of *<<crap>>*. Balancing your bone crafts and bone-milling would become another fun challenge. Third, the productivity of an underground farm is slashed by 25% while demanding a supporting industry. The agricultural revolution was the movement of the majority of a population from agriculture to industry; presently we're already past that point, which seems inconsistant with the feudal-fantasy setting. Fourth and last: the potential for fun little famines caused by players neglecting to oversee their food supply is enormous. With care this is as managable as the booze/food ratio.
Interestingly, the cons are also silver-lined. It is still possible to create an entirely self-contained fortress through the use of a cave river. The water provides mud, fish provides bones, tower caps provide potash, and slaughterhouse offal provides chunks (Gutting a fish provides chunks galore IRL). However, a fortress built completely around a cave river is not only incredibly dwarfy, but also susceptable to various nasties from down there.
Also hauling rotting materials around will cause a miasma problem, and needs to be an unhappy-thought job in and of itself (Urist was unhappy to haul festering buckets of gore around for minimum wage). The fertilizer-creating facility needs to be enclosed yet farm accessible, requiring thoughtful design. Also the composting dwarf needs to be looked after somehow, because nobody likes it when janitor's go postal.
Lastly, it may be possible to cheat the system. If a freshly constructed plot does not require fertilizing, then players can just deconstruct and refurrow farm plots when the fertility is used up. As a solution I propose that removing a farm plot replaces the 'muddy' tag with 'mossy', which is presently almost unused. Players now have to re-flood after removing a plot, which is quite a bit of work. Alternately, moss can be used to make carpeted peasant nap-time barracks, since sleeping on moss isn't as bad as a cavern floor.
And yes, fertilizer should be importable and embarkable.
And sure, fertilizer barrels explode, what with all the nitrates in there. "Load fertilizer" can be a new command on catapults.