#!/bin/bash # # This is a little helper script that tries to convert linux-style device # names to grub-style. It's not very smart, so it # probably won't work for more complicated setups. # # If it doesn't work for you, try installing grub manually: # # # mkdir -p /boot/grub # # cp /usr/lib/grub/i386-pc/* /boot/grub/ # # Then start up the 'grub' shell and run something like the following: # # grub> root(hd0,0) # grub> setup(hd0) # # The "root" line should point to the partition your kernel is located on, # /boot if you have a separate boot partition, otherwise your root (/). # # The "setup" line tells grub which disc/partition to install the # bootloader to. In the example above, it will install to the MBR of the # primary master hard drive. # usage() { echo "usage: install-grub [boot_device]" echo echo "where is the device where Grub will be installed" echo "and [boot_device] is the partition that contains the /boot" echo "directory (auto-detected if omitted)" echo echo "examples: install-grub /dev/hda" echo " install-grub /dev/hda /dev/hda1" echo exit 0 } ## new install-grub, code was taken from setup script ROOTDEV=$1 PART_ROOT=$2 VMLINUZ=vmlinuz26 if [ "$ROOTDEV" = "" ]; then usage fi if [ "$PART_ROOT" = "" ]; then PART_ROOT=$(mount | grep "on /boot type" | cut -d' ' -f 1) fi if [ "$PART_ROOT" = "" ]; then PART_ROOT=$(mount | grep "on / type" | cut -d' ' -f 1) fi if [ "$PART_ROOT" = "" ]; then echo "error: could not determine BOOT_DEVICE, please specify manually" >&2 exit 1 fi get_grub_map() { [ -e /tmp/dev.map ] && rm /tmp/dev.map /sbin/grub --no-floppy --device-map /tmp/dev.map >/tmp/grub.log 2>&1 </boot/grub/menu.lst rm -f /tmp/.menu.lst echo "" >>/boot/grub/menu.lst echo "# (0) Arch Linux" >>/boot/grub/menu.lst echo "title Arch Linux" >>/boot/grub/menu.lst subdir= if [ "$bootdev" != "" ]; then grubdev=$(mapdev $bootdev) else subdir="/boot" fi echo "root $grubdev" >>/boot/grub/menu.lst echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>/boot/grub/menu.lst if [ "$VMLINUZ" = "vmlinuz26" ]; then echo "initrd $subdir/kernel26.img" >>/boot/grub/menu.lst fi echo "" >>/boot/grub/menu.lst # adding fallback/full image echo "# (1) Arch Linux" >>/boot/grub/menu.lst echo "title Arch Linux Fallback" >>/boot/grub/menu.lst echo "root $grubdev" >>/boot/grub/menu.lst echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>/boot/grub/menu.lst if [ "$VMLINUZ" = "vmlinuz26" ]; then echo "initrd $subdir/kernel26-fallback.img" >>/boot/grub/menu.lst fi echo "" >>/boot/grub/menu.lst fi fi echo "Installing the GRUB bootloader..." cp -a /usr/lib/grub/i386-pc/* /boot/grub/ sync # freeze xfs filesystems to enable grub installation on xfs filesystems if [ -x /usr/sbin/xfs_freeze ]; then /usr/sbin/xfs_freeze -f /boot > /dev/null 2>&1 /usr/sbin/xfs_freeze -f / > /dev/null 2>&1 fi # look for a separately-mounted /boot partition bootpart=$(mount | grep /boot | cut -d' ' -f 1) if [ "$bootpart" = "" ]; then bootpart=$PART_ROOT fi bootpart=$(mapdev $bootpart) bootdev=$(mapdev $ROOTDEV) if [ "$bootpart" = "" ]; then echo "Error: Missing/Invalid root device: $bootpart" exit 1 fi /sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 < /dev/null 2>&1 /usr/sbin/xfs_freeze -u / > /dev/null 2>&1 fi if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then echo "Error installing GRUB. (see /tmp/grub.log for output)" exit 1 fi echo "GRUB was successfully installed." rm -f /tmp/grub.log exit 0 } dogrub