Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to customize /etc/fstab in a build?

Featured Replies

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 by Andrea

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!

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 by Johnny on the couch

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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.