You are not logged in.

#1 2013-12-25 07:14:16

guidop
Member
Registered: 2013-11-30
Posts: 5

Workaround: Intermittent fail: No rollback with btrfs & grub2

Refer to this post [marked solved] for similar issue and additional background:
https://bbs.archlinux.org/viewtopic.php?id=150313

This problem still occurs for me INTERMITTENTLY on a fresh Arch install (2013-12-24), dual-booting with Windows 7, with the message:

 btrfs_advanced [WARN]: Root filesystem UUID=1234.....abc is not a BTRFS filesystem. 

When this happens, there is no rollback functionality available: No message saying to press any key for rollback, and pressing keys anyway yields nothing.

I've followed the same install steps (excluding dual booting) on a Virtualbox VM a few hours before attempting it on bare hardware.
On the VM, the rollback hook at boot works [almost?] every time [Maybe it failed to appear once?].
On the dual-boot install, the warning message and rollback hook failure occurs almost every time.

Both installs are using the following [up-to-date] versions of mkinitcpio-btrfs and grub:

mkinitcpio-btrfs-0.4.1-1-any.pkg.tar.xz
grub 1:2.00.1282.g5ae5c54-1

On both installs, I added the: "GRUB_DISABLE_SUBMENU=y" workaround to /etc/default/grub to stop the grub-mkconfig error.
Both installs are also using a logical partition (/dev/sda5) as the btrfs-root volume.

Is there maybe some timeout I can extend so my root partition is more reliably recognized as btrfs?

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

Update 2013-12-26:

OK, so /usr/lib/initcpio/hooks/btrfs_advanced is a shell script, and was failing this test:

    # root must be btrfs else silent return
    if [ "$(blkid -s TYPE -o value ${root} 2>/dev/null)" != "btrfs" -a "$(blkid -s TYPE -o value -lt ${root} 2>/dev/null)" != "btrfs" ]; then
        btrfs_warn "Root filesystem ${root} is not a BTRFS filesystem"
        return 0
    fi

I added some quick checks at the beginning of the file, and reran mkinitcpio -p linux

echo "btrfs_advanced - filesystem checks:"
echo "root = ${root}"
echo "blkid"; blkid
sleep 5
echo "blkid"; blkid
echo "btrfs_advanced - fileshstem checks - done"

I finally caught an instance where the first blkid returned nothing, and the second returned correct information.
If the second blkid test returns (correct) nonblank data, then the test also passes, and the rollback option appears as intended.

So it looks like a timing issue.
Is blkid trying to read hardware (or the blkid cache) before it's ready or populated with data?

Does adding "rootdelay=60" to my GRUB_CMDLINE_LINUX variable in /etc/default/grub make the max wait for a root filesystem ready occur before or after the scripts in HOOKS are run?

I'll try more testing tomorrow.

Last edited by guidop (2013-12-30 23:01:36)

Offline

#2 2013-12-30 22:52:17

guidop
Member
Registered: 2013-11-30
Posts: 5

Re: Workaround: Intermittent fail: No rollback with btrfs & grub2

As a workaround, I wrote this hook script to ensure blkid returns valid data before running btrfs_advanced.

Add this file to /usr/lib/initcpio/hooks/blkid_wait

#!/bin/ash
# blkid_wait - delay until blkid returns valid root volume info - initramfs hook
# File location:  /usr/lib/initcpio/hooks/blkid_wait
# 2013-12-30  G.  Paolini - Initial version
# Copyright (c) 2013, G. Paolini
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: 
#
# 1. Redistributions of source code must retain the above copyright notice, this
#    list of conditions and the following disclaimer. 
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution. 
#
# All other rights reserved.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# hook name
: ${BLKID_HOOK_NAME:="blkid_wait"}

# output handlers
blkid_info () { [ "${quiet}" != "y" ] && echo -e ":: ${BLKID_HOOK_NAME} [INFO]: ${@}"; }
blkid_debug () { [ "${BLKID_WAIT_DEBUG}" == "y" ] && echo -e ":: ${BLKID_HOOK_NAME} [INFO]: ${@}"; }
blkid_fail () { echo -e ":: ${BLKID_HOOK_NAME} [FAIL]: ${@}"; }

# source config file if it exists - only intended functionis to override defaults
if [ -f /etc/default/blkid_wait ]; then
    . /etc/default/blkid_wait
    blkid_info "Configuration file /etc/default/blkid_wait loaded"
fi

# set defaults if not specified in config
: ${BLKID_WAIT_TIMEOUT:="60"}
: ${BLKID_WAIT_DEBUG:="y"}

# main function - try blkid to status root until sucessful or timeout reached
run_hook () {

    # blkid must return root status withing timeout or show failure
    blkid_info "Running blkid status check on root partition: \n    ${root}"
    local i="0"
    while [ "$(blkid ${root} 2>/dev/null)" == "" -a "$(blkid -lt ${root} 2>/dev/null)" == "" ]; do
        sleep 1
        i=$((${i}+1))
        if [ ${i} -ge ${BLKID_WAIT_TIMEOUT} ]; then 
            blkid_fail "blkid did not return ${root} status within ${BLKID_WAIT_TIMEOUT} seconds." 
        return 1
        fi
    done
    blkid_debug "Waited ${i} seconds for valid blkid root status."

}

# vim:set syntax=sh:

And the install file at /usr/lib/initcpio/install/blkid_wait:

#!/bin/bash
# File location:  /usr/lib/initcpio/install/blkid_wait
# 2013-12-30  G.  Paolini - Initial version

build() {

    if [ -f /etc/default/blkid_wait ]; then
        add_file /etc/default/blkid_wait
    fi

    add_runscript
}

help() {
    cat <<HELPEOF
This hook loops until blkid returns information on the defined
root partition, or a preset timeout is reached.
Works around an issue where blkid info is not yet available to
btrfs_advanced hook, which uses blkid to check if root TYPE=btrfs.
If needed, blkid_wait should immediately precede btrfs_advanced 
in HOOKS variable definition in /etc/mkinitcpio.conf.
HELPEOF
}

# vim: set ft=sh ts=4 sw=4 et:

My HOOKS variable in /etc/mkinitcpio.conf:

HOOKS="base udev autodetect modconf block filesystems keyboard blkid_wait btrfs_advanced"

At the time of posting, the script has been minimally tested.  I haven't yet tried a default file or forced failure modes.

On the system experiencing the original problem, with an ASUS M4A88T-I motherboard, and a pair of non-raided laptop hard drives, the script reports a 1 second (1 loop) delay before blkid returns valid data.


It would likely be simpler to change the test in /usr/lib/initcpio/btrfs_advanced, to add a time limited loop as part of the check for a btrfs root partition, but I wanted to avoid conflict with the standard mkinitcpio-btrfs AUR package.

I read through the mkinitcpio ArchWiki to learn how to write this hook, but I still don't know if my issue is something that should be patched, or if I just have missed something in my boot setup.  Help or comments are welcome.

Offline

#3 2014-01-09 18:49:18

KairiTech
Member
From: Toronto, Canada
Registered: 2011-06-04
Posts: 275

Re: Workaround: Intermittent fail: No rollback with btrfs & grub2

Just posted something very similar but the only common denominator seems to be ASUS mobos. I have an M5A99X EVO.

Offline

Board footer

Powered by FluxBB