Linux下格式化U盘及分区

来源:互联网 发布:同花顺中天软件下载 编辑:程序博客网 时间:2024/06/05 01:16

前言:该问题是在hi3516下通过U盘实现自动升级时,遇到了不能挂载U盘的分区。打印log如下:

U-Boot 2010.06-dirty (Jul 04 2016 - 14:39:59)Check spi flash controller v350... FoundSpi(cs1) ID: 0xC2 0x20 0x19 0xC2 0x20 0x19Spi(cs1): Block:64KB Chip:32MB Name:"MX25L 256/257 35 E/F"MMC:   MMC FLASH INIT: No card on slot!In:    serialOut:   serialErr:   serialUSB:   scanning bus for devices... 2 USB Device(s) foundusb_stor_get_info->1438,blksz:5121 Storage Device(s) found** Partition 1 not valid on device 0 **Hit any key to stop autoboot:  032768 KiB hi_sfc at 0:0 is now current device

后来分析发现,该U盘有多个分区,而hi3516的uboot升级镜像必须放在主分区分区才能被识别,因此在Linux下降U盘重新分区,然后格式化,问题解决了。注意:windows下对U盘格式化时,并不能删除U盘的分区信息。


给U盘分区(使用fdisk对U盘进行分区)

  • 用 fdisk 工具分区
    ~ $ fdisk 设备节点
    回车后,输入命令 m,根据帮助信息继续进行以下的操作。

  • 查看当前状态
    在控制台的提示符下,输入命令 p,查看当前分区状态:
    Command (m for help): p
    控制台显示出分区状态信息:
    Disk /dev/mmc/blk1/disc: 127 MB, 127139840 bytes
    8 heads, 32 sectors/track, 970 cylinders
    Units = cylinders of 256 * 512 = 131072 bytes
    Device Boot Start End Blocks Id System
    上面信息表明设备没有分区,需要按照“2.1.2 创建新的分区”和“2.1.3 保存分区信
    息”的描述对设备进行分区。

  • 创建新的分区
    创建新的分区步骤如下:

    • 步骤 1. 创建新的分区。
      在提示符下输入命令 n,创建新的分区:
      Command (m for help): n
      控制台显示出如下信息:
      Command action
      e extended
      p primary partition (1-4)

    • 步骤 2. 建立主分区。
      输入命令 p,选择主分区:
      p

    • 步骤 3. 选择分区数。
      本例中选择为 1,输入数字 1:
      Partition number (1-4): 1
      控制台显示出如下信息:
      First cylinder (1-970, default 1):

    • 步骤 4. 选择起始柱面。
      本例选择默认值 1,直接回车:
      Using default value 1

    • 步骤 5. 选择结束柱面。
      本例选择默认值 970,直接回车:
      Last cylinder or +size or +sizeM or +sizeK (1-970, default 970):
      Using default value 970

    • 步骤 6. 选择系统格式。
      由于系统默认为 Linux格式,本例中选择 Win95 FAT格式,输入命令 t 进行修改:
      Command (m for help): t
      Selected partition 1
      输入命令 b,选择 Win95 FAT 格式:
      Hex code (type L to list codes): b
      输入命令 l,可以查看 fdisk 所有分区的详细信息:
      Changed system type of partition 1 to b (Win95 FAT32)

    • 步骤 7. 查看分区状态。
      输入命令 p,查看当前分区状态:
      Command (m for help): p
      控制台显示出当前分区状态信息,表示成功分区。

  • 保存分区信息
    输入命令 w,写入并保存分区信息到设备:
    Command (m for help): w
    控制台显示出当前设备信息,表示成功写入分区信息到设备:
    The partition table has been altered!
    Calling ioctl() to re-read partition table.
    …………
    ~ $

格式化U盘(使用mkdosfs工具格式化U盘为fat32格式)

  • mkdosfs –F 32 设备分区名(一般为/dev/sda)
0 0
原创粉丝点击