在嵌入式开发中,常参考开发板提供的原始的SD卡镜像,如:
$ fdisk -l ./sockit-gsrd-16.0-sdcard.img Disk ./sockit-gsrd-16.0-sdcard.img: 1.7 GiB, 1782579200 bytes, 3481600 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: 0x982b3f12 Device Boot Start End Sectors Size Id Type ./sockit-gsrd-16.0-sdcard.img1 2048 616448 614401 300M b W95 FAT32 ./sockit-gsrd-16.0-sdcard.img2 616449 3074049 2457601 1.2G 83 Linux ./sockit-gsrd-16.0-sdcard.img3 3074050 3094530 20481 10M a2 unknown 根据自己的sd卡大小,手动分区: $ sudo fdisk -l /dev/sdb [sudo] password for stephen: Disk /dev/sdb: 1.9 GiB, 1997537280 bytes, 3901440 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: 0x0eff6c7b Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 526336 524289 256M b W95 FAT32 /dev/sdb2 528384 3897343 3368960 1.6G 83 Linux /dev/sdb3 3897344 3901439 4096 2M a2 unknown 在这里,先确定sdb1和sdb3大小,进行分区,剩下的给sdb2;好了,格式化sdb1和sdb2。然后,复制各分区内容。
sdb3是RAW,Preloader和U-Boot总共不到1M,所以:
$ sudo dd if=./sockit-gsrd-16.0-sdcard.img of=/dev/sdb3 skip=3074050 bs=512 count=2048 [sudo] password for stephen: 2048+0 records in 2048+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.923305 s, 1.1 MB/s $ sync 然后mount image,在文件管理器中,使用 Disk Image Mounter 简单直接。其实文件占用空间不多,用df看看就知道了。
接下来就是 cp:
$ cp /run/media/stephen/DFFC-6E35/* /run/media/stephen/9CD0-451E/ $ sudo cp -avx /run/media/stephen/3e0cd62a-cd24-4788-a146-93b02a913e89/* /run/media/stephen/b57ab8c3-9f55-4668-b0f0-3dcd8f4765ae/ $ sync umount, eject. Done.