为什么SD卡在Linux下/dev下的设备名叫mmcblk0p1?
SD/MMC 卡的设备构造差不多,MMC 应该是 SD 的前身,不过 MMC 当时的设计比SD 小一半。
所以,SD/MMC 的驱动通用,进一步的,Linux 的设备节点就延续了 MMC 的这个名字,后面的 blk 是块设备这个英文的简写, mmcblk 也就是“mmc/sd 块设备”,0 就是这个 mmc/sd 设备的顺序编号,p1 就是第一个分区。
#!/bin/sh
# partition size in MB
BOOT_ROM_SIZE=10 MBR数据区,10MB
ROOT_SYSTEM_SIZE=150
# call sfdisk to create partition table
# destroy the partition table
node=$1
dd if=/dev/zero of=${node} bs=1024 count=1 清除分区表MBR
sfdisk --force -uM ${node} << EOF
${BOOT_ROM_SIZE},${ROOT_SYSTEM_SIZE},83
,,83 将其他所有空间再分成一个区,,此处应该就是mmcblk0p2了。
EOF
83是Linux分区标识
Uboot和kernel是直接使用dd写入mmcblk0中的,而分区则是使用sfdisk进行的,空出了uboot和kernel的位置,从起始地址10MB开始的。
INPUT FORMAT
sfdisk reads lines of the form
where each line fills one partition descriptor.
Fields are separated by whitespace, or comma or semicolon possiblyfollowed by whitespace; initial and trailing whitespace is ignored. Numbers can be
octal, decimal or hexadecimal, decimal is default. When a field is absent or empty, a defaultvalue is used.
The
fied using the -H, -S, -C flags.
Bootable is specified as [*|-], with as default not-bootable. (The value of this field is irrelevant forLinux - when Linux runs it has been booted already
- but might play a role for certain boot loadersand for other operating systems. Forexample, when there are several primary DOS partitions, DOS assigns
C: to the first among these that is bootable.)
Id is given inhex, without the 0x prefix, or is [E|S|L|X], where L (LINUX_NATIVE (83)) is thedefault, S is LINUX_SWAP (82), E is EXTENDED_PARTITION (5),
and X is LINUX_EXTENDED (85).
The default value of start is the first nonassigned sector/cylinder/...
The default value of size is as much as possible (until next partitionor end-of-disk).
However, for the four partitions inside an extended partition, thedefaults are: Linux partition, Extended partition, Empty, Empty.
But when the -N option (change a single partition only) is given, the defaultfor each field is its previous value
EXAMPLE
The command
sfdisk /dev/hdc << EOF
0,407
,407
;
;
EOF
will partition /dev/hdc just as indicated above.
The command
sfdisk/dev/hdb << EOF
,3,L
,60,L
,19,S
,,E
,130,L
,130,L
,130,L
,,L
EOF
will partition /dev/hdb into two Linux partitions of 3 and60 cylinders, a swap space of 19 cylinders, and an extended partition coveringthe rest. Inside
the extended partition there are four Linux logical partitions, three of130 cylinders and one covering the rest.
With the -x option, the number of input lines must be a multiple of 4:you have to list the two empty partitions that you never want using twoblank lines.
Without the -x option, you giveone line for the partitions inside a extended partition, instead of four, andterminate with end-of-file (^D). (Andsfdisk
will assume that your input line represents the first of four, that thesecond one is extended, and the 3rd and 4th are empty.