Codex Fons : Working around a broken SD card slot on a Raspberry Pi

When moving a cable, I violently ripped the SD card out of my Raspberry Pi by accident, breaking some of the slot's plastic in the process. I was certainly careless, but using flimsy plastic for a component that can receive quite a bit of physical stress is probably not the best idea. The missing parts are highlighted below in red.

Raspberry Pi damaged SD slot

What doesn't work

Those plastic bits are crucial for retaining the SD card, so it's virtually impossible to operate the device for prolonged periods of time. The SD card needs to be firmly in place for continued use. Clamps or glue don't provide the necessary rigidity for that - a slight shift in how the card is situated could already disconnect the card and crash the OS further down the road. The only thing that worked for me was pressing down the card with my fingers.

The cleanest solution is certainly replacing the slot with a (hopefully better) new part. That might not be an option for a variety of reasons:

In that case, someone had the glorious idea to use glue and an old credit card to build a makeshift cover for the slot. This solution works, but is still plagued by the slot contacts' sensitivity. Additional fitting is necessary to keep the SD card steady.

Booting from USB instead is not possible, because the device is hardwired to use the SD card. That can be worked around, though.

Solve the hardware problem in software

Using USB storage for the root file system is possible once the kernel has been booted from the SD card. The steps for powering up the device are as follows:

  1. Insert the USB storage device.
  2. Carefully insert the SD card into the slot and hold it down firmly.
  3. Connect to the power supply.
  4. Wait for a few seconds, ideally until the flashing LEDs on the Pi indicate activity.
  5. Remove the SD card.

The rootfs parameter in the cmdline.txt file on the SD card's FAT partition (the first one) needs to be set to /dev/sda2 beforehand. This is assuming that the OS was installed on the USB storage device the same way as it would be installed on an SD card, where the partition layout generally consists of the FAT-formatted boot partition in the first position, and the root partition in the second position. The USB storage device could also contain the root file system alone in the first position, changing /dev/sda2 in these instructions to /dev/sda1. If multiple USB storage devices are connected, using sdb instead of sda may be necessary, depending on in which order the devices are enumerated.

With these changes, the USB storage device would be used for the root partition, but the boot would still fail, because it is attempted to check the integrity of the SD card's partitions during startup. To avoid this, edit /etc/fstab to use /dev/sda2 as the root partition. The directive for the boot partition is no longer necessary, since its contents on the USB storage device are not used.

This solution comes with a small caveat. Updating the kernel becomes a little more cumbersome, because it has to be done manually on the SD card, and will no longer work with the package manager. Still, it's a viable hack until an opportunity to replace the SD slot comes along.

There are comments.

All posts

  1. Experience with UPC