Bug#852128: grub: Grub not reliable with fragmented initrd on btrfs

Juergen Pfennig info at j-pfennig.de
Sat Jan 21 19:43:47 UTC 2017


Package: grub-pc-bin
Version: 2.02~beta2-22+deb8u1
Severity: wishlist
File: grub
Tags: d-i

Dear Maintainer,

GRUB works happily on BTRFS when kernel(?) and initrd files are not
fragmented. But when initrd fragmentation count is > 1 then:

- an HP elitebook always fails to load initrd (junk in compressed
  archive -> kernel panic)
- the same HP boots fine after defragi of initrd.
- an Lenovo E31 sometimes fails (but sometimes boots) when fragmented
- the Lenovo always boots fine after defrag

Obviously fragementation depends on the disk state (free space) and
typically happens after unattended updates that rebuild initrd. The
initrd size does not directly matter (obviously a "most" initrd is easier
to fragment than a "dep" initrd). The problem does not depend on kernel
versions (4.5 .. 4.8).

More or less the same config (attached here from Lenovo E31) is used on
3 Notebooks, 1 Workstation and 1 Server. The problem was seen multiple
times on the 2 mentioned Notebooks. Other systems whithout btrfs root
volume but the same software configuration are not affected.

Thanks for your attention,
Jürgen


-- Package-specific info:

*********************** BEGIN /proc/mounts
/dev/sda1 / btrfs rw,noatime,ssd,space_cache,subvolid=548,subvol=/Volumes/Root 0 0
/dev/sda1 /export btrfs rw,noatime,ssd,space_cache,subvolid=393,subvol=/Volumes/Export 0 0
/dev/sda1 /home btrfs rw,noatime,ssd,space_cache,subvolid=392,subvol=/Volumes/Home 0 0
*********************** END /proc/mounts

*********************** BEGIN /boot/grub/grub.cfg
# common grub.cfg - jpf at centauri for jessie/stretch (c) 2016-11-20

### ### configuration section ### ### 

set myname=alpha7
set distro=jessie

# <empty>: verbose boot, nosplash: fancy, splash: plymouth
set splash=nosplash

set params=
#set params="$params acpi_osi="
#set params="$params libata.force=3:3.0G"
#set params="$params drm_kms_helper.edid_firmware=HDMI-1:edid/1280x1024.bin"

# video mode

# "gfxmode=auto" and "gfxpayload=keep" are preferred settings. Later during boot
# the  kernel by default switches to the modsetting driver. If it does not work
# use the kernel parameter "nomodeset" and grub "gfxpayload=text" if required.

set gfxmode=auto
#set gfxmode=800x600
#set gfxmode=1366x768
set gfxpayload=keep
#set gfxpayload=text

# keyboard language (see /admin/grub-keybd-de)
set kblang=de

### ### implementation section ### ### 
insmod part_msdos
insmod ext2
insmod btrfs

# default menu entries
set default=2 
set default_men=1
set default_win=4
set timeout=0
set pager=1
set rootdir=
set rootlbl=

# other parameters
if   search --no-floppy --label --set root ${myname}_vol0 ; then
    set rootlbl=${myname}_vol0  ; set rootdir="/Volumes/Root"
elif search --no-floppy --label --set root ${myname}_root ; then
    set rootlbl=${myname}_root
elif search --no-floppy --label --set root ${distro}_vol0 ; then
    set myname="$distro" ; set rootdir="/Volumes/Root"
elif search --no-floppy --label --set root ${distro}_root ; then
    set myname="$distro"
else
    search --no-floppy --label --set root linux_root
    set myname="linux" 
fi

if test -z "${rootlbl}" ; then set rootlbl="${myname}_root" ; fi
if test -z "${splash}"  ; then set splash="systemd.show_status=1" ; fi

# kernel/initd location 
set kernel=${rootdir}/vmlinuz
set initrd=${rootdir}/initrd.img
if test -e ${rootdir}/boot/current ; then
    set kernel=${rootdir}/boot/current
    set initrd=${rootdir}/boot/current.img
elif test -e ${rootdir}/boot/vmlinuz ; then
    set kernel=${rootdir}/boot/vmlinuz
    set initrd=${rootdir}/boot/initrd.img
fi

# boot message
insmod vbe
terminal_output gfxterm

set color_normal=white/black
echo
echo "Booting: $myname ($root)$kernel LABEL=$rootlbl"
echo
echo
set color_normal=white/blue
echo "                                                             "
echo "   Hold down the 'ctrl' key to enter the GRUB boot menu or   "
echo "             the 'alt'  key to boot an alternate system...   "
echo "                                                             "

set color_normal=white/black
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue

set lvers="Linux"
if   test $distro = "jessie"  ; then set lvers="Debian 8.x" 
elif test $distro = "stretch" ; then set lvers="Debian 9.x"
fi

# setup network mode
set nmode="simple"
if   test -e ${rootdir}/etc/network/interfaces.smart  ; then set nmode="smart"
elif test -e ${rootdir}/etc/network/interfaces.simple ; then set nmode="simple"
elif test -e ${rootdir}/etc/network/interfaces.static ; then set nmode="static"
fi

# load late, user can read menu
insmod vbe
insmod gfxterm
loadfont ${rootdir}/usr/share/grub/unicode.pf2
set locale_dir=${rootdir}/boot/grub/locale
set lang=de
insmod gettext

# Check for pressed key (shift interrupts sleep)
sleep --interruptible 3
clear
if keystatus; then
   if keystatus --alt; then
      set default=$default_win
   else
      if keystatus --ctrl; then

         # load image
         echo "Loading menu - please wait ..."
         insmod png
         # btrfs boot makes abs symlinks broken, use private symlink
         if background_image ${rootdir}/boot/grub/desktop-grub.png; then
            set menu_color_normal=light-gray/black
            set menu_color_highlight=white/black
         elif background_image ${rootdir}/usr/share/images/desktop-base/desktop-grub.png; then
             set menu_color_normal=light-gray/black
             set menu_color_highlight=white/black
         else
             set color_normal=white/black
         fi
         set timeout=-1
         set default=$default_men

         # load keymap 
         if test -e ${rootdir}/boot/grub/layouts/${kblang}.gkb ; then
            insmod at_keyboard
            insmod keylayouts
            keymap de
            terminal_input at_keyboard
         fi
      fi
   fi
fi

### ### The boot Menu section ### ###

menuentry "$lvers ($distro) ..." {
    true
}

menuentry "+    Maintenance mode   (console)" {
    linux   $kernel root=LABEL=$rootlbl ro centauriswitch="$nmode" $params quiet systemd.show_status=1 2
    initrd  $initrd
}

### normal mode: smart, static, simple [default]

if test "$nmode" = "smart" ; then
    menuentry "+    Notebook mode      (multiple network interfaces)" {
	linux	$kernel root=LABEL=$rootlbl ro centauriswitch=smart $params quiet $splash resume=LABEL=${myname}_swap
        initrd  $initrd
    }

elif test "$nmode" = "static" ; then
    menuentry "+    Workstation mode   (static network configuration)" {
	linux	$kernel root=LABEL=$rootlbl ro centauriswitch=static $params quiet $splash resume=LABEL=${myname}_swap
        initrd  $initrd
    }

else
    menuentry "+    Workstation mode   (single network interface)" {
	linux	$kernel root=LABEL=$rootlbl ro centauriswitch=simple $params quiet $splash resume=LABEL=${myname}_swap
        initrd  $initrd
    }
fi

### extra modes: switch router

if test -e ${rootdir}/etc/network/interfaces.switch ; then
    if test $default = 5 ; then set default=6 ; fi
    if test $default = 4 ; then set default=5 ; fi
    menuentry "+    Switch mode        (network switch, optional dhcp)" {
        linux   $kernel root=LABEL=$rootlbl ro centauriswitch=switch $params quiet $splash resume=LABEL=${myname}_swap
        initrd  $initrd
    }
fi

if test -e ${rootdir}/etc/network/interfaces.router ; then
    if test $default = 6 ; then set default=8 ; fi
    if test $default = 5 ; then set default=7 ; fi
    if test $default = 4 ; then set default=6 ; fi
    menuentry "+    Deflt router mode  (umts router)" {
        linux   $kernel root=LABEL=$rootlbl ro centauriswitch=router $params quiet $splash resume=LABEL=${myname}_swap
        initrd  $initrd
    }
    menuentry "+    Phone router mode  (wlan router)" {
        linux   $kernel root=LABEL=$rootlbl ro centauriswitch=router:phone $params quiet $splash resume=LABEL=${myname}_swap
        initrd  $initrd
    }
fi

### other os: memtest windows

menuentry "Other Operating Systems ..." {
    true
}

if test -e ${rootdir}/mnt/windows ; then
    menuentry "+    MicroSoft Windows" {
        insmod ntfs
        set root="hd0,1"
        chainloader +1
    }
fi

if test -e ${rootdir}/boot/memtest86+.bin ; then
    menuentry "+    Memory test        (memtest86+)" {
        linux16 $rootdir/boot/memtest86+.bin
    }
fi

if   test "$root" = "hd0,msdos3"  ; then
    menuentry "+    Linux GRUB minimal (console)" {
        set     root=hd0,msdos3
        set     base=/Volumes/Root/boot
        set     gfxpayload=keep
        linux   $base/vmlinuz root=/dev/sda3 ro nomodeset quiet systemd.show_status=1 centauriswitch=disabled 2
        initrd  $base/initrd.img
    }
elif test "$root" = "hd0,msdos2"  ; then
    menuentry "+    Linux GRUB minimal (console)" {
        set     root=hd0,msdos2
        set     base=/Volumes/Root/boot
        set     gfxpayload=keep
        linux   $base/vmlinuz root=/dev/sda2 ro nomodeset quiet systemd.show_status=1 centauriswitch=disabled 2
        initrd  $base/initrd.img
    }
else
    menuentry "+    Linux GRUB minimal (console)" {
        set     root=hd0,msdos1
        set     base=/Volumes/Root/boot
        set     gfxpayload=keep
        linux   $base/vmlinuz root=/dev/sda1 ro nomodeset quiet systemd.show_status=1 centauriswitch=disabled 2
        initrd  $base/initrd.img
    }
fi

### Local boot entries ###

### end ###
*********************** END /boot/grub/grub.cfg

*********************** BEGIN /proc/mdstat
cat: /proc/mdstat: No such file or directory
*********************** END /proc/mdstat

*********************** BEGIN /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Jan 21 11:05 ata-ADATA_SP550_2G1220042699 -> ../../sda
lrwxrwxrwx 1 root root 10 Jan 21 11:05 ata-ADATA_SP550_2G1220042699-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jan 21 11:05 ata-ADATA_SP550_2G1220042699-part2 -> ../../sda2
*********************** END /dev/disk/by-id

*********************** BEGIN /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 Jan 21 11:05 3f03f231-d627-4e1f-a52b-316c251699f2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jan 21 11:05 9fbaaf5e-3123-4896-a006-61149ee4ba39 -> ../../sda1
*********************** END /dev/disk/by-uuid

-- System Information:
Debian Release: 8.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.8.0-0.bpo.2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US, LC_CTYPE=de_DE.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages grub-pc-bin depends on:
pn  grub-common         <none>
ii  libc6               2.19-18+deb8u7
ii  libdevmapper1.02.1  2:1.02.90-2.2+deb8u1

grub-pc-bin recommends no packages.

Versions of packages grub-pc-bin suggests:
ii  desktop-base  8.0.2

-- no debconf information



More information about the Pkg-grub-devel mailing list