blob: 390c40c2db577eabd31a21b5f75695076fc62808 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
Date: 2005-11-11
Author: Otavio Salvador
Comment: Stolen from Fedora grub package.
Add syncs to ensure that filesystem cache are flushed.
-- Original comment, below
I just found another semi-critical bug, whose fix should really get
into 0.91.
It turns out that "grub-install" doesn't have any "sync" calls to make
sure any filesystem caches are coherent with the raw devices they are
on top of... so if your filesystem waits to write out any data from the
copy command in the script to put the "stage1" and "stage2" in their
final location, you're hosed.
I found this because it just bit me on one of my systems running stock
RedHat 7.2 with a large "stage2".
The only script that is patched here is "grub-install". The others
don't appear to need it as they either unmount things first or don't
refer to devices.
Hmm. Maybe the right fix is to make the "sync" system call when
starting the GRUB shell with a device map that refers to any real disks
or something like that.
Erich Stefan Boleyn <erich@uruk.org> http://www.uruk.org/
"Reality is truly stranger than fiction; Probably why fiction is so popular"
Index: b/util/grub-install.in
===================================================================
--- a/util/grub-install.in
+++ b/util/grub-install.in
@@ -384,6 +384,10 @@
# Create a safe temporary file.
test -n "$mklog" && log_file=`$mklog`
+ # Before all invocations of the grub shell, call sync to make sure
+ # the raw device is in sync with any bufferring in filesystems.
+ sync
+
$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
quit
EOF
@@ -509,6 +513,10 @@
# Create a safe temporary file.
test -n "$mklog" && log_file=`$mklog`
+# Before all invocations of the grub shell, call sync to make sure
+# the raw device is in sync with any bufferring in filesystems.
+sync
+
# Now perform the installation.
$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
root $root_drive
|