您的位置:首页 > 运维架构 > Linux

emmc挂载,分区及格式化

2016-07-01 17:23 381 查看
该文章整合了一些网上的资源,如有侵权请告知,我会进行相应删除

1.linux 嵌入式时使用的emmc 最开始是没有进行分区设置的,所以系统要挂载emmc 需要先对emmc 进行分区及格式化。

首先需要使用fdisk 进行emmc 分区,下面为log 及说明

fdisk /dev/mmcblk1

Command (m for help): m        ---输入m获取fdisk工具的使用说明

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) 

Command (m for help): n                      ---输入n创建新的分区

Partition type: 

p primary (0 primary, 0 extended, 4 free) 

e extended 

Select (default p): p               ---输入p创建primary分区

Partition number (1-4, default 1): 1           ---输入分区号

First sector (2048-31116287, default 2048):              ---输入该分区的起始地址,回车使用默认值

Using default value 2048 

Last sector, +sectors or +size{K,M,G} (2048-31116287, default 31116287): 10000000           ---输入该分区的结束地址

Command (m for help): n         ---创建第二个分区

Partition type: 

p primary (1 primary, 0 extended, 3 free) 

e extended 

Select (default p): p 

Partition number (1-4, default 2): 2 

First sector (10000001-31116287, default 10000001): 

Using default value 10000001 

Last sector, +sectors or +size{K,M,G} (10000001-31116287, default 31116287): 20000000 

Command (m for help): n       ---创建第三个分区

Partition type: 

p primary (2 primary, 0 extended, 2 free) 

e extended 

Select (default p): p 

Partition number (1-4, default 3): 3 

First sector (20000001-31116287, default 20000001): 

Using default value 20000001 

Last sector, +sectors or +size{K,M,G} (20000001-31116287, default 31116287): 

Using default value 31116287 

Command (m for help): p       ---打印mmcblk1的分区情况

Disk /dev/sdb: 15.9 GB, 15931539456 bytes 

64 heads, 32 sectors/track, 15193 cylinders, total 31116288 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: 0x00090a89 

Device Boot Start End Blocks Id System 

/dev/sdb1 2048 10000000 4998976+ 83 Linux 

/dev/sdb2 10000001 20000000 5000000 83 Linux 

/dev/sdb3 20000001 31116287 5558143+ 83 Linux 

Command (m for help): t            ---修改分区的系统类型

Partition number (1-4): 1             ---选择要修改的分区号

Hex code (type L to list codes): l   ---打印可设置的系统类型

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 

1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 

2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 

3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 

4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 

5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 

6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 

7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 

8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 

9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access 

a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O 

b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor 

c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs 

e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT 

f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 

10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 

11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 

12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 

14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary 

16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS 

17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 

18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 

1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 

1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 

1e Hidden W95 FAT1 80 Old Minix 

Hex code (type L to list codes): c             ---设置第一分区为W95 FAT32 (LBA)格式

Changed system type of partition 1 to c (W95 FAT32 (LBA)) 

Command (m for help): t                       

Partition number (1-4): 2                    ---修改第二分区的系统类型

Hex code (type L to list codes): c 

Changed system type of partition 2 to c (W95 FAT32 (LBA)) 

Command (m for help): t 

Partition number (1-4): 3                    ---修改第三分区的系统类型

Hex code (type L to list codes): c 

Changed system type of partition 3 to c (W95 FAT32 (LBA)) 

Command (m for help): p                    ---打印mmcblk1的分区情况

Disk /dev/sdb: 15.9 GB, 15931539456 bytes 

64 heads, 32 sectors/track, 15193 cylinders, total 31116288 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: 0x00090a89 

Device Boot Start End Blocks Id System 

/dev/sdb1 2048 10000000 4998976+ c W95 FAT32 (LBA) 

/dev/sdb2 10000001 20000000 5000000 c W95 FAT32 (LBA) 

/dev/sdb3 20000001 31116287 5558143+ c W95 FAT32 (LBA) 

Command (m for help): w                   ---保存分区设置并退出

The partition table has been altered! 

Calling ioctl() to re-read partition table. 

执行:mkdosfs  /dev/mmcblk1p1            ---将/dev/mmcblk1p1格式化为FAT32格式

使用mount命令进行分区挂载<
4000
/span>

2.获取dosfstools(mkfs.vfat)源码

输入命令:

dpkg -S `type -p mkfs.vfat`  

这个命令会输出这个命令所在的包,如下是输出

dosfstools: /sbin/mkfs.vfat

 

type -p mkfs.vfat

是列出 mkfs.vfat命令所在的位置

/sbin/mkfs.vfat

 

dpkg -S是列出命令的包

 

第二步,下载这个包

apt-get source dosfstools

 

这样就得到了mkfs.vfat命令的源代码了

3.dosfstools的交叉编译

源码下面没有找相关的CC交叉编译环境的设置,直接使用make CC=arm-xxxx-xxx-gcc 即可直接进行交叉编译
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux emmc