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.

Leave a Reply

Your email address will not be published. Required fields are marked *