Formatting SD card for the BBB

From Crashcourse Wiki

Jump to: navigation, search

[edit] Formatting (and populating) the SD card

Here's the script I use:

#! /bin/sh

export LC_ALL=C

if [ $# -ne 1 ]; then
        echo "Usage: $0 <drive>"
        exit 1;
fi

DRIVE=$1
PARTITION1=${DRIVE}1
PARTITION2=${DRIVE}2

umount ${PARTITION1}
umount ${PARTITION2}

SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`

echo DISK SIZE - $SIZE bytes

CYLINDERS=`echo $SIZE/255/63/512 | bc`

echo CYLINDERS - $CYLINDERS

{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE

# now make partitions.
if [ -b ${PARTITION1} ]; then
        # umount ${PARTITION1}
        mkfs.vfat -F 32 -n "fat" ${PARTITION1}
else
        echo "Cant find boot partition in /dev"
fi

if [ -b ${PARITION2} ]; then
        # umount ${PARTITION2}
        mkfs.ext4  -L "linux" ${PARTITION2}
else
        echo "Cant find rootfs partition in /dev"
fi

And after a build, here's what I use to populate the card:

#!/bin/sh

sudo cp tmp-eglibc/deploy/images/{MLO,u-boot.img} /media/fat
sudo tar xvzf tmp-eglibc/deploy/images/core-image-minimal-beaglebone.tar.gz \
        -C /media/linux
sudo tar xvzf tmp-eglibc/deploy/images/modules-beaglebone.tgz \
        -C /media/linux
sudo cp tmp-eglibc/work/beaglebone-oe-linux-gnueabi/linux-mainline/3.8.13-r23a/image/boot/am335x-boneblack.dtb /media/linux/boot
sudo cp tmp-eglibc/deploy/images/uImage /media/linux/boot

followed by some variation of:

$ sudo depmod -b /media/linux/ "3.8.13"


(Back to BeagleBone Black page.)

Personal tools