1,插上sd卡到Ubuntu,查看分区信息
peter@ubuntu:~$ ls /dev/sdb
sdb sdb1 sdb2 sdb3 sdb4 sdb5 //如果sdb只有3个分区可以再分两个区:sdb4,sdb5
2,将内核和设备树放到sdb4分区
1》格式化sdb4分区
peter@ubuntu:~$ sudo mkfs.ext4 /dev/sdb4
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 10240 1k blocks and 2560 inodes
Filesystem UUID: d32fe974-557c-4e60-8d5b-ee095f88de41
Superblock backups stored on blocks:
8193
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
2》创建挂载点,将/dev/sdb4分区挂载到挂载点,并将内核镜像uImage和设备树文件拷贝到挂载点中
peter@ubuntu:~$ mkdir testdir
peter@ubuntu:~$ sudo mount -t ext4 /dev/sdb4 testdir/
peter@ubuntu:~$ cd testdir/
peter@ubuntu:~/testdir$ ls
lost+found
peter@ubuntu:~/testdir$ sudo cp /tftpboot/uImage ./ -r
peter@ubuntu:~/testdir$ sudo cp /tftpboot/stm32mp157a-fsmp1a.dtb . -r
peter@ubuntu:~/testdir$ ls
lost+found stm32mp157a-fsmp1a.dtb uImage
//然后卸载:peter@ubuntu:~$ sudo umount testdir
3,将文件系统放到/dev/sdb5分区
1》格式化sdb5分区
peter@ubuntu:~$ sudo mkfs.ext4 /dev/sdb5
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 20480 1k blocks and 5136 inodes
Filesystem UUID: 5b4c4055-0669-4794-9a8e-ef6572e953d8
Superblock backups stored on blocks:
8193
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
2》将/dev/sdb5分区重新挂载到挂载点testdir,并将文件系统中所有文件拷贝到挂载点中
peter@ubuntu:~$ sudo mount -t ext4 /dev/sdb5 testdir
peter@ubuntu:~$ cd testdir/
peter@ubuntu:~/testdir$ ls
lost+found
peter@ubuntu:~/testdir$ sudo cp /opt/myrootfs/* . -r */
peter@ubuntu:~/testdir$ ls
bin etc home linuxrc mnt root sys usr
dev hello_drv.ko lib lost+found proc sbin tmp
//然后卸载:peter@ubuntu:~$ sudo umount testdir