Andrea Posted August 7, 2023 Posted August 7, 2023 (edited) Hi all, I need to customize the /etc/fstab during the build to mount a mtd partition and also to override some mountpoints with tmpfs in order to reduce wearing on mmc. So, have added the following lines to customize-image.sh: cat <<EOT >> /etc/fstab # Reduce SD wearing by storing log files into ram (no need as overlayroot is used to freeze all the rootfs) tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev 0 0 tmpfs /run tmpfs defaults,noatime,nosuid,nodev 0 0 tmpfs /var/tmp tmpfs defaults,noatime,nosuid,nodev 0 0 tmpfs /var/log tmpfs defaults,noatime,nosuid,nodev,noexec 0 0 tmpfs /var/lib/logrotate tmpfs defaults,noatime,nosuid,nodev,noexec,size=1m,mode=0755 0 0 tmpfs /var/lib/sudo tmpfs defaults,noatime,nosuid,nodev,noexec,size=1m,mode=0700 0 0 # MTD EEPROM memory dev/mtdblock0 /mnt/mtd jffs2 ro,relatime 0 0 EOT However changes in /etc/fstab are overridden somewhere over the build process, and this is the resulting /etc/fstab: UUID=c8167755-b557-4288-9109-9108bc48dd94 / btrfs defaults,noatime,commit=600 0 1 UUID=27ac6cc6-eff3-4736-a7bd-5517e3b150c0 /boot ext4 defaults,commit=600,errors=remount-ro 0 2 tmpfs /tmp tmpfs defaults,nosuid 0 0 Is there a way to safely patch the /etc/fstab file? Thanks very much! Andrea Edited August 7, 2023 by Andrea 0 Quote
jesus2k21 Posted September 14, 2023 Posted September 14, 2023 Hello Andrea, I'm also having the same issue. Did you find a solution to the problem? Thanks! 0 Quote
jesus2k21 Posted September 21, 2023 Posted September 21, 2023 Hello again! It turns out I solved this problem by utilizing the Extension Hook format_partitions (https://docs.armbian.com/Developer-Guide_Extensions-Hooks/#format_partitions) Essentially you can follow the example outlined here https://docs.armbian.com/Developer-Guide_Extensions/#example where you can write all of your fstab setup logic in its own shell script, say it's called fstab-setup.sh. You'll need to write a function in this fstab-setup.sh script where the function name is formatted as format_partition__func_name() where "func_name" can be any name you like. It's important to note that you will need to have the extension hook name, in this case its format_parition, first in the function name followed by 2 underscores. Finally, in your configuration file, or on the ./compile.sh line, you will need to add ENABLE_EXTENSIONS=fstab-setup where fstab-setup is the name of the shell script. Something like ./compile.sh ENABLE_EXTENSIONS=fstab-setup BOARD=....more args.... Hope this helps! 2 Quote
Andrea Posted November 27, 2023 Author Posted November 27, 2023 Hi @jesus2k21 , sorry for the late reply. I came to the same conclusions by other means, but yes it was the way to go! 0 Quote
Johnny on the couch Posted September 22 Posted September 22 (edited) I was trying to do the same thing and this was the post which duckduck go lead me to. For the future searchers: you'll need format_partitions__func_name() function (notice "partitions" vs "partition"). You have 2 options: create separate file in extensions with your function and enable it in board config file or just create function in board config file (eg config/boards/orangepizero3.csc), like: function format_partitions__fstab() { echo "# something custom for fstab" >> $SDCARD/etc/fstab } Rerun compile.sh and you'll have your custom fstab I did try all the hooks but only modifications done in format_partitions will end up not overwritten. Edited September 22 by Johnny on the couch 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.