After installing openvpn I cannot connect to my raspberrypi

So I installed openvpn on my Raspian distro on my Raspberry Pi 2. As soon as I started it up, I lost all connectivity to my Pi.

And I don’t have a display, keyboard, or mouse — all my management has been over the network.

How to recover?

I tried a bunch of things, but here’s what worked, in brief.

  • Power off PI and put SD card in my Mac.
  • Copy the SD card to an image file using `dd`
    • dd bs=32768 if=/dev/disk0 of=if=raspberrypi.img

Now we edit the image. If you have a way to open ext4 filesystems already, just remove the files (see rm step below). Here’s how I did it:

  • Install Veertu emulator (VMWare or VirtualBox would work too) with the latest Finnix Recovery Distro.
  • Create the Finnix VM in Veertu and add a 4GB Hard Disk. Boot it up once so it creates the disk image.
  • Move raspberrypi.img on top of the recovery image, e.g.
    • mv raspberrypi.img ~/VM\ Library/Finnix\ Rescue\ 2/hd1.img
  • Boot Finnix again
  • Mount the image
  • mkdir -p /mnt && mount -t ext4 /dev/sda2 /mnt
  • Remove the openvpn startup scripts
    • rm /etc/rc*/*openvpn
  • Unmount
    • umount /mnt
  • Power off Finnix
    • shutdown -h now
  • Copy the image back onto the SD card:
    • dd bs=32768 if="~/VM\ Library/Finnix\ Rescue\ 2/hd1.img" of=/dev/disk0

Put the SD card in your Raspberry Pi and reboot!

Update: The reason RPi doesn’t boot with open vpn is because ifplugd tries to HOT plug it.  To fix this, explicitly list the real network interfaces in `/etc/default/ifplugd`:

  • Replace
  • INTERFACES="auto"
    HOTPLUG_INTERFACES="all"
  • with
  • HOTPLUG_INTERFACES="eth0 wlan0"

(Do that instead of the rm step above to prevent openvpn from killing the wifi.)