Using cpio package tools is OK. But it needs to be done every time you updates rootfs.
You can also use PetaLinux built-in tool to accomplish this. It doesn't need extra steps once you set it up.
Create the app:
petalinux-create -t apps -n fstab_mount_sd --template install --enable
In the created components/apps/fstab_mount_sd
directory, modify the Makefile
to append contents to current fstab file or replace the original fstab with your version of fstab file.
Here's an example of the fstab_mount_sd Makefile:
install:
$(TARGETINST) -a "/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0" /etc/fstab
$(TARGETINST) -a
means append the following text to the destination file.
Note: commands in makefile should start with Tab. Replace the spaces before $(TARGETINST)
in previous code block with a Tab.
You can read the help of the $(TARGETINST)
command by going to PetaLinux install directory and run components/rootfs/targetroot-inst.sh