Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # V1.0 13.03.2013 HSte Script for installing a prebuilt linux on sdcard
- #
- MMC_DEV=/dev/mmcblk0 #change if mmc-card mounts on different dev like /dev/sdb
- HOSTNAME_GK802=GK802
- IMAGE_NAME=oneiric_vpu_jas
- ###############################################################################
- #Check if run as root
- if [ $(id -u) != 0 ]; then
- echo "This script requires root permissions"
- sudo "$0" "$@"
- exit
- fi
- read -r -p "Are you sure your card is $MMC_DEV ? [Y/n] " response
- case $response in
- [yY][eE][sS]|[yY])
- echo "OK. Starting up"
- p=""
- if [ `echo $MMC_DEV|grep mmc` ]; then p="p"; fi
- ROOTFS=$MMC_DEV$p"1"
- umount $ROOTFS >/dev/null 2>&1
- if [ ! -f u-boot.imx ];
- then
- echo "Downloading rootfs. This can take some time"
- wget http://stende.no-ip.info/files/u-boot.imx
- echo "Finished downloading"
- fi
- if [ ! -d $IMAGE_NAME ];
- then
- # This is a ubuntuimage with user linaro and password linaro and sudo
- # You should also generate new ssh keys :)
- echo "Unpack rootfs. This can take some time"
- wget -c http://stende.no-ip.info/files/oneiric_vpu_jas.tar.lzma
- tar -x --lzma -f oneiric_vpu_jas.tar.lzma
- echo "Finished unpacking"
- fi
- ### This will format and prepare your mmc card with partition for rootfs
- echo "Formatting sdcard"
- dd if=/dev/zero of=$MMC_DEV bs=512 count=2047 >/dev/null 2>&1
- dd if=u-boot.imx of=$MMC_DEV bs=1K seek=1 >/dev/null 2>&1 && sync && sync
- # Format one partition on the sdcard
- (echo n;echo;echo;echo "31248";echo;echo w) |fdisk $MMC_DEV >/dev/null 2>&1
- # Make a ext4 optimized filesystem on sdcard
- mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 -LROOTFS $ROOTFS
- mkdir /media/ROOTFS >/dev/null 2>&1
- umount $ROOTFS >/dev/null 2>&1
- mount $ROOTFS /media/ROOTFS >/dev/null 2>&1
- cd $IMAGE_NAME
- echo "Copy rootfs to sdcard. This can take some time"
- cp -va * /media/ROOTFS
- echo $HOSTNAME_GK802 > /media/ROOTFS/etc/hostname
- umount $ROOTFS >/dev/null 2>&1
- echo "Finished"
- echo
- echo "Your sdcard should now be ready to put in to your device"
- ;;
- *)
- echo "Change the variable MMC_DEV to the right device"
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement