Types

Early
Rudolf Diesel intended his engine to replace the steam engine as the primary power source for industry. As such, diesel engines in the late 19th and early 20th centuries used the same basic layout and form as industrial steam engines, with long-bore cylinders, external valve gear, cross-head bearings and an open crankshaft connected to a large flywheel. Smaller engines would be built with vertical cylinders, while most medium- and large-sized industrial engines were built with horizontal cylinders, just as steam engines had been. Engines could be built with more than one cylinder in both cases. The largest early diesels resembled the triple-expansion reciprocating engine steam engine, being tens of feet high with vertical cylinders arranged in-line. These early engines ran at very slow speeds—partly due to the limitations of their air-blast injector equipment and partly so they would be compatible with the majority of industrial equipment designed for steam engines; maximum speeds of between 100 and 300 rpm were common. Engines were usually started by allowing compressed air into the cylinders to turn the engine, although smaller engines could be started by hand.
In the early decades of the 20th century, when large diesel engines were first being used, the engines took a form similar to the compound steam engines common at the time, with the piston being connected to the connecting rod by a crosshead bearing. Following steam engine practice some manufactures made double-acting two-stroke and four-stroke diesel engines to increase power output, with combustion taking place on both sides of the piston, with two sets of valve gear and fuel injection. While it produced large amounts of power and was very efficient, the double-acting diesel engine's main problem was producing a good seal where the piston rod passed through the bottom of the lower combustion chamber to the crosshead bearing, and no more were built. By the 1930s turbochargers were fitted to some engines. Crosshead bearings are still used to reduce the wear on the cylinders in large long-stroke main marine engines.

Modern
A Yanmar 2GM20 marine diesel engine, installed in a sailboat.
As with petrol engines, there are two classes of diesel engines in current use: two-stroke and four-stroke. The four-stroke type is the "classic" version, tracing its lineage back to Rudolf Diesel's prototype. It is also the most commonly used form, being the preferred power source for many motor vehicles, especially buses and trucks. Much larger engines, such as used for railroad locomotion and marine propulsion, are often two-stroke units, offering a more favorable power-to-weight ratio, as well as better fuel economy. The most powerful engines in the world are two-stroke diesels of mammoth dimensions.
Two-stroke diesel operation is similar to that of petrol counterparts, except that fuel is not mixed with air before induction, and the crankcase does not take an active role in the cycle. The traditional two-stroke design relies upon a mechanically driven positive displacement blower to charge the cylinders with air before compression and ignition. The charging process also assists in expelling (scavenging) combustion gases remaining from the previous power stroke. The archetype of the modern form of the two-stroke diesel is the Detroit Diesel engine, in which the blower pressurizes a chamber in the engine block that is often referred to as the "air box". The (much larger) Electromotive prime mover used in EMD diesel-electric locomotives is built to the same principle.
In a two-stroke diesel engine, as the cylinder's piston approaches the bottom dead center exhaust ports or valves are opened relieving most of the excess pressure after which a passage between the air box and the cylinder is opened, permitting air flow into the cylinder. The air flow blows the remaining combustion gases from the cylinder—this is the scavenging process. As the piston passes through bottom center and starts upward, the passage is closed and compression commences, culminating in fuel injection and ignition. Refer to two-stroke diesel engines for more detailed coverage of aspiration types and supercharging of two-stroke engine.
Normally, the number of cylinders are used in multiples of two, although any number of cylinders can be used as long as the load on the crankshaft is counterbalanced to prevent excessive vibration. The inline-six cylinder design is the most prolific in light to medium-duty engines, though small V8 and larger inline-four displacement engines are also common. Small-capacity engines (generally considered to be those below five litres in capacity) are generally four or six cylinder types, with the four cylinder being the most common type found in automotive uses. Five cylinder diesel engines have also been produced, being a compromise between the smooth running of the six cylinder and the space-efficient dimensions of the four cylinder. Diesel engines for smaller plant machinery, boats, tractors, generators and pumps may be four, three or two cylinder types, with the single cylinder diesel engine remaining for light stationary work. Direct reversible two-stroke marine diesels need at least three cylinders for reliable restarting forwards and reverse. Four-stroke engines need at least six cylinders, providing repeated power strokes at 120 degrees.
The desire to improve the diesel engine's power-to-weight ratio produced several novel cylinder arrangements to extract more power from a given capacity. The uniflow opposed-piston engine uses two pistons in one cylinder with the combustion cavity in the middle and gas in- and outlets at the ends. This makes a comparatively light, powerful, swiftly running and economic engine suitable for use in aviation. An example is the Junkers Jumo 204/205. The Napier Deltic engine, with three cylinders arranged in a triangular formation, each containing two opposed pistons, the whole engine having three crankshafts, is one of the better known.