如何在Linux上格式化并创建分区
2015-12-29 16:07
477 查看
在开发的时候经常会遇到系统使用 /dev/block/mmcblk0p1 而不是 /dev/block/mmcblk0
表现出来的现象是:
/dev/mmcblk0p1: No such file or directory
一般SD卡默认都是只有/dev/block/mmcblk0, 因此需要格式化并创建一个分区,
这里使用的是Ubuntu自带的fdisk工具, 方法如下:
1. 先删除所有分区:
#sudo fdisk /dev/sdb
#d
#1
#d
#2
根据提示删除所有的分区。
2. 新创建一个分区:
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-7744511, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-7744511, default 7744511):
Using default value 7744511
3. 保存改动并退出:
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
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)
Syncing disks.
4. 查看分区是否创建成功
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
106 heads, 30 sectors/track, 2435 cylinders, total 7744512 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 7744511 3871232 83 Linux
4. 重新插拔
5. 格式化为fat32
#sudo mkfs.vfat -I /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)
表现出来的现象是:
/dev/mmcblk0p1: No such file or directory
一般SD卡默认都是只有/dev/block/mmcblk0, 因此需要格式化并创建一个分区,
这里使用的是Ubuntu自带的fdisk工具, 方法如下:
1. 先删除所有分区:
#sudo fdisk /dev/sdb
#d
#1
#d
#2
根据提示删除所有的分区。
2. 新创建一个分区:
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-7744511, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-7744511, default 7744511):
Using default value 7744511
3. 保存改动并退出:
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
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)
Syncing disks.
4. 查看分区是否创建成功
Command (m for help): p
Disk /dev/sdb: 3965 MB, 3965190144 bytes
106 heads, 30 sectors/track, 2435 cylinders, total 7744512 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 7744511 3871232 83 Linux
4. 重新插拔
5. 格式化为fat32
#sudo mkfs.vfat -I /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)
相关文章推荐
- 最重要,最常用和有用的Linux命令大集合
- 安装archlinux时遇到的问题--grub安装失败
- Linux I/O优化 磁盘读写参数设置
- LINUX HOOK
- 树莓派安装centos7
- 为Linux用ISO制作U盘启动及基本原理
- RedHat6使用Centos6的yum源
- linux 使用ls与du查看的大小不一样
- Linux运维 第三阶段 (十五)理解LNMP
- 虚拟机与Linux操作系统的安装步骤
- 互斥量--linux多线程的运用
- Vmware 安装CentOS7时连不上网问题的解决
- 启动HDFS遇到问题
- Linux下mysql5.7安装
- linux消耗CPU的shell脚本
- Centos7-NFS server - 笔记
- Desktop Entry,关于Linux如何创建桌面快捷方式
- 在阿里云的CentOS环境中安装django
- linux系统dist-upgrade和upgrade的区别
- Synergy工具 共享Windows系统电脑Linux系统电脑 鼠标键盘