Advertisement
Guest User

Untitled

a guest
Jun 27th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.31 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [[ -z $1 || -z $2 || -z $3 || -z $4 ]]
  4. then
  5.     echo "mksd-ti816x Usage:"
  6.     echo "  mksd-ti816x <device> <MLO> <u-boot.bin> <uImage> <rootfs tar.gz >"
  7.     echo "  Example: mksd-ti816x /dev/sdc MLO u-boot.bin uImage nfs.tar.gz"
  8.     exit
  9. fi
  10.  
  11. if ! [[ -e $2 ]]
  12. then
  13.     echo "Incorrect MLO location!"
  14.     exit
  15. fi
  16.  
  17. if ! [[ -e $3 ]]
  18. then
  19.     echo "Incorrect u-boot.bin location!"
  20.     exit
  21. fi
  22.  
  23. if ! [[ -e $4 ]]
  24. then
  25.     echo "Incorrect uImage location!"
  26.     exit
  27. fi
  28.  
  29. if ! [[ -e $5 ]]
  30. then
  31.     echo "Incorrect rootfs location!"
  32.     exit
  33. fi
  34.  
  35. echo "All data on "$1" now will be destroyed! Continue? [y/n]"
  36. read ans
  37. if ! [ $ans == 'y' ]
  38. then
  39.     exit
  40. fi
  41.  
  42. echo "[Partitioning $1...]"
  43.  
  44. DRIVE=$1
  45. dd if=/dev/zero of=$DRIVE bs=1024 count=1024
  46.      
  47. SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
  48.      
  49. echo DISK SIZE - $SIZE bytes
  50.  
  51. CYLINDERS=`echo $SIZE/255/63/512 | bc`
  52.  
  53. echo CYLINDERS - $CYLINDERS
  54. {
  55. echo ,9,0x0C,*
  56. echo ,,,-
  57. } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
  58.  
  59. echo "[Making filesystems...]"
  60.  
  61. mkfs.vfat -F 32 -n boot "$1"1 &> /dev/null
  62. mkfs.ext3 -L rootfs "$1"2 &> /dev/null
  63.  
  64. echo "[Copying files...]"
  65.  
  66. mount "$1"1 /mnt
  67. cp $2 /mnt/MLO
  68. cp $3 /mnt/u-boot.bin
  69. cp $4 /mnt/uImage
  70. umount "$1"1
  71.  
  72. mount "$1"2 /mnt
  73. tar zxvf $5 -C /mnt &> /dev/null
  74. chmod 755 /mnt
  75. umount "$1"2
  76.  
  77. echo "[Done]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement