I'm creating a QEMU startup script in which I compile a rootfs to cpio.gz each time I launch the env. This is fine for the moment, but when the rootfs gets bigger in size, it is going to be a problem. Is there any way to check if a given directory structure and a compiled xxx.cpio.gz are different? I mean, if a file is added to the base rootfs directory structure, then a new cpio.gz must be created, but if its not the case, the one compiled in a previous launch would be fine.
Thanks in advance.
You can use
diff
between the rootfs dir and the cpio.gz to find files that exist only in the rootfs dir.For example, given the following directories
a
andb
:the output will be:
Then you can know which files to copy instead of copying the whole directory. Note that
diff
has many options, so be sure runningdiff --help
before using it.