1:查看sd卡對應的device,使用命令sudo fdisk -l
1 hy@hy-VirtualBox:~/Desktop/image/yocto315$ sudo fdisk -l 2 Disk /dev/sda: 2 TiB, 2199022206976 bytes, 4294965248 sectors 3 Units: sectors of 1 * 512 = 512 bytes 4 Sector size (logical/physical): 512 bytes / 512 bytes 5 I/O size (minimum/optimal): 512 bytes / 512 bytes 6 Disklabel type: dos 7 Disk identifier: 0x1d291c55 8 9 Device Boot Start End Sectors Size Id Type 10 /dev/sda1 * 2048 4286578687 4286576640 2T 83 Linux 11 /dev/sda2 4286580734 4294963199 8382466 4G 5 Extended 12 /dev/sda5 4286580736 4294963199 8382464 4G 82 Linux swap / Solaris 13 14 15 Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors 16 Units: sectors of 1 * 512 = 512 bytes 17 Sector size (logical/physical): 512 bytes / 512 bytes 18 I/O size (minimum/optimal): 512 bytes / 512 bytes 19 Disklabel type: dos 20 Disk identifier: 0xa73bd1f4 21 22 Device Boot Start End Sectors Size Id Type 23 /dev/sdb1 2048 800767 798720 390M e W95 FAT16 (LBA) 24 /dev/sdb2 800768 8000000 7199233 3.4G 83 Linux
我們可以看到我們sd卡對應的device為/dev/sdb
2:創建分區 sudo fdisk /dev/sdc
1 hy@hy-VirtualBox:~$ sudo fdisk /dev/sdc 2 3 Welcome to fdisk (util-linux 2.27.1). 4 Changes will remain in memory only, until you decide to write them. 5 Be careful before using the write command. 6 7 8 Command (m for help): m 9 10 Help: 11 12 DOS (MBR) 13 a toggle a bootable flag 14 b edit nested BSD disklabel 15 c toggle the dos compatibility flag 16 17 Generic 18 d delete a partition 19 F list free unpartitioned space 20 l list known partition types 21 n add a new partition 22 p print the partition table 23 t change a partition type 24 v verify the partition table 25 i print information about a partition 26 27 Misc 28 m print this menu 29 u change display/entry units 30 x extra functionality (experts only) 31 32 Script 33 I load disk layout from sfdisk script file 34 O dump disk layout to sfdisk script file 35 36 Save & Exit 37 w write table to disk and exit 38 q quit without saving changes 39 40 Create a new label 41 g create a new empty GPT partition table 42 G create a new empty SGI (IRIX) partition table 43 o create a new empty DOS partition table 44 s create a new empty Sun partition table 45 46 Command (m for help):
3:我們需要創建兩個分區
1 Command (m for help): n 2 Partition type 3 p primary (2 primary, 0 extended, 2 free) 4 e extended (container for logical partitions) 5 Select (default p): 6 7 Using default response p. 8 Partition number (3,4, default 3): 9 First sector (8388608-62333951, default 8388608): 10 Last sector, +sectors or +size{K,M,G,T,P} (8388608-62333951, default 62333951): 11 12 Created a new partition 3 of type 'Linux' and of size 25.7 GiB.
4:使用w寫入分區信息
1 Command (m for help): w 2 The partition table has been altered. 3 Calling ioctl() to re-read partition table. 4 Re-reading the partition table failed.: Device or resource busy 5 6 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).
5: 執行: sudo partprobe
6:因為要制作可以啟動linux內核的sd卡,所以需要設置2個不同格式的分區(如果要啟動android,需要制作三個)
這兩個分區格式一個為;msdos,另外一個為ext3/ext4
msdos分區格式制作
1 sudo mkfs.msdos /dev/sdb1 2 mkfs.fat 3.0.28 (2015-05-16) 3 mkfs.msdos: /dev/sdc1 contains a mounted filesystem.
備注:如果出現以上情況,可以通過win10自帶的磁盤管理工具將對應的分區格式化,但是sudo mkfs.msdos /dev/sdb1必須執行
ext3/ext4分區制作
1 sudo mkfs.ext4 /dev/sdc1
7:拷貝
一般把uimage和設備樹文件拷貝到msdos分區內
文件系統拷貝到ext3/ext4分區內