You would need a Class D dry chemical fire extinguisher, Water should not be used to extinguish magnesium fires, because it can produce hydrogen which will feed the fire, according to the reaction:
Mg (s) + 2 H2O (g) → Mg(OH)2 (s) + H2 (g)
or in words:
Magnesium (solid) + steam → Magnesium hydroxide (solid) + Hydrogen (gas)
Carbon dioxide fire extinguishers should not be used either, because magnesium can burn in carbon dioxide (forming magnesium oxide, MgO, and carbon). A Class D dry chemical fire extinguisher should be used if available, or else the fire should be covered with sand or magnesium foundry flux. An easy way to put out small metal fires is to place a polyethylene bag filled with dry sand on top of the fire. The heat of the fire will melt the bag and the sand will flow out onto the fire.
This is why the Navy dumps burning aircraft overboard...
We have a sticky on what to do in case of fire somewhere...
Marc :icon_geek: