步骤一:
查看系统中是否有
步骤二:
sudo fdisk /dev/sdb
输入m
会出现命令类表,简洁而强大
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
输入p
查看当前sd卡的分区(partition)信息
Command (m for help): p
Disk /dev/sdb: 7948 MB, 7948206080 bytes
245 heads, 62 sectors/track, 1021 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 1048576 523264+ c W95 FAT32 (LBA)
/dev/sdb2 1048577 15523839 7237631+ 83 Linux
其中,需要记住的是他的容量7948206080 bytes
之后会用到。
同时也留意他的heads和setcors/track
输入d
删除(delete)所有sd卡分区。因为有2个分区,需要删除2次
Command (m for help): d
Partition number (1-4): 1
Command (m for help): d
Selected partition 2
输入n
新建(new)一个分区
输入p
选择新建一个主分区
输入1
创建分区1
输入分区1的‘First sector’和‘Last sector’
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-15523839, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-15523839, default 15523839):
Using default value 15523839
在新建分区时可以根据实际情况设置分区大小,如果不设置,直接进行回车,会使用默认值。
输入w
将建立完成对分区表写入sd卡,并退出
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
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
步骤三:
sudo mkfs.ext3 /dev/sdb2 -L LABEL2
/dev/sdb2后面的参数根据情况进行设定 mkfs.ext3表示将分区格式化成ext3类型
说明:如果在ARM上进行格式化操作,则mkfs.ext3需要为交叉编译