create rootfs.img using loop device

时间:2023-03-08 19:28:32
create rootfs.img using loop device

reference:

https://www.thegeekdiary.com/how-to-create-virtual-block-device-loop-device-filesystem-in-linux/

制作14G的img镜像 rootfs.img

dd if=/dev/zero of=rootfs.img bs=1024 count=14680064

将rootfs.img 格式化成 ext4

mkfs.ext4  rootfs.img

将rootfs.img 挂载到tf卡目录下

mount -o loop rootfs.img tf

将rootfs目录下的文件系统内容,拷贝至回环设备的挂载目录tf下

cp rootfs/*  tf/  -a

卸载rootfs.img,至此文件系统的内容全部写入到rootfs.img当中

umount tf

可通过etcher、dd(不带校验不安全)命令将基烧录到存储介质当中,进行引道