RSS icon Home icon
  • Ubuntu Grub headaches

    Posted on June 19th, 2015 admin No comments

    Today I had to install an Ubuntu 14.04.2 LTS system on a two-disk PC, with software RAID1, which I did many times before.

    The disks and raid setup went fine, but when reaching the GRUB install it reports “fatal error”.
    I skipped the bootloader install and finished the OS setup. Of course, the system didn’t boot…

    After a little googling, I can resolve all booting problems.

    I was able to boot from CD in rescue mode, but grub-install didn’t work either:

    #grub-install /dev/sda Installing for i386-pc platform.
    grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won’t be possible.
    grub-install: error: embedding is not possible, but this is required for cross-disk install.

    The PC contains a new UEFI BIOS (GigaByte 3D UEFI DualBIOS).

    The OS install sets GPT partition automatically but there’s no BIOS boot partition entry created which
    is a must for Grub2 second stage. This must be due to the “manual partitioning”.

    Luckily, the setup left ~1MB unused space on the drives before the first partition (partition alignment policy), so I can use it for the boot partition.

    To edit the partition table I needed the parted tool. After entering the command I got a new prompt.
    The following commands can be entered afterwards.

    # Select the device (e.g. /dev/sda)
    select /dev/sdX

    # Prints unused spaces
    print free

    # Creates a new partition on an unused space
    # where N1/N2 is the start/end (e.g. 17.4kB 1049kB).
    # Ignore the warning about the best performance complain.
    mkpart primary N1 N2

    # Print the new partition scheme

    # Sets the new partition as the Grub boot partition
    # where N is the newly created partition number.
    set N bios_grub on

    Repeat these steps for the second drive in the RAID array (e.g. /dev/sdb) then quit from parted.

    After this changes, the new partition list may looks like this:

    Number Start End Size File system Name Flags 5 17.4kB 1049kB 1031kB primary bios_grub 1 1049kB 15.0GB 15.0GB ext3 raid 2 15.0GB 440GB 425GB ext3 raid 3 440GB 470GB 30.0GB ext3 raid 4 470GB 500GB 30.1GB ext3 raid

    Install the Grub2 bootloader into both disks then restart PC:

    grub-install /dev/sda
    grub-install /dev/sdb

    After these changes, I was still unable to boot into Ubuntu Linux. The boot procedure stops at the Grub> prompt. To be able to boot from this point, I entered the following commands:

    set root=(md/0)
    linux /vmlinuz root=/dev/md0 ro
    initrd /initrd.img

    I repeated the grub-install commands and update-grub then everything went fine, the OS boots after restart. However, there is one glitch remains. At the boot process the following error message shows for a few seconds:

    error: Diskfilter writes are not supported


    After a quick search, I found this is a bug: Bug #1274320 “Error: diskfilter writes are not supported”

    The solution is to patch the /etc/grub.d/00_header file: link to patch.

    I preserve here the complete diff:

    diff --git a/util/grub.d/ b/util/grub.d/
    index 8dc5592..7ab59e3 100644
    --- a/util/grub.d/
    +++ b/util/grub.d/
    @@ -102,23 +102,42 @@ function savedefault {
     if [ "$quick_boot" = 1 ]; then
    -    cat <<EOF
    +  cat <<EOF
     function recordfail {
       set recordfail=1
    +  check_writable () {
    +    abstractions="$(grub-probe --target=abstraction "${grubdir}")"
    +    for abstraction in $abstractions; do
    +      case "$abstraction" in
    +	diskfilter | lvm)
    +	  cat <<EOF
    +  # GRUB lacks write support for $abstraction, so recordfail support is disabled.
    +	  return
    +	  ;;
    +      esac
    +    done
         FS="$(grub-probe --target=fs "${grubdir}")"
         case "$FS" in
           btrfs | cpiofs | newc | odc | romfs | squash4 | tarfs | zfs)
     	cat <<EOF
       # GRUB lacks write support for $FS, so recordfail support is disabled.
    +	return
    -      *)
    -	cat <<EOF
    -  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
         cat <<EOF
    +  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
    +  }
    +  check_writable
    +  cat <<EOF

    Leave a Reply

    Your email address will not be published. Required fields are marked *