# GRUB2 install fail on FreeBSD 8.1 amd64



## epopen (Jan 5, 2011)

Hi all
I wish install grub2-1.98_1 on my FreeBSD system. But can't install, Please help me. My system is


```
FreeBSD epopen.com 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0: Wed Nov 24 21:17:16 CST 2010     epopen.com:/usr/obj/usr/src/sys/EpopenKernel  amd64
```

My HDD partition


```
ad4    (HDD)
ad4s1  WinVista NTFS
ad4s2  NTFS
ad4s3  FreeBSD partition slice

# gpart show ad4
=>       63  488397105  ad4  MBR  (233G)
         63       1985       - free -  (993K)
       2048   62914560    1  ntfs  (30G)
   62916608  184320000    2  ntfs  (88G)
  247236608  241155457    3  freebsd  [active]  (115G)
  488392065       5103       - free -  (2.5M)
```

FreeBSD slice


```
ad4s3a /     UFS2
ad4s3b swap
ad4s3d /home ZFS
```
And I tried command

`/usr/local/sbin/grub-install --no-floppy --recheck --debug --modules="ufs2 bsd" /dev/ad4`

But I got error, and debug message..


```
+ setup_verbose=--verbose
+ bootdir=/boot
+ echo grub
+ sed s,x,x,
+ grubdir=/boot/grub
+ device_map=/boot/grub/device.map
+ grub_probe='/usr/local/sbin/grub-probe --device-map=/boot/grub/device.map'
+ [ i386-pc = i386-pc ]
+ set /usr/local/sbin/grub-setup dummy
+ test -f /usr/local/sbin/grub-setup
+ :
+ set /usr/local/bin/grub-mkimage dummy
+ test -f /usr/local/bin/grub-mkimage
+ :
+ set /usr/local/sbin/grub-mkdevicemap dummy
+ test -f /usr/local/sbin/grub-mkdevicemap
+ :
+ test -d /boot
+ test -d /boot/grub
+ test yes = yes
+ rm -f /boot/grub/device.map
+ test -f /boot/grub/device.map
+ test -n ''
+ /usr/local/sbin/grub-mkdevicemap --device-map=/boot/grub/device.map --no-floppy
+ + sortuniq
 -d
+ sed -n 1p
+ sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' /boot/grub/device.map
+ tmp=''
+ test -n ''
+ test -f /boot/grub/acpi.mod
+ basename /boot/grub/acpi.mod
+ [ acpi.mod != menu.lst ]
+ rm -f /boot/grub/acpi.mod
 |
 | (a lot of rm & cp message...)
 |
+ cp -f /usr/local/lib/grub/i386-pc/video.lst /boot/grub
+ [ i386-pc = i386-pc ]
+ test -f /usr/local/lib/grub/i386-pc/boot.img
+ cp -f /usr/local/lib/grub/i386-pc/boot.img /boot/grub
+ test -f /usr/local/lib/grub/i386-pc/cdboot.img
+ cp -f /usr/local/lib/grub/i386-pc/cdboot.img /boot/grub
+ test -f /usr/local/lib/grub/i386-pc/diskboot.img
+ cp -f /usr/local/lib/grub/i386-pc/diskboot.img /boot/grub
+ test -f /usr/local/lib/grub/i386-pc/kernel.img
+ cp -f /usr/local/lib/grub/i386-pc/kernel.img /boot/grub
+ test -f /usr/local/lib/grub/i386-pc/lnxboot.img
+ cp -f /usr/local/lib/grub/i386-pc/lnxboot.img /boot/grub
+ test -f /usr/local/lib/grub/i386-pc/pxeboot.img
+ cp -f /usr/local/lib/grub/i386-pc/pxeboot.img /boot/grub
+ test -f '/usr/local/lib/grub/i386-pc/efiemu??.o'
+ mkdir -p /boot/grub/locale/
+ test -f '/boot/grub/locale/*.mo'
+ test -f '/usr/local/lib/grub/i386-pc/locale/*.mo'
+ /usr/local/sbin/grub-probe --device-map=/boot/grub/device.map --target=device /boot/grub
+ grub_device=/dev/ad4s3a
+ test -f /boot/grub/grubenv
+ /usr/local/sbin/grub-probe --device-map=/boot/grub/device.map --target=fs --device /dev/ad4s3a
/usr/local/sbin/grub-probe: error: no such partition.
+ fs_module=''
+ test x = x -a 'xufs2 bsd' = x
+ /usr/local/sbin/grub-probe --device-map=/boot/grub/device.map --target=partmap --device /dev/ad4s3a
+ partmap_module=''
+ /usr/local/sbin/grub-probe --device-map=/boot/grub/device.map --target=abstraction --device /dev/ad4s3a
/usr/local/sbin/grub-probe: error: no such partition.
+ devabstraction_module=''
+ modules='ufs2 bsd biosdisk'
+ modules='ufs2 bsd biosdisk   '
+ make_system_path_relative_to_its_root /boot/grub
+ /usr/local/bin/grub-mkrelpath /boot/grub
+ path=/boot/grub
+ uname
+ echo /boot/grub
+ relative_grubdir=/boot/grub
+ [ x/boot/grub = x ]
+ prefix_drive=''
+ config_opt=''
+ [ x = x ]
+ [ x/dev/ad4 != x ]
+ echo /dev/ad4
+ grep -qx '(.*)'
+ /usr/local/sbin/grub-probe --device-map=/boot/grub/device.map --target=drive --device /dev/ad4
+ install_drive='(hd0)'
+ echo '(hd0)'
+ sed -e 's/,[0-9]*[a-z]*//g'
+ install_drive='(hd0)'
+ /usr/local/sbin/grub-probe --device-map=/boot/grub/device.map --target=drive --device /dev/ad4s3a
+ grub_drive='(hd0,3,c)'
+ sed -e 's/,[0-9]*[a-z]*//g'
+ echo '(hd0,3,c)'
+ grub_drive='(hd0)'
+ [ biosdisk = ata ]
+ [ 'x(hd0)' != 'x(hd0)' ]
+ [ i386-pc = i386-pc ]
+ /usr/local/bin/grub-mkimage --output=/boot/grub/core.img --prefix=/boot/grub ufs2 bsd biosdisk
+ /usr/local/sbin/grub-setup --verbose --directory=/boot/grub --device-map=/boot/grub/device.map /dev/ad4
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: info: changing current directory to /dev.
/usr/local/sbin/grub-setup: info: changing current directory to fd.
/usr/local/sbin/grub-setup: info: changing current directory to dri.
/usr/local/sbin/grub-setup: info: changing current directory to usb.
/usr/local/sbin/grub-setup: info: changing current directory to ntfs.
/usr/local/sbin/grub-setup: info: getting the size of /boot/grub/boot.img.
/usr/local/sbin/grub-setup: info: reading /boot/grub/boot.img.
/usr/local/sbin/grub-setup: info: getting the size of /boot/grub/boot.img.
/usr/local/sbin/grub-setup: info: getting the size of /boot/grub/core.img.
/usr/local/sbin/grub-setup: info: reading /boot/grub/core.img.
/usr/local/sbin/grub-setup: info: getting the size of /boot/grub/core.img.
/usr/local/sbin/grub-setup: info: the size of hd0 is 488397168.
/usr/local/sbin/grub-setup: error: no such partition.
+ exit 1
```

