How to make shareable SD card by Raspberry Pi & PC.

Goal

Make a Raspberry Pi OS SD card which can be used by both Raspberry Pi & PC (Windows & Mac), for using as:

  • Taking Camera Image or Sensor Data by Raspberry Pi & write on SD CARD
  • Pull out the SD CARD, read it by PC.


Problem

Raspberry Pi OS SD Card consist of 2 partition, one is small size (about 44 MByte) FAT32 formatted partition for Linux Boot Loader, and the other is the EXT4 formatted partition for Linux OS.

As mentioned here, Raspberry Pi's First Stage BootLoader mount first FAT partition on the SD Card and start Second Stage BootLoader from this partition. Then, mount EXT4 partition for Linux OS.

The first 44 MByte FAT32 partition is too small to store Camera Images or Sensor Data. But, next EXT4 partition can't recognized by neither Windows PC nor Mac.

So, first conceived idea is that adding 3rd partition which is formatted as FAT32, and is enough big for storing data.


This idea is work well with Mac. Both Raspberry Pi & Mac can recognize the 3rd Partition formatted as FAT32.

But not work with Windows. Windows just can recognize first FAT32 partition, and can't recognize other partition.

Solution.

The constraints are as follows:
  • For Raspberry Pi BootLoader, the first partition on the SD CARD should be formatted as FAT
  • Mac can recognize multi partitioned SD Card, but Windows can recognize only the first partition.
The remaining solution is only that the first FAT should be share both for store boot files and Camera Image & Sensor Data by expanding the size.

How to get it ?

My made the Latest (Sep, 2018 version ) Raspbian stretch lite image with 4GB boot area for 8GB SD Card is available on my Payhip account for saving your time.

Also you can make it by yourself by the steps described latter.

How to make it yourself.

You can do this by gparted, famous great Partition Editor. Even you can use gparted on PC as usual, but I recommend more convenient way as to use gparted on the Raspberry Pi. The gparted can move & resize partition which is unmounted, and running partition can't be unmounted, so right steps are as follows:
  1. Prepare one SD Card. This is a target SD Card on which you will make Raspberry OS SD Card with big FAT32 partition for sharing DATA between RPi and PCs.
  2. Prepare another SD Card in which desktop type raspbian (not lite) is installed. This is working SD Card for making it. 
  3. Prepare USB SD Card reader
  4. Start Raspberry Pi with desktop type raspbian, install gparted.
  5. Mount the other SD Card, which you will make bit FAT32 Raspberry OS, on the USB SD Card reader and put it on the Raspberry Pi's USB port.

How to use gparted on the Raspberry Pi.

On the menu of Raspberry Pi, select Preferences, then select GParted.

Running SD card is mounted on the /dev/mmcblk0 and the other SD Card on the USB is monted on /dev/sda in general (In case other USB device is mounted, possible mount point shift to /dev/sdb, /dev/sdc ... and so on).
So, select /dev/sda.



Now, you can move EXT4 partition back to make room for resize fat partition.

Note:
The FAT16 partition is automatically be change to FAT32 when the resize byte exceed to FAT16 limitation.


Note:
The boot partition on the recent version of raspbian is formatted as FAT32, not FAT16 from the beginning.
Unfortunately, the gparted has one issue which fail to move / resize fat32 partitions less than 256 MB in size. So, you should choice original OS image as old OS image like 2016-09-23 version of raspbian jessie lite. After boot partition expanded, you can update it latest version of Stretch by following steps:


  1. update sources list file from jessie to stretch as:

    sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list
    sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list.d/raspi.list
  2. upgrade & dist-upgrade as follows:

    sudo apt update
    sudo apt upgrade
    sudo apt dist-upgrade
    sudo apt-get autoremove --purge -y


    upgrade might be take long time (about 1 - 2 hours).
















Comments

Popular posts from this blog

How to Measure ROOM CO2 concentration with 20$ sensor "MH-Z19" and Raspberry Pi, 2nd edition.

How to Measure ROOM CO2 concentration with 20$ sensor "MH-Z19" and Raspberry Pi

Monitoring all over the world with 3G Network for not more than 10$ monthly payment