-
Notifications
You must be signed in to change notification settings - Fork 384
mkosi-initrd: protect old initrd image against errors #3589
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
mkosi-initrd: protect old initrd image against errors #3589
Conversation
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.
This is very messy., there's no guarantee we can put the backup back in place when copying the new one fails. We should copy the new initrd to a temporary file next to the initrd we're replacing and then use rename() to atomically replace the old one.
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 @DaanDeMeyer on how this should be implemented, but generally I do want to see this feature. I've had the exact thing this is supposed to prevent happen to me with dracut a few times. :)
With this approach we are always invalidating an amount of space equal to the initrd size, but ok, I see your point. |
4f690b5
to
c4a23ff
Compare
Let's merge #3591 first and then rebase this on top of that and make use of Path 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.
LGTM, #3591 has just been merged, so this just needs the rebase. One small nit
c4a23ff
to
9c88011
Compare
When `copy_tree()` ends up calling `cp`, if it fails because there is not enough space, it leaves an incomplete initrd image in the output directory. If we are writing the initrd image directly where a bootloader entry has an initrd configured, the system will fail to boot. So, instead of copying the initrd image directly to the output, copy it next to it in the same output directory, and if the copy is successful, replace it.
9c88011
to
e133298
Compare
When
copy_tree()
ends up callingcp
, if it fails because there is not enough space, it leaves and incomplete initrd image in the output directory. If we are writing the initrd image directly where a bootloader entry has an initrd configured, the system will fail to boot. So, backup the old initrd image before callingcopy_tree()
, and restore it if that function throws an exception.