Chinaunix首页 | 论坛 | 博客
  • 博客访问: 565140
  • 博文数量: 127
  • 博客积分: 1169
  • 博客等级: 少尉
  • 技术积分: 1298
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-16 14:29
个人简介

空白

文章分类

全部博文(127)

分类: LINUX

2017-07-06 14:57:53

使用fdisk分区和格式化emmc存储

这里主要记录fdisk命令的常用使用方法,如何对emmc做最基本的如分区,格式化等操作。

1、根据系统启动信息,查看emmc的基本信息
硬件上电启动,在内核的启动信息中找到了如下信息:

emmc在/dev下的设备文件为:mmcblk0, 使用ls名查看/dev目录下文件,确认mmcblk0设备文件存在;如果存在进行下一步fdisk操作。

2、使用fdisk对emmc进行分区
2.1、对emmc进行分区
# fdisk /dev/mmcblk0
Device contains neither a valid DOS partition table, nor Sun, SGI, OSF or GPT disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.

The number of cylinders for this disk is set to 238592.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

2.2、使用m命令,获取fdisk使用帮助
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
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):

2.3、使用n命令,添加一个新的分区
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
选择p,添加主分区

2.4、选择分区号,选择1,
Partition number (1-4): 1                    // 选择分区号
First cylinder (1-238592, default 1): Using default value 1               // 选择分区的第一个柱面,选择1
Last cylinder or +size or +sizeM or +sizeK (1-238592, default 238592): Using default value 238592  // 选择最后一个柱面

可以使用同样的方式添加第二、第三等分区。

2.5、是用p命令,显示分区信息
Command (m for help): p

Disk /dev/mmcblk0: 7818 MB, 7818182656 bytes
4 heads, 16 sectors/track, 238592 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1               1      238592     7634936  83 Linux

2.6、使用t命令,设置分区格式
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): l

 0 Empty                  1b Hidden Win95 FAT32     9f BSD/OS                
 1 FAT12                  1c Hidden W95 FAT32 (LBA) a0 Thinkpad hibernation  
 4 FAT16 <32M             1e Hidden W95 FAT16 (LBA) a5 FreeBSD               
 5 Extended               3c Part.Magic recovery    a6 OpenBSD               
 6 FAT16                  41 PPC PReP Boot          a8 Darwin UFS            
 7 HPFS/NTFS              42 SFS                    a9 NetBSD                
 a OS/2 Boot Manager      63 GNU HURD or SysV       ab Darwin boot           
 b Win95 FAT32            80 Old Minix              b7 BSDI fs               
 c Win95 FAT32 (LBA)      81 Minix / old Linux      b8 BSDI swap             
 e Win95 FAT16 (LBA)      82 Linux swap             be Solaris boot          
 f Win95 Ext'd (LBA)      83 Linux                  eb BeOS fs               
11 Hidden FAT12           84 OS/2 hidden C: drive   ee EFI GPT               
12 Compaq diagnostics     85 Linux extended         ef EFI (FAT-12/16/32)    
14 Hidden FAT16 <32M      86 NTFS volume set        f0 Linux/PA-RISC boot    
16 Hidden FAT16           87 NTFS volume set        f2 DOS secondary         
17 Hidden HPFS/NTFS       8e Linux LVM              fd Linux raid autodetect
Hex code (type L to list codes): 83

2.7、使用w命令,保存配置
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table

3、使用对应文件系统工具对分析进行格式化
# mkfs.ext4 /dev/mmcblk0p1
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
477664 inodes, 1908734 blocks
95436 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1954545664
59 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                            
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

完成。
阅读(14957) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~