cdsteinkuehler / br2rauc

Buildroot + RAUC
Other
51 stars 18 forks source link

Files in rootfs-overlay are not installed on the device #21

Closed hrs11-95 closed 1 year ago

hrs11-95 commented 1 year ago

Hello @cdsteinkuehler ,

I am currently facing issue with rootfs-overlay. I created some directories and copied some config files into them. They are part of /board/raspberrypi/rootfs-overlay/data/ . I am using data to store some config files as it's persistent partition. But these files and directories are not available on the target(Pi CM4). However, they are part of sdcard.img (checked by unzipping the file) and also available in /output/target/data/. I don't know why they are not installed on the target. Any idea what is the issue here?

Thanks in advance

cdsteinkuehler commented 1 year ago

I am not clear on exactly what you mean when you say "they are not installed on the target", but anything you expect to be in the data partition needs to be copied to the temporary root filesystem prior to execution of the genimage command. See the rauc.status file for example: https://github.com/cdsteinkuehler/br2rauc/blob/master/board/raspberrypi/post-image.sh#L120

Also, depending on what you are trying to copy, you may want to place your files in the root filesystem and copy them instead of placing them directly into the data partition. The data partition is created once when you create the uSD image. If the data partition ever gets corrupted you will no longer have your files available. For my production system which leverages br2rauc I have a systemd unit which forcibly mounts the data partition. First it tries a simple mount. if that fails, the script attempts to repair the file system and then mount it. If that fails, the partition is formatted and then mounted. Finally, there are systemd tmpfiles.d entries which copy the desired content from /home to /data if the content does not exist. That allows recovery from various failures while still allowing persistent writable content on the /data partition.

https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html#

hrs11-95 commented 1 year ago

Hi Charles,

Thanks for the quick update.

but anything you expect to be in the data partition needs to be copied to the temporary root filesystem prior to execution of the genimage command.

Understood.

My goal is to copy the config files (stored in differewnt sub-directories within data) into data partition. If I understood it correctly then I need to adapt post-image.sh script with below changes:

CUSTOM_DATA="${BOARD_DIR}/rootfs-overlay"

find ${CUSTOM_DATA}/data/ -type f -exec install -Dm 755 "{}" "${ROOTPATH_TMP}/data/" \;

Do you think this will work? This is a temporary solution and will switch to your suggestion of using systemd unit tmpfiles.

hrs11-95 commented 1 year ago

Update:

A simple cp -rand chmoddid the job. Thanks for the support