-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 support for boot environment data to be stored in the label #10009
Conversation
what is the reason do not reuse illumos logic for GRUB1 and loader? |
Codecov Report
@@ Coverage Diff @@
## master #10009 +/- ##
========================================
- Coverage 79% 79% -<1%
========================================
Files 386 386
Lines 122431 122533 +102
========================================
+ Hits 97023 97066 +43
- Misses 25408 25467 +59
Continue to review full report at Codecov.
|
aiui Linux now supports multiboot2, why not just port the illumos / freebsd bootloader? grub is awfully encumbered code. |
First, Illumos is no longer using GRUB1, it is using the FreeBSD loader. The logic was written for the FreeBSD loader, rather than GRUB1. We are not reusing that logic on Linux because GRUB and the FreeBSD loader have fundamentally different capabilities. The nextboot implementation in the FreeBSD loader is built directly into the code of the loader, and uses special fields in the header to count to the number of boots and store the fallback filesystem. GRUB, on the other hand, performs automated fallback through scripting, and stores the data for this directly in the grubenv file. As a result, it doesn't make sense to have special nextboot specific fields in the boot area for GRUB, since they will not be used or respected. |
we are using GRUB1 on DilOS and will try to port GRUB2 soon. i'm asking about logic because i'd like to be more compatible with ZoL as possible on DilOS. current GRUB1 implementation still good, but has issues with large list of BE what can be using by BEADM. |
@misterbigstuff I welcome others to take on that work, but we are currently most comfortable tweaking a well-established bootloader compared to doing the work of porting and testing one. |
@pcd1193182 so we can assume this means grub2 will be getting native encryption and large dnode support? |
@misterbigstuff Not sure if anyone is taking that on right now, but I would expect it to happen eventually. I'm sure there is demand for native encryption on the bootfs out there. |
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.
A couple quick comments. I haven't yet had a chance to look at the grub portion of this.
Codecov Report
@@ Coverage Diff @@
## master #10009 +/- ##
==========================================
- Coverage 79.52% 79.48% -0.04%
==========================================
Files 389 389
Lines 123120 123229 +109
==========================================
+ Hits 97906 97952 +46
- Misses 25214 25277 +63
Continue to review full report at Codecov.
|
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Modern bootloaders leverage data stored in the root filesystem to enable some of their powerful features. GRUB specifically has a grubenv file which can store large amounts of configuration data that can be read and written at boot time and during normal operation. This allows sysadmins to configure useful features like automated failover after failed boot attempts. Unfortunately, due to the Copy-on-Write nature of ZFS, the standard behavior of these tools cannot handle writing to ZFS files safely at boot time. We need an alternative way to store data that allows the bootloader to make changes to the data. This work is very similar to work that was done on Illumos to enable similar functionality in the FreeBSD bootloader. This patch is different in that the data being stored is a raw grubenv file; this file can store arbitrary variables and values, and the scripting provided by grub is powerful enough that special structures are not required to implement advanced behavior. We repurpose the second padding area in each label to store the grubenv file, protected by an embedded checksum. We add two ioctls to get and set this data, and libzfs_core and libzfs functions to access them more easily. There are no direct command line interfaces to these functions; these will be added directly to the bootloader utilities. Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Paul Dagnelie <pcd@delphix.com> Closes openzfs#10009
Motivation and Context
Modern bootloaders leverage data stored in the root filesystem to enable some of their powerful features. GRUB specifically has a grubenv file which can store large amounts of configuration data that can be read and written at boot time and during normal operation. This allows sysadmins to configure useful features like automated failover after failed boot attempts. Unfortunately, due to the Copy-on-Write nature of ZFS, the standard behavior of these tools cannot handle writing to ZFS files safely at boot time. We need an alternative way to store data that allows the bootloader to make changes to the data.
Description
This work is very similar to work that was done on Illumos to enable similar functionality in the FreeBSD bootloader. This patch is different in that the data being stored is a raw grubenv file; this file can store arbitrary variables and values, and the scripting provided by grub is powerful enough that special structures are not required to implement advanced behavior.
We repurpose the second padding area in each label to store the grubenv file, protected by an embedded checksum. We add two ioctls to get and set this data, and libzfs_core and libzfs functions to access them more easily. There are no direct command line interfaces to these functions; these will be added directly to the bootloader utilities.
How Has This Been Tested?
These changes have been tested in conjunction with a custom version of GRUB that knows how to read from and write to the padding areas of the label to access to the grubenv data. Many tests were performed, including selectively corrupting the contents of the padding areas to verify that edge cases are handled correctly.
The GRUB changes that enabled this have been posted for review at https://lists.gnu.org/archive/html/grub-devel/2020-02/msg00026.html
Types of changes
Checklist:
Signed-off-by
.