linux环境下,手动制作嵌入式设备sd启动卡

一、卸载sdb卡

bhj@ubuntu:~$ sudo umount /dev/sdb1
bhj@ubuntu:~$ sudo umount /dev/sdb2
bhj@ubuntu:~$ 

二、分区
bhj@ubuntu:~$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


命令(输入 m 获取帮助): p
Disk /dev/sdb: 3.7 GiB, 3965190144 bytes, 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
Disklabel type: dos
Disk identifier: 0x4843c375

设备       启动   Start  末尾  扇区  Size Id 类型
/dev/sdb1          2048 1026048 1024001  500M  c W95 FAT32 (LBA)
/dev/sdb2       1028096 7744511 6716416  3.2G 83 Linux

命令(输入 m 获取帮助): d
分区号 (1,2, default 2): 1

Partition 1 has been deleted.

命令(输入 m 获取帮助): d
Selected partition 2
Partition 2 has been deleted.

命令(输入 m 获取帮助): 2
2: unknown command

命令(输入 m 获取帮助): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


命令(输入 m 获取帮助): p

Disk /dev/sdb: 3.7 GiB, 3965190144 bytes, 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
Disklabel type: dos
Disk identifier: 0x4843c375

命令(输入 m 获取帮助): x

专家命令(输入 m 显示帮助): h
磁头数 (1-256, default 122): 255

专家命令(输入 m 显示帮助): s
扇区数 (1-63, default 62): 63

专家命令(输入 m 显示帮助): c
柱面数 (1-1048576, default 482): 482

专家命令(输入 m 显示帮助): r

命令(输入 m 获取帮助): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
分区号 (1-4, default 1): 1
First sector (2048-7744511, default 2048): +1024000
Value out of range.
First sector (2048-7744511, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-7744511, default 7744511): +1024000 //注意!此处有加号

Created a new partition 1 of type 'Linux' and of size 500 MiB.

命令(输入 m 获取帮助): t
Selected partition 1
Partition type (type L to list all types): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

命令(输入 m 获取帮助): a //切换可引导标志,否则无法引导启动
Selected partition 1
The bootable flag on partition 1 is enabled now.

命令(输入 m 获取帮助): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
分区号 (2-4, default 2): 2
First sector (1026049-7744511, default 1028096): 
Last sector, +sectors or +size{K,M,G,T,P} (1028096-7744511, default 7744511): 

Created a new partition 2 of type 'Linux' and of size 3.2 GiB.

命令(输入 m 获取帮助): p
Disk /dev/sdb: 3.7 GiB, 3965190144 bytes, 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
Disklabel type: dos
Disk identifier: 0x4843c375

设备       启动   Start  末尾  扇区  Size Id 类型
/dev/sdb1  *       2048 1026048 1024001  500M  c W95 FAT32 (LBA)
/dev/sdb2       1028096 7744511 6716416  3.2G 83 Linux

命令(输入 m 获取帮助): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

三、格式化SD卡
bhj@ubuntu:~$ sudo mkfs.msdos -F 32 /dev/sdb
sdb   sdb1  sdb2  
bhj@ubuntu:~$ sudo mkfs.msdos -F 32 /dev/sdb
sdb   sdb1  sdb2  
bhj@ubuntu:~$ sudo mkfs.msdos -F 32 /dev/sdb1 -n FAT32
mkfs.fat 3.0.28 (2015-05-16)

到此创建Linux的启动SD卡完成,需要注意的一点是,有时需要重新再Windows下再次使用FAT32格式化第一个引导分区FAT32,才能成功引导Linux。(请不要使用快速格式化)
 

你可能感兴趣的:(其他)