-->

Wednesday, December 11, 2013

Mounting a USB disk drive at boot

In the following I have plugged in a USB drive and I want to have it mounted when the system boots.

Get a list of your USB devices to check if your USB drive is available

pi@raspberrycam2$ lsusb

Bus 001 Device 002: ID 0424:9514 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 13fe:5200 Kingston Technology Company Inc. 
Bus 001 Device 005: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

Make a directory to mount your drive/volume into

pi@raspberrycam2$ sudo mkdir /home/pi/crap




Find the UUID of your drive

pi@raspberrycam2$ sudo blkid

/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="2654-BFC0" TYPE="vfat" /dev/mmcblk0p2: UUID="548da502-ebde-45c0-9ab2-de5e2431ee0b" TYPE="ext4"
/dev/sda1: LABEL="CRAP" UUID="7CCD-19F2" TYPE="vfat"


Edit your /etc/fstab file by appending a line for your dive

pi@raspberrycam2$ sudo pico /etc/fstab

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
UUID=7CCD-19F2 /home/pi/crap    vfat    rw,umask=0      0       0
# a swapfile is not a swap partition, so no using swapon|off from here on, use $

Important. When you make the directory where a drive will be mounted it MUST be done with sudo mkdir /home/pi/crap. This is so fstab can mount it on boot, the final permissions of this mounted drive are set in the fstab line with rw,umask=0.

Linux Commands

lsusb
sudo blkid
sudo umount /home/pi/crap
sudo mount -a

Tuesday, December 10, 2013

Initial Installation on Raspian Wheezy

Before you begin
  • Make sure you have a reliable power supply (5V 1A).
  • Make sure you have access to a router (or access to a USB to TTL cable).
Install Raspian image to an SD card
  • Download Raspian.
  • On OS X, use PiFiller to copy the Raspian image to an empty SD card.
Put the SD card in the Pi and attach some power.
  • AC/DC wall adapter plugged into the micro SD
  • OR
  • USB to TTL plugged into pins 1, 3, 4, 5 colors are: red - skip - black - white - green.
  • IMPORTANT: Do not attach power on both the USB and Raspberry pins at the same time.
First time login
  • If you have a router, connect an ethernet cable from your Raspberry to the router, figure out your Pi's IP and login with ssh.
  • If your using a USB to TTL cable, use screen (see Problems)
Configure Wireless network

pi@Rasberry$ sudo pico /etc/network/interfaces









auto lo
iface lo inet loopback

iface eth0 inet dhcp

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

iface default inet dhcp


pi@Rasberry$ sudo pico /etc/wpa_supplicant/wpa_supplicant.conf





ctrl_interface=DIR=/var/run/wpa_supplicant

#GROUP=netdev

#update_config=1

network={
        ssid="your_work_ssid"
        key_mgmt=WPA-EAP
        eap=PEAP
        phase2="auth=MSCHAPV2"
        identity="your_user_id"
        password="your_password"
}

network={
        ssid="your_router_ssid"
        psk="your_router_password"
}

Problem: If you have connected your Raspberry with a USB to TTL cable (xxx) and have logged in from a host computer using screen then the carriage return character can sometimes not be correct. You will see this as you edit /etc/network/interfaces, when you reopen the file some of the lines will be mashed into the same line and calls to 'sudo ifup wlan0' or 'sudo ifdown' will give you unpredictable errors.

Solution: Limit your time using a USB to TTL cable with screen. While using one, just configure your two network files (above). For each line in the file, just  put two carriage returns per line.

Linux Commands:







sudo ifup wlan0
sudo ifdown wlan0
ifconfig