This issue came up at work this week.

I received two phone calls from customers who were having issues with their Raspberry Pi-based D-STAR Hotspot: something was corrupting the microSD card.

One wanted to get the built-in halt/reboot options working, and he eventually did with the help of the image’s site.

The second brought his RPi and laptop in for me to check on, and luckily he was using the same image as me, D-STAR Commander. After I set a new microSD card up for him, I popped it into my laptop, which runs Arch Linux, to do some modifications to /etc/fstab to allow for essentially hot unplugging of power. It involves RAM disks.

The procedure is quite easy and can be done before the RPi is booted up if you have an SD-card reader-equipped Linux machine.

If you’re already booted up on the RPi, connect to it via VNC (or SSH), open the Terminal, and follow the following steps:

1. Type “sudo nano /etc/fstab” and hit Enter.
2. Add the following lines to the file:

tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,mode=0700,gid=12,size=30m 0 0

(the last two lines are really one line. you can copy and paste if you need to)

3. Hit Ctrl-X and hit “Y” when prompted to exit and save the file.

Now reboot the RPi if it is running or unmount the microSD card and insert it into the RPi.

What this has done is crate three RAM disks: one 30 MB in size, one 100 MB in size, and one 30 MB in size. The directories listed there often are continually written to, which can be catastrophic if power is removed while the microSD card is being written to. If they are in RAM, they disappear once the power is removed.

This solves the corruption issue with the D-STAR images.