-
-
Notifications
You must be signed in to change notification settings - Fork 268
Grub2: REAR Improvements proposal #844
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
Conversation
Actually we found that ppc64 and ppc64le are not aware of "hd0,msdos1", current grub2 rescue does not work without the above option in ppc64 and ppc64le. Since this search option is used even in x86 grub2 distro menu, so it would be better to handle as platform independent option.
Using /etc/grub.d/45_rear to store REAR grub menuentry. This prevent REAR menu entry to be erased is case of grub2-mkconfig (or grub-mkconfig) is run (like after a kernel update).
| fi | ||
|
|
||
| #Finding UUID of filesystem containing /boot | ||
| grub_boot_uuid=$(df /boot | awk 'END {print $1}' | xargs blkid -s UUID -o value) |
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.
@schabrolles I know of Linux systems where the /boot file system is not always mounted. Then the variable would be empty.
What happens in such cases? You would get an invalid grub entry.
Perhaps, foresee a sanity check here?
Gratien
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.
@gdha. df /boot | awk 'END {print $1}' returns the file system on which /boot stands : either /boot (if it is a file system) or / (if it is only a directory).
So, if /boot is not mounted, the UUID return by the command will be / UUID (and not /boot).
grub-mkconfig has the same behavior. it uses grub2-probe --target=device /boot to get the name of the boot device. If /boot is not mounted, it returns / device instead and grub.cfg generation won't be good.
It is not a good idea to not mount /boot, grub-mkconfig can be automatically run after some packages upgrade (kernel for example); if /bootis not mounted, grub.cfg won't be updated.
Anyway, your point is correct and we should may be test if a directory like /boot/grub* exist.
If not, we can exist and avoid to generate a bad grub.cfg
#Test if /boot is mounted
if ls -ld /boot/grub* > /dev/null 2>&1 ; then
grub_boot_uuid=$(df /boot | awk 'END {print $1}' | xargs blkid -s UUID -o value)
....
else
echo "Error: /boot is empty, or may be not mounted..."
exit 1
fi
Your feedback is welcomed
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.
@schabrolles You could make the test easier (and we use this a lot in rear):
ls -ld /boot/grub* > /dev/null 2>&1
StopIfError "/boot is empty, or may be not mounted..."
Thank you for reviewing the code once more.
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.
I check again the code, there is several test before to check /boot/grub/grub.cfg, verify that this one is writable etc ...
example line 66 67
[[ -w "$grub_conf" ]]
StopIfError "GRUB2 configuration cannot be modified."
Normally, if we pass this test, this mean that /boot/grub* exists (/boot is mounted or directory not empty). It is may be useless to add another test. What do you think ?
Another question : What is the difference between StopIfErrorand BugIfError ?
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.
I agree with you - testing once is enough.
BugIfError function is mainly used when we think there might be a bug report needed against rear. StopIfError is meant to force an exit out of rear when there is a condition not met (missing executable or file or something else which is not caused by a bug)
* Checking that /boot is valid and mounted. * Verifying /boot UUID is valid.
* Add verification of /boot UUID consistency before creating new grub file.
|
@gdha I apply the changes in
I put a bit of mess in my git branch ... If it is an issue I can redo the job... just tell me what is best to do. (a new pull request ?) |
1- Grub2: Using search --fs-uuid instead of hardcoded root='hd0,msdos1'
Actually we found that ppc64 and ppc64le are not aware of "hd0,msdos1", current grub2 rescue does not work without the above option in ppc64 and ppc64le. Since this search option is used even in x86 grub2 distro menu, so it would be better to handle as platform independent option.
By the way, this search option allows to use GPT formated disk ! Which is not the case of 'hd0,msdos1'
2- Changing the way REAR grub2 menuentry is created. By using the standard /etc/grub.d directory to store the REAR menu, we are sure that it will not be removed by a manual grub-mkconfig (or an automated one after a kernel upgrade.)