Advertisement
Guest User

Untitled

a guest
Mar 18th, 2013
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # V1.0 13.03.2013 HSte Script for installing a prebuilt linux on sdcard
  4. #
  5.  
  6.  
  7. MMC_DEV=/dev/mmcblk0 #change if mmc-card mounts on different dev like /dev/sdb
  8.  
  9.  
  10. HOSTNAME_GK802=GK802
  11.  
  12. IMAGE_NAME=oneiric_vpu_jas
  13.  
  14. ###############################################################################
  15.  
  16. #Check if run as root
  17. if [ $(id -u) != 0 ]; then
  18. echo "This script requires root permissions"
  19. sudo "$0" "$@"
  20. exit
  21. fi
  22.  
  23. read -r -p "Are you sure your card is $MMC_DEV ? [Y/n] " response
  24. case $response in
  25. [yY][eE][sS]|[yY])
  26. echo "OK. Starting up"
  27. p=""
  28. if [ `echo $MMC_DEV|grep mmc` ]; then p="p"; fi
  29. ROOTFS=$MMC_DEV$p"1"
  30. umount $ROOTFS >/dev/null 2>&1
  31.  
  32. if [ ! -f u-boot.imx ];
  33. then
  34. echo "Downloading rootfs. This can take some time"
  35. wget http://stende.no-ip.info/files/u-boot.imx
  36. echo "Finished downloading"
  37. fi
  38. if [ ! -d $IMAGE_NAME ];
  39. then
  40. # This is a ubuntuimage with user linaro and password linaro and sudo
  41. # You should also generate new ssh keys :)
  42. echo "Unpack rootfs. This can take some time"
  43. wget -c http://stende.no-ip.info/files/oneiric_vpu_jas.tar.lzma
  44. tar -x --lzma -f oneiric_vpu_jas.tar.lzma
  45. echo "Finished unpacking"
  46. fi
  47.  
  48. ### This will format and prepare your mmc card with partition for rootfs
  49. echo "Formatting sdcard"
  50. dd if=/dev/zero of=$MMC_DEV bs=512 count=2047 >/dev/null 2>&1
  51.  
  52. dd if=u-boot.imx of=$MMC_DEV bs=1K seek=1 >/dev/null 2>&1 && sync && sync
  53.  
  54. # Format one partition on the sdcard
  55. (echo n;echo;echo;echo "31248";echo;echo w) |fdisk $MMC_DEV >/dev/null 2>&1
  56.  
  57. # Make a ext4 optimized filesystem on sdcard
  58. mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 -LROOTFS $ROOTFS
  59.  
  60. mkdir /media/ROOTFS >/dev/null 2>&1
  61.  
  62. umount $ROOTFS >/dev/null 2>&1
  63. mount $ROOTFS /media/ROOTFS >/dev/null 2>&1
  64. cd $IMAGE_NAME
  65.  
  66. echo "Copy rootfs to sdcard. This can take some time"
  67.  
  68. cp -va * /media/ROOTFS
  69.  
  70. echo $HOSTNAME_GK802 > /media/ROOTFS/etc/hostname
  71.  
  72. umount $ROOTFS >/dev/null 2>&1
  73.  
  74. echo "Finished"
  75. echo
  76.  
  77. echo "Your sdcard should now be ready to put in to your device"
  78. ;;
  79.  
  80. *)
  81. echo "Change the variable MMC_DEV to the right device"
  82. ;;
  83. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement