fonts should be installed to /boot/grub

Bug #615769 reported by Michael Kofler
54
This bug affects 10 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Triaged
Medium
Unassigned
ubiquity (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: grub2

fonts for GRUB 2 are installed to /usr/share/

if / is not readable for grub (i.e. because / is a btrfs filesystem), GRUB can only use fonts in a separate /boot partition

I stumbled over this when I tried to set a GRUB background image on a btrfs system. It didn't work because GRUB started in text mode. And it took me a while to find out why (because it could not find a font file).

Colin Watson (cjwatson)
Changed in grub2 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
vadimo (michalgejdos-azet) wrote :

I installing Xubuntu 11.04:
/ on btrfs (lzo compression)
/boot on ext2

After restarting system i got this message from grub:

error: font format error: can't read section name
error: no suitable mode found.

After 5 sec is the message unreadable (bad font?). System is properly loaded.
Shift key working and also grub menu is readable.
In attachment is photo this message.

Revision history for this message
vadimo (michalgejdos-azet) wrote :

In photo attachment i do mistake.
Property --> Properly
:-D

Revision history for this message
Brian K. White (bkw777) wrote :

Ubuntu 12.04 with grub 1.99-21ubuntu3.1

Same problem here but not because of btrfs or any other filesystem support.

In my case it's because / lives on a built-in sdcard reader in a Sony Vaio P netbook.
The card reader is not bootable, has no bios support, and at boot time grub has no driver that can see it.

/boot does live on a bootable drive, a usb stick, and internal hd is all Windows 8 Consumer Preview.
So /boot is on a small removable usb drive and / is entirely on a 32G sdcard.

update-grub generates a grub.conf that refers to (sdcard,partition)/usr/share/... for background image and for font.

At boot time, sdcard is not is not accessible and so the loadfont line fails, and so gfxterm does not load.
Booting still works. It fails gracefully and falls back to a non-gfxterm plain text mode that functions.

The wallpaper image can be taken care of by copying it to somewhere under /boot and editing /etc/default/grub to reflect that.

But the font is still a problem.

If I manually copy unicode.pf2 to /boot/grub, and manually change /boot/grub/grub.cfg to refer to the external usb drive that /boot lives on instead of the internal card reader that / lives on, then at boot time gfxmenu and the background image and the font all load as normal.

It appears that the tests is /usr/share/grub/grub-mkconfig_lib fail to guess that / will not be accessible at boot time.

So if that can't be made smarter, then at least we need a /etc/default/grub option to TELL it. It looks like the rest of the code would do the right thing and automatically copy any wallpapers and fonts to /boot/... and write grub.cfg to refer to those copies instead of the originals if there was just a way to override the automatic detection and tell it that / will not be available.

Right now my manual changes get lost every time update-grub runs.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

If you do:

    $ sudo apt-get --install --reinstall grub2
    $ sudo update-grub

The fonts would actually be copied into /boot/grub

How did you install your system?

   * ubiquity (Desktop Live CD)
   * debian-installer (alternate, server, pxe boot) ?

Revision history for this message
Brian K. White (bkw777) wrote :

Previously the best work-around I found was creating a file /boot/grub/custom.cfg with this in it:

[CODE]
# Manually re-load gfxterm
# update-grub generates a grub.cfg that thinks grub can see the SD card reader
# (where "/" lives) at boot time to get the font for gfxterm from /usr/share/...
# So we do manually here what update-grub fails to do automatically in grub.cfg
insmod part_msdos
insmod ntfs
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root 12E2D580E2D5688D
if loadfont /linux_boot/grub/fonts/unicode.pf2 ; then
        set locale_dir=($root)/linux_boot/grub/locale
        set lang=en_US
        set gfxmode=1600x768x16
        set gfxterm_font=unicode
        load_video
        insmod gfxterm
        insmod gettext
        insmod png
        terminal_output gfxterm
        background_image /linux_boot/grub/VaioP_Green.png
fi
[/CODE]

That's arcane and full of ugly hard-coded stuff that will break and update-grub will not update when the underlying details change.
That root= and uuid point to the windows ntfs partition C: drive on the main pata drive.
The path /linux_boot is a directory C:\linux_boot on that ntfs filesystem.
(/boot is symlinked to /windows/linux_boot. Remember / is not visible to grub at boot time.)

This works, but I finally found instead of all that junk you don't need any custom.cfg at all unless you need it for other stuff.

Recent versions of grub2 copy unicode.pf2 to /boot/grub/fonts.
As long as that's there, then all you need to do is one time run this:

grub-editenv - set feature_default_font_path=y

Now update-grub still produces a grub.cfg that points to /usr/share , but now this part gets invoked instead of the part that tries to use the unreachable path:
if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else

You only have to run it once and subsequent update-grub doesn't break it.

As far as I'm concerned this is almost as good as a variable in /etc/default/grub. It's main problem is it's unfindable in any documentation. But it satisfies my request above for "a way to tell it not to try to use /" .

There does seem to be an undocumented variable GRUB_FONT that you can put in /etc/default/grub, but I couldn't figure out how to make it work. No matter what I put in there, it would just break update-grub.

root@noexcuse:~# update-grub
Generating grub.cfg ...
/usr/sbin/grub-probe: error: failed to get canonical path of unicode.pf2.
/usr/sbin/grub-probe: error: cannot find a GRUB drive for . Check your device.map.
root@noexcuse:~#

unicode
unicode.pf2
fonts/unicode.pf2
grub/fonts/unicode.pf2
/linux_boot/grub/fonts/unicode.pf2
/boot/grub/fonts/unicode.pf2
all failed the same way

And pinfo grub does not say anything about it. It didn't say anything about feature_default_font_path either, I found that by reading the scripts and the generated grub.cfg and GUESSING.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ubiquity (Ubuntu):
status: New → Confirmed
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This release of Ubuntu is no longer receiving maintenance updates. If this is still an issue on a maintained version of Ubuntu please let us know.

Changed in ubiquity (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This issue has sat incomplete for more than 60 days now. I'm going to close it as invalid. Please feel free re-open if this is still an issue for you. Thank you.

Changed in ubiquity (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.