Re: grub2 confusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 06 Oct 2011 17:05:06 -0600, EB (Eric) wrote:

> > cp -f ${grub_cfg}.new ${grub_cfg} ; rm -f ${grub_cfg}.new
> >
> > Better?
> 
> No.  cp is not atomic.  rename(2) (via mv(1), if both files are on the 
> same device) is.  Any solution that does not use rename(2) is flawed, 
> because an ill-timed power-outage will leave the file in an inconsistent 
> state.  What you want is that ${grub_cfg} _always_ exists, and is either 
> the unchanged original, or atomically the contents of the new 
> replacement.  Anything else is a recipe for disaster, for something as 
> important as the files that control how you boot your machine.
> 
> > I assume you are not concerned about the removal of the temporary
> > local file in the second step,
> 
> Not as much as I am that ${grub_cfg} always exist, and always have valid 
> contents.

Whether the latter is ensured [yet], I dunno, because the
/usr/bin/grub2-script-check isn't mentioned anywhere other than in the
ChangeLog file. No idea how mighty it is without visiting the source.
It's written in C. There's a lot more in grub2 menu entries which can
be damaged.

Brute-force work-around so /etc/grub2.cfg becomes usable:

--- /sbin/grub2-mkconfig	2011-09-14 22:21:35.000000000 +0200
+++ /home/misc16b/grub2-mkconfig	2011-10-07 01:18:53.922155628 +0200
@@ -257,6 +257,9 @@
   GRUB_BADRAM
 
 if test "x${grub_cfg}" != "x"; then
+  if [ -L "${grub_cfg}" ] ; then
+    grub_cfg=$(readlink ${grub_cfg})
+  fi
   rm -f ${grub_cfg}.new
   exec > ${grub_cfg}.new
 
-- 
test mailing list
test@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: 
https://admin.fedoraproject.org/mailman/listinfo/test


[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]

  Powered by Linux