SD卡烧写过程
2025-08-04
10
0
通过fdisk -l查看系统中所有的存储设备和其下的分区信息
zzmt@zzmt:~/Desktop/images/files$ sudo fdisk -l
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: 0xf8c5367d
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 104857599 104855552 50G 83 Linux
Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 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: 0xa459e40c
Device Boot Start End Sectors Size Id Type
/dev/sdb1 8192 62333951 62325760 29.7G c W95 FAT32 (LBA)
查看到的设备为/dev/sdb
其下面的一个FAT32分区/dev/sdb1
执行下面的脚本对该设备进行分区并复制相关的文件
zzmt@zzmt:~/Desktop/images/files$ sudo ./imx6mksdboot.sh -device /dev/sdb -flash emmc -ddrsize 512
您已经选择开发板参数为:EMMC版本,DDR大小为512MB
即将进行制作SD系统启动卡,大约花费几分钟时间,请耐心等待!
************************************************************
* 注意:这将会清除/dev/sdb所有的数据 *
* 在脚本执行时请不要将/dev/sdb拔出 *
* 请按<Enter>确认继续 *
************************************************************
卸载 device '/dev/sdb1'
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.500141 s, 2.1 MB/s
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.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x53968c99.
Command (m for help): Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): Partition number (1-4, default 1): First sector (2048-62333951, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-62333951, default 62333951):
Created a new partition 1 of type 'Linux' and of size 64 MiB.
Command (m for help): Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): Partition number (2-4, default 2): First sector (133120-62333951, default 133120): Last sector, +sectors or +size{K,M,G,T,P} (133120-62333951, default 62333951):
Created a new partition 2 of type 'Linux' and of size 29.7 GiB.
Command (m for help): Partition number (1,2, default 2): Partition type (type L to list all types):
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
Command (m for help): Partition number (1,2, default 2):
The bootable flag on partition 1 is enabled now.
Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
格式化 /dev/sdb1 ...
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
格式化/dev/sdb2 ...
mke2fs 1.42.13 (17-May-2015)
/dev/sdb2 contains a ext3 file system labelled 'rootfs'
last mounted on Mon Aug 4 10:30:59 2025
Creating filesystem with 7775104 4k blocks and 1945888 inodes
Filesystem UUID: ce4c4bb4-f7d0-4658-a2ee-631368f4df0e
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
正在烧写u-boot-imx6ull-14x14-ddr512-emmc.imx到/dev/sdb
355+0 records in
355+0 records out
363520 bytes (364 kB, 355 KiB) copied, 0.11294 s, 3.2 MB/s
烧写u-boot-imx6ull-14x14-ddr512-emmc.imx到/dev/sdb完成!
正在准备复制...
正在复制设备树与内核到/dev/sdb1,请稍候...
复制设备树与内核到/dev/sdb1完成!
卸载/dev/sdb1
正在解压文件系统到/dev/sdb2 ,请稍候...
解压文件系统到/dev/sdb2完成!
正在解压模块到/dev/sdb2/lib/modules/ ,请稍候...
解压模块到/dev/sdb2/lib/modules/完成!
卸载/dev/sdb2
SD卡启动系统烧写完成!
以上的脚本会将sd卡重新格式化3个分区
- 第一个分区产uboot,不显示
- 第二个分区是fat32,存储kernel,设备树
- 第三个分区是ext3,存储根文件系统
zzmt@zzmt:~/Desktop/images/files$ sudo fdisk -l
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: 0xf8c5367d
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 104857599 104855552 50G 83 Linux
Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x53968c99
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 133119 131072 64M c W95 FAT32 (LBA)
/dev/sdb2 133120 62333951 62200832 29.7G 83 Linux
zzmt@zzmt:~/Desktop/images/files$
zzmt@zzmt:~/Desktop/images/files$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 393M 6.5M 386M 2% /run
/dev/sda1 50G 16G 32G 33% /
tmpfs 2.0G 252K 2.0G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs 393M 60K 393M 1% /run/user/1000
/dev/sr0 14G 14G 0 100% /media/zzmt/sblive
/dev/sdb1 63M 6.8M 57M 11% /media/zzmt/boot
/dev/sdb2 30G 611M 27G 3% /media/zzmt/rootfs
格式完成后,插入SD卡,切换从SD启动。