#! /bin/sh
# mk3PartSDCard.sh v0.
# Licensed under terms of GPLv2 # 参考文档:
# . sfidsk创建可启动分区问题
# http://segmentfault.com/a/1190000002493628
# . sfdisk 中文手册
# http://blog.csdn.net/hnmsky/article/details/7650964
# . linux sfdisk partition
# http://blog.csdn.net/shell_albert/article/details/8425530
# . How to Make Partition SD Card
# http://processors.wiki.ti.com/index.php/How_to_Make_3_Partition_SD_Card if [ $# -ne ]; then
echo "USAGE:"
echo " $0 <device node>"
exit -;
fi # 获取SD卡设备节点,并擦除分区表
DRIVE=$
dd if=/dev/zero of=$DRIVE bs= count= # 获取SD卡大小,并在terminal中显示字节大小
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes # 计算磁柱数
# 每一个柱面的大小为255**=,, Bytes
CYLINDERS=`echo $SIZE/// | bc` # Usage:
# sfdisk [options] <device> [...]
#
# Options:
# -s, --show-size list size of a partition
# -c, --id change or print partition Id
# --change-id change Id
# --print-id print Id
# -l, --list list partitions of each device
# -d, --dump idem, but in a format suitable for later input
# -i, --increment number cylinders etc. from instead of from
# -u, --unit <letter> units to be used; <letter> can be one of
# S (sectors), C (cylinders), B (blocks), or M (MB)
# -, --one-only reserved option that does nothing currently
# -T, --list-types list the known partition types
# -D, --DOS for DOS-compatibility: waste a little space
# -E, --DOS-extended DOS extended partition compatibility
# -R, --re-read make the kernel reread the partition table
# -N <number> change only the partition with this <number>
# -n do not actually write to disk
# -O <file> save the sectors that will be overwritten to <file>
# -I <file> restore sectors from <file>
# -V, --verify check that the listed partitions are reasonable
# -v, --version display version information and exit
# -h, --help display this help text and exit
#
# Dangerous options:
# -f, --force disable all consistency checking
# --no-reread do not check whether the partition is in use
# -q, --quiet suppress warning messages
# -L, --Linux do not complain about things irrelevant for Linux
# -g, --show-geometry print the kernel's idea of the geometry
# -G, --show-pt-geometry print geometry guessed from the partition table
# -A, --activate[=<device>] activate bootable flag
# -U, --unhide[=<dev>] set partition unhidden
# -x, --show-extended also list extended partitions in the output,
# or expect descriptors for them in the input
# --leave-last do not allocate the last cylinder
# --IBM same as --leave-last
# --in-order partitions are in order
# --not-in-order partitions are not in order
# --inside-outer all logicals inside outermost extended
# --not-inside-outer not all logicals inside outermost extended
# --nested every partition is disjoint from all others
# --chained like nested, but extended partitions may lie outside
# --onesector partitions are mutually disjoint
#
# Override the detected geometry using:
# -C, --cylinders <number> set the number of cylinders to use
# -H, --heads <number> set the number of heads to use
# -S, --sectors <number> set the number of sectors to use
# # sfdisk的-D参数指定与DOS兼容,并自动在每个分区前预留空间,以存放MBR(Master Boot Record);
#
# <start>, <size>, <id>, <bootable>
#
# bootable 可以指定为[*|-]格式,默认值是"-"也就是没有可引导标记。
# 这个标记仅对DOS有意义:DOS会给带有可引导标记的主分区分配 C: 盘符
#
# id 应该以无"0x"前缀的格式给出其十六进制值,或者[E|S|L]简写字母:
# L()是默认值;
# S(,LINUX_SWAP);
# E(,扩展分区)。
#
# 第一行分区描述,,0x0C,* 自动分配起始柱面,数量为9,分区ID为0x0C(表示FAT32分区),<bootable>为*, 表示可启动分区。
# 第二行分区描述10,,,- 同样自动分配起柱面,数量为115,其它为默认。
# 第三行分区描述126,,,- 同样自动分配起柱面,剩下所有的数量,其它为默认。
sfdisk -D -H -S -C $CYLINDERS $DRIVE << EOF
,,0x0C,*
,,,-
,,,-
EOF # 这里可以得到一张FAT32分区的SD卡,我有时候我们就只需要一张这样的卡
# sfdisk -D -H -S -C $CYLINDERS $DRIVE << EOF
# ,,0x0C,*
# EOF # 格式化各个分区,格式化完卸载对应的分区
mkfs.vfat -F -n "boot" ${DRIVE}
umount ${DRIVE}
mkfs.ext3 -L "rootfs" ${DRIVE}
umount ${DRIVE}
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. 在HTTP通讯过程中,是客户端还是服务端主动断开连接?

    比如说:IE访问IIS,获取文件,肯定是要建立一个连接,这个连接在完成通讯后,是客户端Close了连接,还是服务端Close了连接.我用程序测模拟IE和IIS,都没有收到断开连接的消息,也就是都没有触 ...

  2. PHP实体层基础类

    PHP实体层基础类 class BaseModel { private $tableName; private $fields=array(); function __construct() { $t ...

  3. Linux安装keepalived

    1.下载安装ipvs安装包,进行解压 http://www.keepalived.org/software/ 2.创建安装路径连接 安装环境: yum -y install openssl-devel ...

  4. 嵌入式 Web workers

    前言 虽然worker可以将复杂的运算放入单独线程去运算,不阻塞UI线程,但是,由于worker()的构造函数的参数不能读取本地的文件,只能来自网络,所以当在一个项目里想使用本地的模块函数,是一个很麻 ...

  5. em和px的区别一次彻底搞清楚!

    在国内网站中,包括三大门户,以及“引领”中国网站设计潮流的蓝色理想,ChinaUI等都是使用了px作为字体单位.只有百度好歹做了个可调的表率.而 在大洋彼岸,几乎所有的主流站点都使用em作为字体单位, ...

  6. Linux命令详解-date

    在linux环境中,不管是编程还是其他维护,时间是必不可少的,也经常会用到时间的运算,熟练运用date命令来表示自己想要表示的时间,肯定可以给自己的工作带来诸多方便. 1.命令格式:   date [ ...

  7. jQuery-瀑布流的取巧做法分享

      分析:瀑布流,做法有2种 (1)绝对定位方案:每个单元格设置为绝对定位,通过计算,分别设置 top , left 即可实现 (2)浮动方案:弄N列布局(浮动),然后图片数据,按顺序依次插入,如N为 ...

  8. 【Raspberry pi】cpu、内存等查看及扩展

    使用树莓派时,需要在其系统中部署几个不同功能的程序系统,并涉及到数据库读写.串口读写.web访问等,使系统使用压力较大,在查看树莓派使用情况时也遇到些许问题. free命令 total used fr ...

  9. TCP的time_wait、close_wait状态

    转载:http://huoding.com/2013/12/31/316  http://blog.csdn.net/lxnkobe/article/details/7525317  http://k ...

  10. 简单粗暴地理解js原型链–js面向对象编程

    简单粗暴地理解js原型链–js面向对象编程 作者:茄果 链接:http://www.cnblogs.com/qieguo/archive/2016/05/03/5451626.html 原型链理解起来 ...