创建TF卡镜像
如果您没有部署本地TFTP服务器,则您可以使用TF卡进行数据传输。
重要: 创建TF卡镜像将覆盖目标TF卡上的所有现有数据。
TF卡的默认大小为16 GB,建议您使用TF卡的GPT分区表。
按照以下步骤,创建TF卡镜像:
-
执行以下命令,生成sdcard.img文件。
$ make -j$(nproc) $ make buildroot_rootfs -j$(nproc) $ make img
结果:
将生成输出文件work/sdcard.img。
提示: 您可通过以下方式之一将镜像文件烧录到TF卡上:- 执行以下
dd
命令:$ sudo dd if=work/sdcard.img of=/dev/sdX bs=4096 $ sync
- 或使用
rpi-imager
或balenaEtcher
工具。
- 执行以下
- (可选)如有需要,可使用以下方法扩展分区。
- 方法1:在Ubuntu主机上:
- 输入以下命令,安装软件包:
$ sudo apt install cloud-guest-utils e2fsprogs
- 在Ubuntu主机上插入一张TF卡。
- 执行以下命令扩展分区。注:
/dev/sdX
是TF卡设备名,可根据实际情况更改该变量。$ sudo growpart /dev/sdX 4 # extend partition 4 $ sudo e2fsck -f /dev/sdX4 $ sudo resize2fs /dev/sdX4 # extend filesystem $ sudo fsck.ext4 /dev/sdX4
- 输入以下命令,安装软件包:
- 方法2:在昉·星光 2开发板上运行
fdisk
和resize2fs
命令:# fdisk /dev/mmcblk1 Welcome to fdisk (util-linux 2.37.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. This disk is currently in use - repartitioning is probably a bad idea. It's recommended to umount all file systems, and swapoff all swap partitions on this disk. Command (m for help): d Partition number (1-4, default 4): 4 Partition 4 has been deleted. Command (m for help): n Partition number (4-128, default 4): 4 First sector (614400-62333918, default 614400): ): t sector, +/-sectors or +/-size{K,M,G,T,P} (614400-62333918, default 62333918) Created a new partition 4 of type 'Linux filesystem' and of size 29.4 GiB. Partition #4 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: N Command (m for help): w The partition table has been altered. Syncing disks. # resize2fs /dev/mmcblk1p4 resize2fs 1.46.4 (18-Aug-2021) Filesystem at /d[ 111.756178] EXT4-fs (mmcblk1p4): resizing filesystem from 512000 to 30859756 blocks ev/mmcblk1p4 is [ 111.765203] EXT4-fs (mmcblk1p4): resizing filesystem from 512000 to 30859265 blocks mounted on /; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 118 [ 112.141953] random: crng init done [ 112.145369] random: 7 urandom warning(s) missed due to ratelimiting [ 115.474184] EXT4-fs (mmcblk1p4): resized filesystem to 30859265 The filesystem on /dev/mmcblk1p4 is now 30859756 (1k) blocks long.
- 方法1:在Ubuntu主机上: