ubuntu设置sd卡分区


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分区内





 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM