How to Make 3 Partition SD Card 中文手册

How to Make 3 Partition SD Card

 

/******************************************************************

*      author:       卢浩

*      time:          2012.09.12

*      environment:   ubuntu10.04LTS +TI AM3359

*      kernel version:  linux-3.2

*      QQ Group For Technology Exchange122879839

******************************************************************/

 

 

 

首先在linux主机上建立一个文件,命名为mk3PartSDCard,把下面段代码复制进去并保存

 

 

 

 

#! /bin/sh

# mk3PartSDCard.sh v0.3

# Licensed under terms of GPLv2

 

DRIVE=$1

 

dd if=/dev/zero of=$DRIVE bs=1024 count=1024

 

SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`

 

echo DISK SIZE - $SIZE bytes

 

CYLINDERS=`echo $SIZE/255/63/512 | bc`

 

sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF

,9,0x0C,*

10,115,,-

126,,,-

EOF

 

mkfs.vfat -F 32 -n "boot" ${DRIVE}1

umount ${DRIVE}1

mkfs.ext3 -L "rootfs" ${DRIVE}2

umount ${DRIVE}2

mkfs.ext3 -L "START_HERE" ${DRIVE}3

 

插上你的SD卡,并且让linux主机识别到改变文件的可执行属性

user@UbuntuVbox1004:~$chmod 755 mk3PartSDCard

在命令终端输入df -hT来显示挂载分区情况

 

 

执行这个脚本之前请umount你的SD

user@Ubuntu1004:~$umount /dev/sdb1然后执行这个脚本

user@Ubuntu1004:~$sudo ./mk3PartSDCard /dev/sdb然后你会看到

 

user@UbuntuVbox1004:~$ sudo ./mk3PartSD /dev/sdb

[sudo] password for user:

1024+0 records in

1024+0 records out

1048576 bytes (1.0 MB) copied, 1.53109 s, 685 kB/s

Disk /dev/sdb doesn't contain a valid partition table

DISK SIZE - 1977614336 bytes

Checking that no-one is using this disk right now ...

OK

 

Disk /dev/sdb: 240 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature

/dev/sdb: unrecognized partition table type

Old situation:

No partitions found

New situation:

Units = cylinders of 8225280 bytes, blocks of 1024 bytes,counting from 0

 

Device  Boot    Start  End     #cyls   #blocks         Id System

/dev/sdb1 *    0+  8  9-  72261       cW95 FAT32 (LBA)

/dev/sdb2  10  124    115     923737+         83 Linux

/dev/sdb3  126     239    114     915705     83 Linux

/dev/sdb4  0   - 0    0   0       Empty

Successfully wrote the new partition table

Re-reading the partition table ...

 

If you created or changed a DOS partition, /dev/foo7, say,then use dd(1)

to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7bs=512 count=1

(See fdisk(8).)

mkfs.vfat 3.0.7 (24 Dec 2009)

umount: /dev/sdb1: not mounted

mke2fs 1.41.11 (14-Mar-2010)

Filesystem label=rootfs

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

57856 inodes, 230934 blocks

11546 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=239075328

8 block groups

32768 blocks per group, 32768 fragments per group

7232 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information:done

 

This filesystem will be automatically checked every 20 mountsor

180 days, whichever comes first. Use tune2fs -c or -i tooverride.

umount: /dev/sdb2: not mounted

mke2fs 1.41.11 (14-Mar-2010)

Filesystem label=START_HERE

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

57232 inodes, 228926 blocks

11446 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=234881024

7 block groups

32768 blocks per group, 32768 fragments per group

8176 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information:done

 

This filesystem will be automatically checked every 27 mountsor

180 days, whichever comes first. Use tune2fs -c or -i tooverride.

然后输入这些

user@Ubuntu1004:~$ umount /dev/sdb1

user@Ubuntu1004:~$ umount /dev/sdb2

user@Ubuntu1004:~$ umount /dev/sdb3

再输入df -hT查看分区情况

 

 

记住第一个分区/media/boot用来存放MLO   uboot.bin  uImage

第二个分区/media/rootfs用来存放你的文件系统


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值