|
1、将img文件拷贝到Ubuntu下,例如img文件名为 AC540-SoC-Console.img,拷贝的路径为 /home/fpgaer/tools/
2、使用fdisk命令查看img文件的分区 fdisk AC540-SoC-Console.img
3、输入p来查看分区信息:
root@ubuntu:/home/fpgaer/tools# fdisk AC540-SoC-Console.img
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.
Command (m for help): p
Disk AC540-SoC-Console.img: 1.9 GiB, 2002780160 bytes, 3911680 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: 0xd68e23ba
Device Boot Start End Sectors Size Id Type
AC540-SoC-Console.img1 2121728 3799447 1677720 819.2M b W95 FAT32
AC540-SoC-Console.img2 14336 2111487 2097152 1G 83 Linux
AC540-SoC-Console.img3 2048 4095 2048 1M a2 unknown
Partition table entries are not in disk order.
Command (m for help):
假如修改第一分区,也就是FAT32分区中的内容,则需要先挂载该分区,挂载的offset是其起始地址,用start块*512就是2121728*512=1086324736
3、挂载FAT32分区。
mount -o loop,offset=1086324736 AC540-SoC-Console.img /mnt/
4、在mnt下去修改里面的内容,
使用fdisk AC540-SoC-Console.img 再次管理该文件,
输入w来讲刚刚的修改写入该img文件。
完成
|
|