Raspbian using SD card & USB thumb drive

Sub-Topic: Creating a backup image of your Raspbian SD card

Decided to try moving my actual linux partition from the standard SD card location to a USB memory stick.

I did this without fully understanding the benefits (or cons). ¬†ūüôā

I knew people had done this previously with USB hard drives. ¬†Its possible this will reduce the likelihood of the SD card becoming corrupted. ¬†I’m not sure if it provides any performance (read/write) improvements.

So in summary… I just did it… To do it.

Notes:

  • My primary resource for getting this done was: Raspbian on Raspberry Pi using SD card + USB memory stick
  • I primarily use a Win7 laptop, so I’ll be differing from the above link in the details, but the overall concepts remain the same.
  • When working with any images I used the Win32 Disk Imager program (v0.7).
  • I did all this after already having Raspbian working and configured with an SD card

Process:

  1. Determine the device name of the USB memory stick
    1. This can be accomplished via “dmesg” as seen at the above link.
    2. An alternative method is to “sudo tail -f /var/log/messages” prior to putting the memory stick in. ¬†When you put the memory stick in log messages will appear similar to the “dmesg” format.
    3. My memory stick was at “/dev/sda”
    4. Remove the USB memory stick once done
  2. Create a backup image of your SD card
    1. This accomplishes a couple of things.
      1. Creates a nice backup of a working Raspbian image
      2. Makes it so that when you’re successful, the Raspbian image running off your USB stick is already configured and working immediately. ¬†Yes… This was as awesome as it sounds.
    2. With Win32 Disk Imager
      1. Select the SD card drive letter
      2. Type in the name and full path for the backup image (e.g. c:\users\john doe\desktop\rasp_backup.img).  I had to type it in, bringing up the file window only allows selecting an existing img file
      3. Click Read
      4. And wait…
  3. Write the SD card backup image to the thumb drive
    1. Again, using Win32 Disk Imager
      1. Select the thumb drive’s drive letter
      2. Select the backup img file you just created.  You can use the file dialog box this time
      3. Double check that you did selectd the thumb drive’s drive letter
      4. Click Write
      5. And wait…
  4. Prepare the boot SD card
    1. I had a smaller 256MB SD card lying around, so I used it for this purpose
    2. I used Window’s format capability to format the boot SD card
      1. File system:  FAT32 (this is not the default)
      2. Allocation unit size: 1024 (not sure if this is needed, but its what I did… Default was 2048, which probably would have worked)
  5. Copy boot files from USB memory stick to boot SD
    1. Open the USB memory stick via Windows Explorer
    2. Open the boot SD via Windows Explorer (in a separate window)
    3. Copy all displayed files from the USB memory stick to the boot SD
  6. Modify the boot files to point to the USB memory stick
    1. On the boot SD, open “cmdline.txt” ¬†(notepad worked for me)
    2. There is only a single line in the file
    3. Change “root=/dev/mmcblk0p2” to “root=/dev/sda2”
      1. This tells Raspbian to look at the 2nd partition on the USB memory stick instead of the 2nd partition on the SD card
      2. Save. ¬†There should be no issues saving with notepad since you’re editting the middle of the line, so no carriage return issues that could occur… Possibly… I really don’t know in this case. ¬†ūüôā
      3. Its possible you SD card and USB memory sticks have different device names, but the above is how it looked for me
  7. Put the boot SD and USB thumb drive into your Pi and plug in the power

After I did the above, everything worked for me the first time and with the configuration I had previously working with just an SD card.  Which means I did not have to move my headless Pi to reconnect it to a TV and keyboard and mouse to verify and configure.

Multiple Windows 7 Crashes (Possibly Resolved)

My laptop has crashed 3 times in the last 24 hours on my Asus G73J with Win7.

  • I usually put it into hibernate over night, but left it awake and in a power saving mode to allow it to finish syncing with a server. ¬†The next morning it was off.
  • Put it to sleep while not in use. ¬†Came back and it was off.
  • Don’t recall the 3rd incident… Probably similar to the 2nd.

So now I’m trying to determine what’s happening and have come across some interesting tools and links.

NirSoft BlueScreenView

  • Got this to analyze the “.dmp” files being produced. ¬†Gives me some info, but after just a few minutes of using it (and obviously becoming a quick expert), it does not appear to provide a root cause of my problem.
  • Looks like it can call a “DumpChk” utility. ¬†Vaguely familiar with this. ¬†I believe its part of a Windows SDK package

Windows SDK Package

  • Found the listed pages to help go further than BlueScreenView
    • http://mikemstech.blogspot.com/2011/11/how-to-troubleshoot-0x9f.html
    • http://mikemstech.blogspot.com/2011/11/windows-crash-dump-analysis.html
  • Installed the Windows SDK via the instructions on the 2nd link
    • I did get an error for my first install and it is resolved with this page:¬†http://support.microsoft.com/kb/2717426
    • I had to 2010 versions installed. ¬†I only uninstalled the one that was greater and it worked.
    • Not sure I need to reinstall yet though… Also, after a quick look I could not find it on MS’s website.
  • Now to keep following the first link’s instructions.
    • Instructions from the links about could have been better. ¬†Looked like he was running a linux command, but he was really in the WinDbg program already.
    • Found this link as helpful: ¬†http://social.technet.microsoft.com/wiki/contents/articles/6302.windows-bugcheck-analysis.aspx

Windows Autoruns

  • In my searching, I found this utility from MS. ¬†Looks like it may be useful… Maybe not for this issue, but still useful. ¬†It analyzes all “startup” programs. ¬†One potential and interesting use is that it supposedly can tell you what programs are being autoran but not longer exist or cannot be found or any other reason why the configured path does not work…
  • http://technet.microsoft.com/en-us/sysinternals/bb963902

 Possible Resolution

  • So my analysis basically circled back to a driver that I already knew about… I guess I learned some new stuff, so that’s good.
  • Everything pointed to my crashes being caused by: ¬†NETw5s64.sys
    • Googling suggests this is an Intel Wireless driver and said to make sure its updated and suggested using this Intel page:
      • http://www.intel.com/p/en_US/support/detect?iid=dc_iduu
  • Now time will tell if this resolved my issue… I’m done with troubleshooting for the day. ūüôā

Raspbian – NFS w/Synology

Synology stuff first…

  • Enabled NFS file sharing on my Synology
  • For each share on my Synology NAS, had to go into NFS Permissions and create a rule
    • Disabled “Asynchronous”

Then followed these instructions…

First, install the necessary packages. I use aptitude, but you can use apt-get instead if you prefer; just put apt-get where you see aptitude:

sudo aptitude install nfs-common portmap

(nfs-common may already be installed, but this will ensure that it installs if it isn’t already)

On the current version of Raspbian, rpcbind (part of the portmap package) does not start by default. This is presumably done to control memory consumption on our small systems. However, it isn’t very big and we need it to make an NFS mount. To enable it manually, so we can mount our directory immediately:

sudo service rpcbind start

To make rpcbind start automatically at boot:

sudo update-rc.d rpcbind enable

Now, let’s mount our share:

Make a directory for your mount. I want mine at /public, so:

mkdir /public

Mount manually to test:

sudo mount -t nfs 192.168.222.34:/public /public

  • (my server share path) (where I want it mounted locally)

Now, to make it permanent, you need to edit /etc/fstab (as sudo) to make the directory mount at boot. I added a line to the end of /etc/fstab:

192.168.222.34:/public /public nfs rsize=8192,wsize=8192,timeo=14,intr 0 0

The rsize and wsize entries are not strictly necessary but I find they give me some extra speed.

 

Notes:

  • Everything basically needs to be done via sudo
  • With multiple shares, each needs to be mounted independently. ¬†Such as…
    • /public/dir1
    • /public/dir2

 

Source: http://www.raspbian.org/RaspbianFAQ

Raspbian – VNC

Installing VNC on the Pi

We’re going to use Tight VNC here (server on the Raspberry Pi and Viewer on Windows).

There’s an excellent tutorial over at¬†Penguin Tutor¬†if you need more information.

First of all install the Tight VNC Server from the command prompt:

sudo apt-get install tightvncserver

Let it finish installing (if you’re asked to¬†confirm¬†anything, just hit ‘y’ on the keyboard). When complete start the server:

vncserver

You’ll be asked to create a password, enter one and confirm. I used raspberry for ease of use, but probably not the most secure!

When asked to create a view only password, say No.

Every time you start VNC you’ll see something like:

New 'X' desktop is raspberrypi:1

Note the :1. This is the desktop session created. You can add more by running VNC again.

Head over to TightVNC on your windows box and install the viewer.

 

Source: http://www.neil-black.co.uk/raspberry-pi-beginners-guide#.UTk0TDC9t8F

Raspbian – Misc To-Done

Misc things I’ve done to configure my Pi for my personal usage.

Most have to be done via “sudo”

  • Create a new user, separate from “pi”
    • Command: ¬†‘adduser’
    • Appears to be a Debian specific command, different than the usual Linux ‘useradd’
  • Make new user’s primary group be “users”
    • Since I’m connecting to my Synology NAS over NFS, this allows any files I create as the new user to be part of a common group between the Pi and NAS
    • Command: ‘usermod -g users <newuser>’
  • As “pi” user, give new user ‘sudo’ access
    • Command: ‘visudo’
  • Create RSA key for authentication
    • Command: ‘ssh-keygen’
    • Be sure to keep your key safe and retrievable so that access is not lost… Don’t lose your key!
  • Add pub key to “~/.ssh/authorized_keys” file for new user
  • After achieving access via key authentication, disable SSH password authentication
    • Edit /etc/ssh/sshd_config
    • “PasswordAuthentication no”
  • Optional, specify SSH access for accounts
    • Edit /etc/ssh/sshd_config
    • At bottom of the file, add:
      • AllowUsers newUser1 newUser2
    • Good way to leave default “pi” user “active”, but not directly accessible via SSH
  • Changed hostname
    • nano /etc/hosts
    • nano /etc/hostname
    • reboot
  • Install rsync
    • aptitude install rsync
  • rsync backup script caused an error
    • Error: Too many open files
    • Testing solution: edit /etc/security/limits.conf
      • @users ¬† ¬† hard ¬† ¬† nofile ¬† ¬† 32768
  • Configure NTP to sync with NAS
    • Edit /etc/ntp.conf
    • Comment out existing lines starting with “server” that look like “server 0.debian.pool.ntp.org”
    • Add line like “server <nas IP>”
    • Save
    • service ntp restart

To be continued…