On Tue, Jun 03, 2014 at 03:00:30PM -0400, Vivek Goyal wrote:
[..]
> + restore_default_initrd
I think directly writing to default image is not a good idea. What if
image is being built and power cable is pulled. We might have a half
built initrd image and system is unbootable.
We should first build image in a separate copy and upon successful
operation replace it with new one.
We seem to have this issue with kdump initrd also but it is less severe
as we don't use that initrd for regular boot.
I think rename(2) is the right thing to do here. But we don't seem to
have equivalent bash command version. rename(1) seems to be different.
Ok, I asked some fs developers about it. And they said that "mv" is
same as rename(2) if both files on same file system. So we can make
sure that newly generated initrd is part of /boot/ and then mv it
in place.
This still leaves one issue that is after generating the new initramfs
file we need to make sure it is on disk before we call "mv". Otherwise
it might happen that rename is successful but all the file's contents
are not on disk.
But the catch is that there does not seem to be a "fsync" utility callable
from shell.
Thanks
Vivek