Create a setup USB key for Lion or Mountain Lion

You want to create a USB setup key of an old Mac OS X but the excellent DiskMaker X does not include Lion and Mountain Lion? Here is a small tip.
En Français.

DiskMaker X only takes into account Mavericks, Yosemite and El Capitan, but a small tip allow to make easily a USB key of Lion or Mountain Lion.

Quelques limites

A few limitations

Apple explains how to create a USB key with the integrated tool in the setup files of Mavericks, Yosemite and El Capitan, but not with Lion and Mountain Lion.

The trick requires the Lion setup files (or Mountain Lion) but also those of El Capitan. Then simply use the software of El Capitan to run the Lion or Mountain Lion images. The following commands need an empty USB key (/Volumes/Untitled) and the setup images contained in the /Applications folder.

The command for Lion:

sudo /Applications/Install\ OS\ X\ El\ --volume /Volumes/Untitled --applicationpath /Applications/Install\ Mac\ OS\ X\ --nointeraction

The command for Mountain Lion:

sudo /Applications/Install\ OS\ X\ El\ --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mountain\ --nointeraction