tiny210 ubuntu下sd卡分区

1、ubuntu实现SD-Flasher.exe原理
友善官方给出的烧录uboot的工具是SD-Flasher.exe,这个工具只能在windows下使用。由于本人电脑无法打开这个工具,所以在windows下无法制作sd启动卡。

看了官方文档介绍,SD-Flasher.exe原理是在sd卡前面预留130M,然后在这个空白的130M区域内烧入uboot,在ubuntu下可以使用fdisk和dd命令实现同样的操作。

2、格式化sd卡
在进行该操作前,需要先将sd卡分区,使用fdisk命令进行分区。
插入sd卡,先对sd卡进行格式化。查看sd卡在/dev下的设备名称,一般名称为/dev/sdb或者/dev/sdc等

查看sd卡挂载情况

mount -l | grep sdb

/dev/sdb1 on /media/chen/5B69-318F type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)
/dev/sdb3 on /media/chen/5BA3-8E79 type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)

可以看到我的sd卡分别挂载了1和3分区,现将这两个分区卸载

umount /media/chen/5B69-318F
umount /media/chen/5BA3-8E79

格式化sd卡成fat32格式

sudo mkfs.vfat -I /dev/sdb

清空sd卡的分区表

sudo dd if=/dev/zero of=/dev/sdb bs=512 count=1

3、制作sd启动盘:
sudo dd iflag=dsync oflag=dsync if=tiny210v2-uboot.bin of=/dev/sdb seek=1
这里seek=1,跳过sd卡第一个block,因为sd卡开始的512个字节用来存放分区表。其中tiny210v2-uboot.bin来自http://blog.csdn.net/liukun321/article/details/7438880

4、创建uboot和kernel分区

在sd卡起始130M的地方创建第一个分区,前面按照友善文档预留130M,其实可以不需要预留这么大空间。
这里我们设定第一个分区的大小为100M。

sudo fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc3f695a7.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

命令(输入 m 获取帮助): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
245 heads, 62 sectors/track, 1021 cylinders, total 15523840 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3f695a7

   设备 启动      起点          终点     块数   Id  系统

命令(输入 m 获取帮助): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
分区号 (1-4,默认为 1): 1
起始 sector (2048-15523839,默认为 2048): 268288
Last sector, +扇区 or +size{K,M,G} (268288-15523839,默认为 15523839): +100M

命令(输入 m 获取帮助): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
245 heads, 62 sectors/track, 1021 cylinders, total 15523840 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3f695a7

   设备 启动      起点          终点     块数   Id  系统
/dev/sdb1          268288      473087      102400   83  Linux

指定分区格式为fat32,因为uboot支持fat32的文件系统,所以可以在uboot启动后通过fatload mmc命令把分区中的uboot文件和kernel文件读取出来。

命令(输入 m 获取帮助): t
Selected partition 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

命令(输入 m 获取帮助): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
245 heads, 62 sectors/track, 1021 cylinders, total 15523840 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3f695a7

   设备 启动      起点          终点     块数   Id  系统
/dev/sdb1          268288      473087      102400    b  W95 FAT32

命令(输入 m 获取帮助): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

然后对分区进行格式化,格式化成fat32

sudo mkfs -t vfat /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)

5、增加文件系统分区
第二个分区用于存放文件系统,格式为ext3,创建过程和第一个分区类似

sudo fdisk /dev/sdb

命令(输入 m 获取帮助): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
36 heads, 28 sectors/track, 15400 cylinders, total 15523840 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3f695a7

   设备 启动      起点          终点     块数   Id  系统
/dev/sdb1          268288      473087      102400    b  W95 FAT32

命令(输入 m 获取帮助): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
分区号 (1-4,默认为 2): 2
起始 sector (2048-15523839,默认为 2048): 473088
Last sector, +扇区 or +size{K,M,G} (473088-15523839,默认为 15523839): +2G

命令(输入 m 获取帮助): t
分区号 (1-4): 2
Hex code (type L to list codes): 83

命令(输入 m 获取帮助): p

Disk /dev/sdb: 7948 MB, 7948206080 bytes
36 heads, 28 sectors/track, 15400 cylinders, total 15523840 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3f695a7

   设备 启动      起点          终点     块数   Id  系统
/dev/sdb1          268288      473087      102400    b  W95 FAT32
/dev/sdb2          473088     4667391     2097152   83  Linux

命令(输入 m 获取帮助): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

格式化成ext4格式

sudo mkfs -t ext4 /dev/sdb2
mke2fs 1.42.9 (4-Feb-2014)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912

Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成 

这样就创建好了二个分区,第一个分区用来分别存放uboot、kernel,第二个分区用来存放filesystem。如果后面还要增加分区的话,则第四个分区必须是扩展分区,因为主分区和扩展分区最多只能4个。

因为windows下默认只显示sd卡第一个分区,所以当把sd卡插入到windows下的时候显示的可用容量只有10M,这是因为我们的第一个分区用来存放uboot,大小设置为10M,所以windows下显示只有10M可用。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值