Skip to content

Instantly share code, notes, and snippets.

@hansstimer
Forked from mattes/mkcard.sh
Created February 14, 2013 02:55
Show Gist options
  • Save hansstimer/4950249 to your computer and use it in GitHub Desktop.
Save hansstimer/4950249 to your computer and use it in GitHub Desktop.

Revisions

  1. @mattes mattes created this gist Oct 22, 2012.
    19 changes: 19 additions & 0 deletions mkcard.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/bash
    # Quelle: http://omappedia.org/wiki/Minimal-FS_SD_Configuration, 06.06.2012
    if [ ! "$1" = "/dev/sda" ] ; then
    unset LANG
    DRIVE=$1
    if [ -b "$DRIVE" ] ; then
    dd if=/dev/zero of=$DRIVE bs=1024 count=1024
    SIZE=`fdisk -l $DRIVE | grep Disk | 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
    mkfs.vfat -F 32 -n "boot" ${DRIVE}1
    mke2fs -j -L "rootfs" ${DRIVE}2
    fi
    fi