Skip to content

Instantly share code, notes, and snippets.

@mattes
Created October 22, 2012 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mattes/3933631 to your computer and use it in GitHub Desktop.
Save mattes/3933631 to your computer and use it in GitHub Desktop.
format sd card for arch linux and others
#!/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
@mattes
Copy link
Author

mattes commented Oct 22, 2012

short url in raw http://goo.gl/cY09b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment