1. #! /bin/sh
  2. # mk3PartSDCard.sh v0.
  3. # Licensed under terms of GPLv2
  4.  
  5. # 参考文档:
  6. # . sfidsk创建可启动分区问题
  7. # http://segmentfault.com/a/1190000002493628
  8. # . sfdisk 中文手册
  9. # http://blog.csdn.net/hnmsky/article/details/7650964
  10. # . linux sfdisk partition
  11. # http://blog.csdn.net/shell_albert/article/details/8425530
  12. # . How to Make Partition SD Card
  13. # http://processors.wiki.ti.com/index.php/How_to_Make_3_Partition_SD_Card
  14.  
  15. if [ $# -ne ]; then
  16. echo "USAGE:"
  17. echo " $0 <device node>"
  18. exit -;
  19. fi
  20.  
  21. # 获取SD卡设备节点,并擦除分区表
  22. DRIVE=$
  23. dd if=/dev/zero of=$DRIVE bs= count=
  24.  
  25. # 获取SD卡大小,并在terminal中显示字节大小
  26. SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
  27. echo DISK SIZE - $SIZE bytes
  28.  
  29. # 计算磁柱数
  30. # 每一个柱面的大小为255**=,, Bytes
  31. CYLINDERS=`echo $SIZE/// | bc`
  32.  
  33. # Usage:
  34. # sfdisk [options] <device> [...]
  35. #
  36. # Options:
  37. # -s, --show-size list size of a partition
  38. # -c, --id change or print partition Id
  39. # --change-id change Id
  40. # --print-id print Id
  41. # -l, --list list partitions of each device
  42. # -d, --dump idem, but in a format suitable for later input
  43. # -i, --increment number cylinders etc. from instead of from
  44. # -u, --unit <letter> units to be used; <letter> can be one of
  45. # S (sectors), C (cylinders), B (blocks), or M (MB)
  46. # -, --one-only reserved option that does nothing currently
  47. # -T, --list-types list the known partition types
  48. # -D, --DOS for DOS-compatibility: waste a little space
  49. # -E, --DOS-extended DOS extended partition compatibility
  50. # -R, --re-read make the kernel reread the partition table
  51. # -N <number> change only the partition with this <number>
  52. # -n do not actually write to disk
  53. # -O <file> save the sectors that will be overwritten to <file>
  54. # -I <file> restore sectors from <file>
  55. # -V, --verify check that the listed partitions are reasonable
  56. # -v, --version display version information and exit
  57. # -h, --help display this help text and exit
  58. #
  59. # Dangerous options:
  60. # -f, --force disable all consistency checking
  61. # --no-reread do not check whether the partition is in use
  62. # -q, --quiet suppress warning messages
  63. # -L, --Linux do not complain about things irrelevant for Linux
  64. # -g, --show-geometry print the kernel's idea of the geometry
  65. # -G, --show-pt-geometry print geometry guessed from the partition table
  66. # -A, --activate[=<device>] activate bootable flag
  67. # -U, --unhide[=<dev>] set partition unhidden
  68. # -x, --show-extended also list extended partitions in the output,
  69. # or expect descriptors for them in the input
  70. # --leave-last do not allocate the last cylinder
  71. # --IBM same as --leave-last
  72. # --in-order partitions are in order
  73. # --not-in-order partitions are not in order
  74. # --inside-outer all logicals inside outermost extended
  75. # --not-inside-outer not all logicals inside outermost extended
  76. # --nested every partition is disjoint from all others
  77. # --chained like nested, but extended partitions may lie outside
  78. # --onesector partitions are mutually disjoint
  79. #
  80. # Override the detected geometry using:
  81. # -C, --cylinders <number> set the number of cylinders to use
  82. # -H, --heads <number> set the number of heads to use
  83. # -S, --sectors <number> set the number of sectors to use
  84. #
  85.  
  86. # sfdisk的-D参数指定与DOS兼容,并自动在每个分区前预留空间,以存放MBR(Master Boot Record);
  87. #
  88. # <start>, <size>, <id>, <bootable>
  89. #
  90. # bootable 可以指定为[*|-]格式,默认值是"-"也就是没有可引导标记。
  91. # 这个标记仅对DOS有意义:DOS会给带有可引导标记的主分区分配 C: 盘符
  92. #
  93. # id 应该以无"0x"前缀的格式给出其十六进制值,或者[E|S|L]简写字母:
  94. # L()是默认值;
  95. # S(,LINUX_SWAP);
  96. # E(,扩展分区)。
  97. #
  98. # 第一行分区描述,,0x0C,* 自动分配起始柱面,数量为9,分区ID为0x0C(表示FAT32分区),<bootable>为*, 表示可启动分区。
  99. # 第二行分区描述10,,,- 同样自动分配起柱面,数量为115,其它为默认。
  100. # 第三行分区描述126,,,- 同样自动分配起柱面,剩下所有的数量,其它为默认。
  101. sfdisk -D -H -S -C $CYLINDERS $DRIVE << EOF
  102. ,,0x0C,*
  103. ,,,-
  104. ,,,-
  105. EOF
  106.  
  107. # 这里可以得到一张FAT32分区的SD卡,我有时候我们就只需要一张这样的卡
  108. # sfdisk -D -H -S -C $CYLINDERS $DRIVE << EOF
  109. # ,,0x0C,*
  110. # EOF
  111.  
  112. # 格式化各个分区,格式化完卸载对应的分区
  113. mkfs.vfat -F -n "boot" ${DRIVE}
  114. umount ${DRIVE}
  115. mkfs.ext3 -L "rootfs" ${DRIVE}
  116. umount ${DRIVE}
  117. mkfs.ext3 -L "START_HERE" ${DRIVE}

OK335x mksd.sh hacking的更多相关文章

  1. Woobuntu woobuntu_build.sh hacking

    # Woobuntu woobuntu_build.sh hacking # 说明: # 有时候因为一些需求,我们需要定制一些系统,包括Ubuntu系统,于是 # 我们自然需要知道如何去解包一个Ubu ...

  2. OK335xS psplash make-image-header.sh hacking

    /***************************************************************************** * OK335xS psplash mak ...

  3. ti processor sdk linux am335x evm setup.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm setup.sh hacking # 说明: # 本文主要对TI的sdk中的setup.sh脚本进行解读 ...

  4. ti processor sdk linux am335x evm /bin/setup-host-check.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-host-check.sh hacking # 说明: # 本文主要对TI的sdk ...

  5. ti processor sdk linux am335x evm /bin/create-sdcard.sh hacking

    #!/bin/bash # # ti processor sdk linux am335x evm /bin/create-sdcard.sh hacking # 说明: # 本文主要对TI的sdk中 ...

  6. ti processor sdk linux am335x evm /bin/unshallow-repositories.sh hacking

    #!/bin/bash # # ti processor sdk linux am335x evm /bin/unshallow-repositories.sh hacking # 说明: # 本文主 ...

  7. ti processor sdk linux am335x evm /bin/setup-package-install.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-package-install.sh hacking # 说明: # 本文主要对T ...

  8. ti processor sdk linux am335x evm /bin/setup-uboot-env.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-uboot-env.sh hacking # 说明: # 本文主要对TI的sdk中 ...

  9. ti processor sdk linux am335x evm /bin/setup-minicom.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-minicom.sh hacking # 说明: # 本文主要对TI的sdk中的s ...

随机推荐

  1. 防止XSS攻击的方式

    主要有三种请求方式,进行过滤替换非法符号 1.普通的GET请求数据: 2.FORM表单提交数据: 3.Json格式数据提交: 把下面5个文件放入项目中即可 package com.joppay.adm ...

  2. arp攻击的处理方法

    http://www.hacking-tutorial.com/tips-and-trick/4-steps-to-prevent-man-in-the-middle-attack-arp-poiso ...

  3. bat批处理以当前时间创建文本文件

    :: 表示注释 :: @表示不显示当前命令,只在后台执行 :: @echo off 表示以后执行的命令都不显示 :: set d=%,% 表示设置变量d为当前年月日,默认表示为例如:// :: set ...

  4. 字典树应用 - poj1002

    字典树应用 - poj 1002 Description Businesses like to have memorable telephone numbers. One way to make a ...

  5. Objective C Protocol implementation

    protocol 类似于接口,可以实现函数的回调 @protocol MyDelegate<NSObject> -(void)myCallbackFunction; @end //Call ...

  6. redmine修改附件储存路径

    如果想把redmine 1.x.x 版本中的attachments files 放在自定义的目录(例如/home/darkofday/redmineAttachFile/).执行下列命令:cd /ho ...

  7. Dockerfile 设置语言包

    最近使用Hangfire的Dashboard, 在本地调试时,显示的是中文,但是通过docker在kubernetes上运行时,就显示成英文了, 怀疑是docker运行环境中没有设计默认的语言包: 我 ...

  8. Restore IP Addresses,将字符串转换成ip地址

    问题描述: Given a string containing only digits, restore it by returning all possible valid IP address c ...

  9. jquery validate检验

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  10. 009——数组(九) each list array_map array_walk array_walk_recursive

    <?php /** * 9 数组 each list array_map array_walk array_walk_recursive */ //each() 返回数组中的键名和键值生成新数组 ...