-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add example how to mount the correct data partition for redundant layout #370
Conversation
Codecov Report
@@ Coverage Diff @@
## master #370 +/- ##
=======================================
Coverage 66.53% 66.53%
=======================================
Files 24 24
Lines 6455 6455
=======================================
Hits 4295 4295
Misses 2160 2160 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
The example implementation provided is still very use-case specific.
I would suggest boiling this down to 2 lines of udev as you can use the expr magic etc. also inside the shell script.
Then having %n only is possibl in this case, but will not work when having data volumes on separate volumes for example, because names are ubi0_x ubi1_y then.
Instead I would use %k, i.e. the udev 'kernel' name for this device. A bit of cut and sed will extract the name you need for comparsion.
Yes, you are right, either the shell script or the udev rules are highly use-case specific: Individual logic is always needed to find the correct rootfs slot for a given data slot. I decided to make the udev rule more specific since I dont like shell scripting that much ;) Will provide an example with the individual logic inside the shell script. |
You'd be the first one I know who likes udev scripting more than shell scripting, but.. ok.. 😏 |
For my case the udev was indeed easier since I get the partition for free from udev. Another thing:
But udev uses ubiX_Y notation from the kernel. Any idea how to solve this without patching / scripting barebox? |
Ok, logic inside the shell script. /usr/bin/is-parent-active :
udev rules:
Should we use this for documentation? |
The udev rules now looks fine for me (maybe we can add another example for (more common) sdX devices, such as
but basically that's it. The script however is a bit too specifc for an example and I also realized that using %k is not required in any case, but there's nothing bad to about having it ;) If I remember correctly, you also have access to udev variables (e.g. One check I've used on a similar setup is DISK_ID=$(cat /proc/cmdline | sed -e 's/^.*root=PARTUUID=\([0-9a-z-]*\).*/\1/')
[ "$DISK_ID" == "$ID_PART_TABLE_UUID" ] ... Maybe we can sum it up to something like ROOTFS_DEV=<determine rootfs by using proc cmdline or mount>
TEST_DEV=<obtain expected rootfs device for processed device (%k)>
if [[ $ROOTFS_DEV == $TEST_DEV]]; then
echo 1
else
echo 0
fi The actual handling is probably too use-case specific? |
Yep, in my opinion
is the best for documentation. Maybe, we can add one specific example. |
I'm wondering if this can't be done by letting udev look at the kernel cmdline:
That way you have an explicit mapping by name. I've not tried this very recently, so I'm not sure I got the details correct. Also often useful is:
|
@jluebbe is right for this case and maybe we should use this by default. It will not work when dealing with PARTUUID's as I had it in my setup, there we need a solution similar to what is in @FabianKnapp's last comment. So, we should maybe start with the simple ubifs example and shortly note that other as we already did. @FabianKnapp would you like to? |
As always: Feel free to modify. |
I've added another commit on top, which simplifies the udev rules to get rid of the temporary variable. That makes it possible to use just a single rule. |
Not yet, but it is on my todo's |
We hit this problem, so we solved it with a small tool and a simple configuration file: https://github.com/KopisMobile/bootslot-mounts It does require systemd, which is a lot of complexity on a very small system. But if you're already using systemd, it's pretty straightforward to use. |
… a redundant data layout Signed-off-by: Fabian Knapp <knapp@ambibox.de>
I've updated the branch to current master and changed some minor wording. |
Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Enrico Jörns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a minor fix in the example script and updated CHANGES.
Looks fine for me now.
This is one possible solution how to select the correct data partition when using redundant data slots.
As talked with ejoerns at #rauc.
Feel free to modify.