Sometimes, if you modify the MBR of a x86 disk you can loose its content so you need to reinstall the grub again, for example after install a mixed linux/solarisx86 environment, or migrating a x86 physical machine to a virtualized environment.
You have two options to boot the system, both using the CD-Rom:
One is using the cdrom grub, to do that, press e after grub appears, and delete all the lines and add the next 3 lines:
root (hd0,2,a) kernel /platform/i86pc/multiboot module /platform/i86pc/boot_archive
As the only thing is broken is the grub itself, all the data remains available in the disks, you just need to specify which is the device which contains the root file system, multiboot and boot_archive file, in this case, the first disk (disk0), slide 2.
After the system will be up, run this command to install grub:
/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/dsk/c0d0
Also you can do it in “the long way”, for example, if you need to fix some filesystem errors and reinstall the grub. To do that you can boot from the CD-Rom and boot in single user mode (adding -s after the kernel line in grub cdrom boot). After the cdrom boot is up, mount the / file system under a temporary folder /a and install grub from the command line in a shell.
Note: Mounting a solaris / FS will be covered in future post on this site.
If you don’t specify the correct device, you will see a message like:
# /sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/dsk/c0d0s0 The error was: Cannot open/stat device /dev/dsk/c0d0s2
Be careful, you must specify the correct device containing the slide 2, like:
# /sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/dsk/c0d0
note you are installing stage1 and stage2 from the bootable cdrom, after run this command and reboot, you should run again the same command, but as it will use the correct /boot/grub/stage1 and 2, grub will be correctly set.
TIP: If you are configuring a P2V migration under VMware, you must set the SCSI controller as LSI.
TIP2: if you are booting a system with x86 solaris and it has ZFS and you want to have it available to mount after boot from CD-Rom, you have to modify the grub from the bootable solaris CD-Rom and editing boot options (after grub screen appear, press “e” to edit the grub command line) and enter the next 3 lines:
findroot (pool_rpool,0,a) kernel$ /platform/i86pc/multiboot -B $ZFS-BOOTFS module /platform/i86pc/boot_archive
But it won’t detect any disks, so you must run
# devfsadm -C # echo | format
and later run
# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/cXtXdXs0
cXtXdX you can find it in the echo | format command finding our boot disk, normally first one.