linux-sfdisk用法说明


[root@ /]#sfdisk --force -uM /dev/mmcblk1 << EOF
2> 0,256,83
2> 256,128,83
> 384,,83
E> EOF

( <start> <size> <id><bootable> <c,h,s> <c,h,s>)

#!/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

83Linux分区标识

 

Ubootkernel是直接使用dd写入mmcblk0中的,而分区则是使用sfdisk进行的,空出了ubootkernel的位置,从起始地址10MB开始的。

 

INPUT FORMAT

      sfdisk reads lines of the form

             <start> <size> <id><bootable> <c,h,s> <c,h,s>

      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 <c,h,s> parts can (and probably should) be omitted - sfdiskcomputes them from <start> and <size> and the disk geometry asgiven by the kernel or speci?

      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.

 

猜你喜欢

转载自blog.csdn.net/ccwzhu/article/details/80752675