一、对SD卡分区
1.将SD卡连接到PC机上,查看其设备名称
输入# dmesg|tail -20
......
[16392.819300] sd 16:0:0:0: [sdb] 31291392 512-byte logical blocks: (16.0 GB/14.9 GiB)
[16392.827038] sd 16:0:0:0: [sdb] Write Protect is off
[16392.827042] sd 16:0:0:0: [sdb] Mode Sense: 03 00 00 00
[16392.827044] sd 16:0:0:0: [sdb] Assuming drive cache: write through
[16392.848523] sd 16:0:0:0: [sdb] Assuming drive cache: write through
[16392.848530]
[16392.863252] sd 16:0:0:0: [sdb] Assuming drive cache: write through
[16392.863265] sd 16:0:0:0: [sdb] Attached SCSI removable disk
2.使用fdisk工具进入sdb(设备名)
输入# sudo fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
Command (m for help):进入到fdisk模式
3.查看分区
Command (m for help): p
Disk /dev/sdb: 16.0 GB, 16021192704 bytes
255 heads, 63 sectors/track, 1947 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b0e64c8
如果有分区可以用“Command (m for help): d”删除分区
4.开始分区
Command (m for help): n
Command action
Partition number (1-4): 1(第一个分区)
First cylinder (1-1947, default 1):直接回车
Last cylinder, +cylinders or +size{K,M,G} (1-1947, default 1947): +50MB(第一分区大小)
第二个分区
Command (m for help): n
Command action
Partition number (1-4): 2 (第二个分区)
First cylinder (8-1947, default 8):直接回车
Last cylinder, +cylinders or +size{K,M,G} (8-1947, default 1947):直接回车(其他都为第二分区)
5.查看分区
Command (m for help): p
Disk /dev/sdb: 16.0 GB, 16021192704 bytes
255 heads, 63 sectors/track, 1947 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b0e64c8
/dev/sdb1
/dev/sdb2
6.修改分区类型,将第一分区改成“b W95 FAT32”格式
Command (m for help): t
Partition number (1-4): 1(修改第一分区)
Hex code (type L to list codes): L(查看类型列表)
Changed system type of partition 1 to b (W95 FAT32)
7.再次查看分区
Command (m for help): p
Disk /dev/sdb: 16.0 GB, 16021192704 bytes
255 heads, 63 sectors/track, 1947 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b0e64c8
/dev/sdb1
/dev/sdb2
8.保存退出
Command (m for help): w(保存退出)
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x
二、对SD卡每个分区格式化
输入# sudo mkfs.vfat /dev/sdb1
输入# sudo mkfs.ext3 /dev/sdb2
三、将uImage内核和rootfs文件系统拷贝或解压到对应的分区中
四、设置U-Boot启动参数
U-boot # set ramaddr 4000000
U-boot # set kfile uImage
U-boot # set bootcmd 'mmc;fatload mmc 0:1 $(ramaddr) $(kfile);
U-boot # set bootargs console=ttyS0,38400 mem=256M root=/dev/mmcblk0p2 init=/linuxrc rootwait
U-boot # saveenv
注:U盘启动方法相同,只是设备名是sda、sdb等,设置bootargs参数时root=/dev/sda1(或sda2)等等。