And device.map


```
#less /boot/grub/device.map 
(hd0)   /dev/ad4
```

Look like grub-probe not recognize bsd slice /dev/ad4s3a... How can I fix it? Thanks a lot.


----------



## dandelion (Jan 5, 2011)

Try to use grub-mkimage(1) and grub-setup(8) directly, e.g.
`$ grub-mkimage -o /boot/grub/core.img -c /boot/grub/load.cfg -O i386-pc biosdisk part_msdos part_bsd search_fs_uuid ufs2 ntfs`
`$ grub-setup -s --root-device='(hd0)' /dev/ad4`
where load.cfg contains smth like

```
set root=(hd0,3,1)
```


----------



## epopen (Jan 6, 2011)

dandelion said:
			
		

> Try to use grub-mkimage(1) and grub-setup(8) directly, e.g.
> `$ grub-mkimage -o /boot/grub/core.img -c /boot/grub/load.cfg -O i386-pc biosdisk part_msdos part_bsd search_fs_uuid ufs2 ntfs`
> `$ grub-setup -s --root-device='(hd0)' /dev/ad4`
> where load.cfg contains smth like
> ...


Thanks you very much...
I used under command
`$ grub-mkimage -o /boot/grub/core.img biosdisk search_fs_uuid ufs2 ntfs`
`$ grub-setup -s --root-device='(hd0)' /dev/ad4`
1. I don't know load.cfg before, So I didn't use it.
2. i386-pc & part_bsd/msdos complain doesn't exist?
3. I forget use "bsd" module or not...

After boot, grub said "unknow filesystem". and enter grub rescue mode...
But use "ls" command in grub rescue prompt, only (hd0), shall be (hd0),(hd0,1),(hd0,2),(hd0,3) I think..
Grub didn't get full information from HDD.
I don't why.
I will fix it in rescue mode...
Thanks you a lot.


----------



## epopen (Jan 13, 2011)

Thanks, solved.
I use command for install
`$ grub-mkimage -o /boot/grub/core.img -c /boot/grub/load.cfg biosdisk part_msdos bsd search_fs_uuid ufs2 msdospart`
`$ grub-setup --root-device='(hd0)' /dev/ad4`

And load.cfg

```
set root=(hd0,3,a)
set prefix=(hd0,3,a)/boot/grub
```
I can boot to menu mode.
But I can't run grub-mkconfig complete, because "grub-probe: error: no such partition" error.
So I edit grub.cfg

```
### BEGIN /usr/local/etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  set saved_entry=${prev_saved_entry}
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z ${boot_once} ]; then
    saved_entry=${chosen}
    save_env saved_entry
  fi
}

menuentry "FreeBSD" --class freebsd --class bsd --class os {
        set root='(hd0,3,a)'
        echo                    Loading kernel of FreeBSD kernel ...
        kfreebsd                /boot/kernel/kernel
        kfreebsd_loadenv        /boot/device.hints
        set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ad4s3a
        set kFreeBSD.vfs.root.mountfrom.options=rw
}

menuentry "Microsoft Windows vista" {
        insmod ntfs
        set root=(hd0,1)
        chainloader +1
}
```

Now work fine.
I don't know why grub-probe work fail...
If it work fine, I can use grub-install maybe
Thanks you a lot


----------



## cucu007 (Feb 16, 2011)

There are a few things not working in grub...I hope the port maintainer work on it and get it going for 8.2. I cannot get thing going myself using i386 8.1. Can someone provide a how to install and get this going.


----------

