Raspberry PI running from an external HDD

This is a scenario where you have an external HDD (or “pen” drive) connected via USB to the PI. The SD card will be just used for the boot sequence then everything will work from the external HDD, I find the system to work faster, smoother and more stable this way (at least with my v1 PI).

First thing is to normally install the Raspbian system in the SD card. There will be 2 partitions on it. A first small fat16 partition labeled ‘boot’ with the lba flag set, and a second ext4 partition. So, on your external HDD you will need also a ext4 partition. I advice you to to make 2 partitions in the HDD, one for the OS, programs and files, and the second (like a /home/ or /data/) for personal files, backups, etc. In the event of a major catastrophic malfunction, this configuration offers a bigger safeguard to your personal data.

If you need assistance to partition and format your HDD probably its a good idea to stop here.

Mount and sync the second SD card ext4 partition with your external HDD ext4 partition

sudo rsync -avHx /mnt/sdcard/ /mnt/hdd

Next step is to mount the SD card boot partition. And change in /cmdline.txt (adjust sda1 to your HDD partition as needed).



root=/dev/sda1 rootwait

You can actually delete de SD card system directory (or not) it works the same. Also don’t forget to add an entry in /etc/fstab for mounting the second partition in the HDD in case you have it.

Good luck with your PI.

Raspberry PI configuring Wi-Fi command-line

This was a saga… i bought myself a second hand USB dongle, a Dynamode WL-700N-XS ultra compact (nano) 802.11b/g/n compatible Wi-Fi adapter, based in tbe Realtek 8188CU chipset. A fully updated USB Wi-Fi adapters list is mantained here.

Dynamode Wireless USB Nano 150mbps WL-700N-XSThis chipset is pretty plug an play on the PI with the latest Raspbian Wheezy, reported to work directly with a decent power source, no driver compilation or obscure installation, just supported out of the box by the Linux kernel. Just perfect.

I confidently connect the dongle in the PI, the USB device was properly recognized:

# lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

also on dmesg

# dmesg
[    3.171681] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[    3.293726] usb 1-1.2: New USB device found, idVendor=0bda, idProduct=8176
[    3.302266] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.311142] usb 1-1.2: Product: 802.11n WLAN Adapter
[    3.317650] usb 1-1.2: Manufacturer: Realtek
[    3.323401] usb 1-1.2: SerialNumber: 00e04c000001
[   15.830604] usbcore: registered new interface driver rtl8192cu

and ifconfig, reports a wlan0, so by now everything looked great. I followed an tutorial about configuring wireless on PI, and no connection, then another, and no connection… shit!!! Then of course i dump the PI tutorials (you can guess the technical level as low when you find “reboot to load the new values”….). Moved to good old Linux documentation, as Raspbian is just another Debian clone.

So before messing with /etc/network/interfaces and /etc/wpa_supplicant/wpa_supplicant.conf the best debug tool is the command ‘iwlist wlan0 scan‘, that should print the available wireless networks. And with this dongle i was getting none (even at 10 centimeters of the wireless router). Long story short, after testing the dongle in other computers (and even other OS – yes, i washed my hands already) i found out the dongle is simply damaged and working rather randomly.

After replacing the dongle (thanks Delaman) by another of the exact same model, things started to work properly, iwlist wlan0 scan started to work right and i could see my wireless network, and the neighbors networks also.

From this point i could confidently resume the wireless network setup. First thing the /etc/network/interfaces:

auto lo
iface lo inet loopback

iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

the important lines here are those 3 referring to the wlan interface and should be added to the configuration file.

Then the /etc/wpa_supplicant/wpa_supplicant.conf that holds the network security configuration. First i tried some of the suggested configurations in the Internets, but i was just getting the error: “failed to parse ssid ‘MY_NETWORK_NAME’” and the likes. So, go with the wpa_passphrase command to generate a network block configuration:

wpa_passphrase YOUR_NETWORK_NAME password

Now copy and replace the generated network block to /etc/wpa_supplicant/wpa_supplicant.conf, it should look something like this (a quite simple and clean configuration):

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


You can heep the first two lines, as they provide an interface to the wpa_supplicant via the wpa_cli command.

Don’t have to reboot, i tested this while ethernet connected. Restart the wlan0 interface and reload the configuration into the supplicant thing:

ifdown wlan0
ifup wlan0
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

And there, ifconfig shows an active Wi-Fi connection on wlan0. From other computer, the wlan0 IP responds on pings and is possible to SSH. Now disable the ethernet connection:

ifdown eth0

disconnect the ethernet cable, and there your PI is free to move around without the network cable.

FreeBSD USB keyboard stalled in single user mode

Trying to recover a root password in an old FreeBSD box (that has been working flawlessly for many years), after selecting single user boot in Beastie menu the keyboard stop responding…. oh well the USB support in old versions is somewhat buggy… just before i was going into the LiveCD route i found a thread in FreeBSD lists with this info:

1) From Beastie menu, escape to loader prompt.
2) set hint.atkbd.0.flags=”0x1″
3) boot -s

and it did the work. Afterward it was a child’s game to change the root password. All the credits to the freebsd lists.