#!/bin/bash # To use this script first Flash your sd-card using #Create-sdcard script in SDK located in bin directory. #Then tar rootfs and copy the tarball in rootfs partition #of sd-card in any subdirectory.Copy this script to sd-card #and run it in the target machine using sd-card. #Enter yes if anything is prompted. cd / umount -f /dev/mmcblk1p1 umount -f /dev/mmcblk1p2 cat << EOM ============================================================================== Current partitions ============================================================================== EOM fdisk -l /dev/mmcblk1 cat << EOM ============================================================================== Removing all partitions ============================================================================== EOM echo "....WARNING...." echo "Continuing will Erase all the current data and Partitions in EMMC" CONTINUE=0 while [ $CONTINUE -eq 0 ] do read -p "Do You Want To Continue [y/n] : " CHOICE if [ $CHOICE = 'y' ] then CONTINUE=1 elif [ $CHOICE = 'n' ] then CONTINUE=-1 else echo "Wrong Choice...Enter y or n" CONTINUE=0 fi done if [ $CONTINUE = -1 ] then exit fi fdisk /dev/mmcblk1 << EEOF d 2 d w EEOF echo "" echo "All partitions removed." echo "" echo "" cat << EOM ============================================================================== Creating new partitions ============================================================================== EOM parted -s /dev/mmcblk1 mklabel msdos parted -s /dev/mmcblk1 unit cyl mkpart primary fat32 -- 0 9 parted -s /dev/mmcblk1 set 1 boot on parted -s /dev/mmcblk1 unit cyl mkpart primary ext2 -- 9 -2 cat << EOM ============================================================================== New partitions ============================================================================== EOM fdisk -l /dev/mmcblk1 mkfs.vfat -F 32 -n "boot" /dev/mmcblk1p1 mkfs.ext3 -L "rootfs" /dev/mmcblk1p2 sync sync if [ -d /temp1 ] then rm -rf temp1 fi mkdir temp1 cd temp1 mkdir boot mkdir rootfs mkdir temp rm -rf boot/* rm -rf rootfs/* mount -t vfat /dev/mmcblk1p1 boot/ mount -t ext3 /dev/mmcblk1p2 rootfs/ mount -t vfat /dev/mmcblk0p1 temp/ cat << EOM ============================================================================= COPYING U-BOOT ============================================================================= EOM cp -R temp/* boot/ echo "copying MLO" echo "copying u-boot" echo "copying uEnv.txt" echo "done.." ENTERCORRECTLY=0 while [ $ENTERCORRECTLY -ne 1 ] do read -p "Enter the complete path to rootfs tarball : " ROOTFSPATH if [ -d $ROOTFSPATH ] then ENTERCORRECTLY=1 else echo "Is not a directory OR dirctory does not exist...Enter complete path to directory containing Rootfs" continue fi done TARBALL=`ls $ROOTFSPATH | grep .tar.gz | awk '{ print $1 }'` cat << EOM ========================================================================== EXTRACTING ROOTFS ... WILL TAKE SOME TIME ========================================================================== EOM if [ -n $TARBALL ] then echo "The rootfs tarball is: " $TARBALL tar -zxf $ROOTFSPATH/$TARBALL -C rootfs/ else echo "Tarball does not exist" echo "Exiting..." fi umount -f boot umount -f rootfs umount -f temp rm -rf boot rm -rf rootfs rm -rf temp cd .. rm -rf temp1 cat << EOM =========================================================================== ...FINISHED... =========================================================================== EOM