Ethernet shield SD card initialization failed

If you are using an Uno, the w5100 SPI will be disabled by accident when the SD.begin() call sets the default SPI slave select (D10) to OUTPUT and HIGH.

This is not an accident. SS is set high to disable any device sharing SPI on 328 Arduinos and using D10 for chip select. This was done mainly to avoid problems with the Ethernet shield on Uno and other 328 boards. On 328 boards, D10 must be an output so setting it high avoids many problems.

In the above test sketch you should set sharedCsPin to 10 if you are using an Arduino Ethernet shield. It won't hurt if you are using an Uno and is necessary if you use a Mega.

In general, the safest procedure is to set chip select for all SPI devices to output mode and high in setup before initializing any SPI device.