Here is the stock bitbake /etc/fstab file:
me@petalinux:~$ cat /etc/fstab
# stock fstab - you probably want to override this with a machine specific one
/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
tmpfs /var/volatile tmpfs defaults 0 0
# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0
Here is my altered version of the fstab, which I use to create a patch file:
# /dev/mmcblk0p1 uncommented and /media/card changed to /media/emmc
/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
tmpfs /var/volatile tmpfs defaults 0 0
# uncomment this if your device has a SD/MMC/Transflash slot
/dev/mmcblk0p1 /media/emmc auto defaults,sync,noauto 0 0
I’ve created the patch file below by:
diff -u base-files/fstab base-files/new_fstab > base-files/fstab.patch
This results in this patch file:
--- base-files/fstab 2024-05-06 10:08:57.366006727 -0500
+++ base-files/new_fstab 2024-05-06 10:08:53.086007033 -0500
@@ -1,4 +1,4 @@
-# stock fstab - you probably want to override this with a machine specific one
+# new fstab - /dev/mmcblk0p1 uncommented and /media/card changed to /media/emmc
/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
@@ -7,4 +7,4 @@
tmpfs /var/volatile tmpfs defaults 0 0
# uncomment this if your device has a SD/MMC/Transflash slot
-#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0
No newline at end of file
+/dev/mmcblk0p1 /media/emmc auto defaults,sync,noauto 0 0
No newline at end of file
The original fstab, new_fstab and fstab.patch file are all located in the same directory under the recipes-core directory:
~/petalinux/2023.2/project/petalinux/components/yocto/layers/poky/meta/recipes-core$ tree
.
├── base-files
│ ├── base-files
│ │ ├── new_fstab
│ │ ├── fstab
│ │ ├── fstab.orig
│ │ ├── fstab.patch
│ │ ├── host.conf
│ │ ├── hosts
│ │ ├── issue
│ │ ├── issue.net
│ │ ├── licenses
│ │ │ └── GPL-2
│ │ ├── motd
│ │ ├── nsswitch.conf
│ │ ├── profile
│ │ ├── rotation
│ │ ├── share
│ │ │ ├── dot.bashrc
│ │ │ └── dot.profile
│ │ └── shells
│ ├── base-files_%.bbappend
│ └── base-files_3.0.14.bb
the base-files_%.bbappend file is as follows:
SRC_URI:append = " file://fstab.patch;apply=yes
"
# FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
FILESEXTRAPATHS:prepend := "${THISDIR}/base-files:"
do_patch:append() {
patch -p1 ${WORKDIR}/fstab < ${WORKDIR}/fstab.patch
# install -m 0644 ${WORKDIR}/new_fstab ${D}${sysconfdir}/fstab
}
I’ve tried dozens of variations of this bbappend file. But I can never get the /etc/fstab file in the rootfs to change.
According to https://docs.yoctoproject.org/singleindex.html
5.7 Patching code – Any files mentioned in SRC_URI whose names end in .patch or .diff or compressed versions of these suffixes (e.g. diff.gz, patch.bz2, etc.) are treated as patches. The do_patch task automatically applies these patches.
The build system should be able to apply patches with the “-p1” option (i.e. one directory level in the path will be stripped off)
This is why my patch was created outside of the directory where the patch and files reside (base-files)
6.1.18 do_patch – you can use the “apply=yes” parameter with the SRC_URI statement to indicate any file as a patch file
This is why I used apply=yes.
FILESEXTRAPATHS – A colon-separated list to extend the search path the OpenEmbedded build system uses when looking for files and patches as it processes recipes and append files. The default directories BitBake uses when it processes recipes are initially defined by the FILESPATH variable. You can extend FILESPATH variable by using FILESEXTRAPATHS.
This is why I used FILESEXTRAPATHS variable to explicitly capture the base-files folder in the path.
I’ve also tested the patch manually and it works. But for reasons unknown, I can not get bitbake to execute the patch and update the /etc/fstab. There are a handful of posts on here but none of them have helped.
Note – this is all being done within the Xilinx (now AMD) petalinux build flow. So I don’t have (or I don’t know how to ) access bitbake directly.
Thank you for your time.