Ubuntu on USB without BIOS support / partition unaccessible

Asked by Master

Good morning everyone.
New here I'll try to be clear...

Having some troubleshoot with the internal HD of my laptop, I installed Ubuntu 10.10 on a usb drive (in ext4) in /dev/sdb2 - (hd1,msdos2).
The /boot is actually /dev/sda - (hd0,msdos1) formated in ext because the first 32 MB of my internal hard drive are still accessible and it avoids my to need a boot CD. Grub2 is on the mbr of the internal HD. Version 1.98 ubuntu 3.1.

However, when Grub2 boots. I have a message stating that grub2 cannot get C/H/S of partition (hd1,msdos2), which is normal since there is no BIOS support in my (old) laptop but it finally boots (or show me the menu if I press shift) without any problem since it loads the kernel and initrd from internal HD, then recognizes the USB with the kernel/module and uses it as root.

After investigation, i found that in /boot/grub/grub.cfg, I have:

--------------------------------------------------------

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  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
}

function recordfail {
  set recordfail=1
  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
  insmod vbe
  insmod vga
}

insmod part_msdos
insmod ext2
set root='(hd1,msdos2)'
search --no-floppy --fs-uuid --set c9083da5-8561-4189-9e7e-d0ef9eed3e55
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set 8812973d-eff0-4248-8007-852e543290c6
set locale_dir=($root)/grub/locale
set lang=fr
insmod gettext
if [ "${recordfail}" = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###

ETC ETC.

-----------------------------------------------------------

As you can see, after the load_video function, there is:

insmod part_msdos
insmod ext2
set root='(hd1,msdos2)'
search --no-floppy --fs-uuid --set c9083da5-8561-4189-9e7e-d0ef9eed3e55
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  load_video
  insmod gfxterm
fi

which of course cannot work since the Usb HD is not accessible yet.

These lines come from the execution of 00_header:

if [ "x$gfxterm" = x1 ]; then
    # Make the font accessible
    prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT_PATH}"`

    cat << EOF
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
  set gfxmode=${GRUB_GFXMODE}
  load_video
  insmod gfxterm
fi

which uses /usr/lib/grub/grub-mkconfig_lib function's:

is_path_readable_by_grub ()
{
  path=$1

  # abort if path doesn't exist
  if test -e $path ; then : ;else
    return 1
  fi

  # abort if file is in a filesystem we can't read
  if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
    return 1
  fi

  return 0
}

It seems this function replies positively whereas the fs is not accessible at boot time.

Strange thing, the first time I installed 10.10 it was working but after a while & reinstalling not anymore...
May be the gfx sceen was disabled for some reason so it did not execute this part of the code. I don't see any option and anyway that would just be a workaround.

I tried using --root-directory=/boot manually for grub-install.

Any idea of how to specify the system some disk is not available at boot time before the kernel ?
And why is just unicode.pf2 copied in /boot/grub ?
Solved in natty ?

Thanks in advance, If we can fix all these little stuff, the system will be perfect !
Bye

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Solved by:
delance
Solved:
Last query:
Last reply:
Revision history for this message
zachariakassim (zachariakassim) said :
#1

if it is a desktop pc , disconect the internel harddisk then install ubntu in usb drive, othewise install ubnutu in usb drive in other pc and boot it with your laptop it should work

Revision history for this message
delance (olivier-delance) said :
#2

"However, when Grub2 boots...., which is normal since there is no BIOS support in my (old) laptop but it finally boots (or show me the menu if I press shift) ..."
As the menu is in /boot folder, which is, if I understand, on the USB key, it means that after having loading the stage 2 (which lies in 64 first block sectors of disk), Grub is able to read USB key, using its own drivers.
So I presume your issue is not related to USB management.
Did you try to reinstall Grub from Ubuntu USB key ?
Did you get issue after a system update (this week, a new kernel was delivered, with some boot issues) ?

Revision history for this message
Master (master123456-deactivatedaccount) said :
#3

No, the core.img does not include drivers for Usb.
Grub2 neither by the way, and since I have no support for USB in the BIOS, so no Usb drive recognized until the kernel/initrd are loaded.
Therefore grub2 should not make any reference to what is on the Usb drive, since it does not exist but for the kernel (except the root UUID setting argument in linux command line).

So I believe grub should have an option to tell which disks are unavailable at boot so that it stores what is needed (unicode.pf2, locales etc) on something available, typically /boot.

Revision history for this message
delance (olivier-delance) said :
#4

On which device is "/boot" ?
Do you see Grub menu ?

Revision history for this message
Master (master123456-deactivatedaccount) said :
#5

/boot is /dev/sda1 (hd0,msdos1), which is the only available partition.

I finally see grub2 menu after waiting twice for the partition c9083da5-8561-4189-9e7e-d0ef9eed3e55 (i.e. /dev/sdb1 to be found by the search command), which will never be completed since it is on the Usb drive, unavailable until the kernel/initrd have been loaded.

I removed the sections making reference to c9083da5-8561-4189-9e7e-d0ef9eed3e55 and it works, so that is why I say everything needed should be copied in /boot and no reference to any partition should be made, aprat from the argument of the kernel.

Revision history for this message
Best delance (olivier-delance) said :
#6

I reread the question more carefully.
You have a bootable hard drive of 32MB (like me in the 80s), which holds "/boot" folder.
You have a USB disk, which can't be managed by the BIOS, on which is system folder "/", including /etc/fstab.
You are able to boot when you remove some reference to this system partition.
Each time Grub is updated (installation of a new kernel), you lost boot.

In my grub.cfg file, I have
search --no-floppy --fs-uuid --set 068e7fcc-df66-4a3a-a3dd-b1322fc240d0
linux /boot/vmlinuz-2.6.35-25-generic root=UUID=068e7fcc-df66-4a3a-a3dd-b1322fc240d0 ro quiet splash
Which one of the two references did you remove ? I presume it's the first.

About knowing if you will have to remove manually this reference each time you install a new kernel, I'm afraid that answer is yes. Each time update-manager ask you to reboot to complete an update, you will have to manually check grub.cfg. You could log a bug, but as your configuration is very very unusual, I'm not sure someone will fix this issue.

Revision history for this message
Master (master123456-deactivatedaccount) said :
#7

Thanks for your reply,
this is exactly the situation.

However, I don't think it is so unusual as a config because someone installing Ubuntu on a Usb disk, keeping Windows on the internal Hd of his laptop and installing grub on the internal disk with a boot partition inside will be in the same situation.
But this is true that all the new PC's have support for usb and so grub2 can just be installed on the external hd Mbr.

Now my internal Hd just crashed completely, so I needed to create a boot cd, and I filed a bug for grub-mkrescue that doesn t handles the paths properly !

Revision history for this message
Master (master123456-deactivatedaccount) said :
#8

Thanks delance, that solved my question.