3

I'm attempting to move my /boot folder from the / partition, to /dev/sdb. The following script:

parted -s /dev/sdb mklabel msdos mkpart primary ext2 1M 100% set 1 boot on
mkfs.ext2 /dev/sdb1
mkdir /mnt/boot
mount /dev/sdb1 /mnt/boot
cd /boot
find . -depth -print0 | \
    cpio --null --sparse --make-directories --pass-through --verbose /mnt/boot
cd /
umount /mnt/boot
mv /boot /boot.orig
mkdir /boot
echo "/dev/sdb1 /boot ext2 ro 0 2" >>/etc/fstab
mount /dev/sdb1 /boot
parted /dev/sda set 1 boot off
grub-install /dev/sdb
update-grub
reboot

produces this error:

error: file '/boot/grub/i386-pc/normal.mod' not found.
grub rescue>

Any ideas?

Edit: It appears that the above script works fine, if the original /boot directory is on a separate partition (say /dev/sda2). It only fails if it's on the same partition as the / partition (/dev/sda1).

I've tried many, many variations of the above script, on both Ubuntu 13.04 and Fedora 19, and have yet to avoid the file '/boot/grub/i386-pc/normal.mod' not found error.

Any other ideas?

3 Answers3

6

The issue is that grub is looking for /boot/grub/i386-pc/normal.mod on the new partition. As the root of that partition is now mounted at /boot, the file is currently located at /grub/i386-pc/normal.mod on the new partition. You either need to reinstall grub to that partition or, as a temporary measure, you can create a symlink by calling ln -s . /boot/boot, which will allow the file to be found under either name.

3

Do an "ls" to find your boot partition (new one that is) say (hdX,Y).

Then ls (hdX,Y)/usr/lib/grub/i386-pc

Do you see the file there?

Likely you need to boot with a rescue cd or usb, and reinstall grub. Something is corrupted.

johnshen64
  • 516
  • 2
  • 4
0

This happens because the prefix variable, which is hardcoded in the core.img image by grub-install doesn't match your partition layout anymore. You can temporarily override this variable manually and load GRUB once by running the following commands in the rescue shell :

set prefix=(hd0,1)/boot/grub
insmod normal
normal

The prefix should be the path to where GRUB's files (grub.cfg, etc) reside, it's usually something like (hdX,Y)/boot/grub in case of a single root partition, or (hdX,Y)/grub if you have a dedicated /boot partition. In case of mdadm-managed RAID, the hdX,Y would probably be md/xxx or mduuid/xxxx....

If everything goes right, GRUB should be able to load its modules and load its grub.cfg and you should be able to start your OS. Once booted, run grub-install to regenerate a core.img (which will be embedded in the MBR of the disk) with the new prefix.

More info in their (awful) documentation.