How to Make 3 Partition SD Card

Prepare Script

Create a file on the Linux host named mk3PartSDCard.  Copy the contents of the script (see below) to this file and save it.  See the later section for the contents of the two partition script.

This script requires a single input parameter which must be the device which is connected to the USB card reader.  DO NOT RUN THE SCRIPT IF YOU ARE NOT COMPLETELY SURE THAT YOU HAVE ENTERED THE CORRECT DEVICE TO USE.  If you specify the device connect to the host machine hard drive instead of the SD card reader, you will destroy the hard drive of your host machine.  The next section shows how to figure out which device is connected the SD card and which is connected to the hard drive.

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

Make the script executable with the following command

user@UbuntuVbox1004:~$ chmod 755 mk3PartSDCard

Run Script

After verifying the correct device that you must send to the script, it is necessary to unmount any directory that is mounted to the device.  In the example above, the directory /media/disk is mounted to /dev/sdb1.  To unmount run the following command

user@Ubuntu1004:~$ umount /dev/sdb1

The script must be executed with supre-user permissions.  In Ubuntu, this is done by pre-pending the command with "sudo".  When prompted for a password by sudo, use the password of the user account.

user@Ubuntu1004:~$ sudo ./mk3PartSDCard /dev/sdb

On a successful execution the terminal will look something like the following.  The error that may come from sfdisk (as shown below) can be safely ignired.

http://processors.wiki.ti.com/index.php/How_to_Make_3_Partition_SD_Card
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值