+
+# oops, install device is a symlink...
+if [ -h "$install_device" ]; then
+ install_device_resolved=$(resolve_symlink "$install_device")
+ if [ -z "$install_device_resolved" ]; then
+ install_device_resolved="$install_device"
+ fi
+
+ # try to fix device map with symlink resolved device
+ if [ "x$install_device_resolved" != "x$install_device" ]; then
+ cp_check_and_sed '^\(hd0\)' \
+ "s;^(hd0).*;(hd0) $install_device_resolved;" "$device_map" \
+ || true
+ fi
+fi
+echo -n " grub5"
+
+# install GRUB loader
+if ! grub-install --no-floppy "$install_device" >/dev/null 2>&1; then
+ echo "."
+ echo "CN: FATAL ERROR while running grub-install!"
+ echo "CN: Do not reboot your server and report this to OTRS immediately!"
+ exit 1
+fi
+echo -n " grub6"
+
+# fix possible wrong params in menu.lst
+cp_check_and_sed '^# groot=' \
+ "s;^# groot=.*;# groot=$grub_root_device;g" \
+ "$menu_file" || true
+cp_check_and_sed '^# kopt=' \
+ "s;^# kopt=\(.*\)root=[^[:space:]]*\(.*\);# kopt=\1root=$root_device\2;g" \
+ "$menu_file" || true
+/usr/sbin/update-grub >/dev/null 2>&1 || true
+echo -n " grub7"
+
+# and final stage of devfs/udev brokeness fix
+if [ "x$install_device_resolved" != "x$install_device" ]; then
+ # get original (symlinked device)
+ root_device=$(find_device_nonresolved "/")
+ if [ -z "$root_device" ]; then
+ root_device=$(find_root_device)
+ fi
+
+ # fix (hd0) mapping
+ cp_check_and_sed '^\(hd0\)' \
+ "s;^(hd0).*;(hd0) $install_device;" "$device_map" \
+ || true
+
+ # fix global root= invocation
+ cp_check_and_sed '^# kopt=' \
+ "s;^# kopt=\(.*\)root=[^[:space:]]*\(.*\);# kopt=\1root=$root_device\2;g" \
+ "$menu_file" || true
+
+ # fix root= invocation for individual kernel profiles
+ cp_check_and_sed '^kernel' \
+ "s;\(^kernel.*\)root=[^[:space:]]*\(.*\);\1root=$root_device\2;g" \
+ "$menu_file" || true
+fi
+echo -n " grub8"
+
+# restore execshield state