Using Bitbake to patch /etc/fstab within Petalinux

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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật