grub rescue btrfs ubuntu

to play more seriously with yet another distro, i needed to install it. so i had some fun resizing/moving partitions around to clear some freespace for a new partition. during this, the partition numbering changed. i couldn't boot ubuntu's btrfs partition. i didn't understand why, till i discovered that partition numbers are hardcoded into the grub boot record.. even though grub cfg contains only labels or uuids. tsk tsk! yet another reason why i seem to be going off grub2. i'm playing around with extlinux, and i seem to like it more & more. but that's another story for another time.

trawling through the net, you might see many experts making dubious claims that btrfs cannot be used for /boot partition, or grub doesn't work with btrfs, etc. i have a few systems on btrfs.. booting with grub or extlinux. i haven't noticed any issues yet. and i always keep root & boot together.

am i moving to btrfs? umm.. no! it is early days for btrfs, still considered experimental. i prefer efficiency over feature-bloat. and btrfs seems to be more efficient than the current ones on the scene. on that note, there seems to be another worthy contender hovering on the horizon.. bcachefs: open-source is good for the soul :-)

but i digress again.. back to our topic.

trying to boot the ubuntu btrfs partition would end up at grub rescue prompt as below. understanding troubleshooting concepts and the grub/btrfs architecture can help us recover from such problems. if you are not on ubuntu or btrfs, customise the below process accordingly. if you follow all the steps below, hopefully there is enough for you to find your own way. i had to attempt multiple times, and each time i got a bit closer. knowing this your (or my later) attempts should be far fewer.

grub rescue>

this is a very limited grub shell, containing a tiny subset of commands from normal grub.

stage 1: diagnostics

we gather all the information, and understand what needs change. our intention is to get to the normal grub prompt. for that we need access to the /boot/grub directory, which contains the grub modules.

let's find out what is hard-coded by grub

grub rescue> set

list all disks & partitions. identify where we are.

grub rescue> ls
grub rescue> ls /

step-by-step, we reach the grub modules.

grub rescue> ls (hd0,9)/

debian installer doesn't create btrfs subvolumes, but ubuntu does and calls it '@'. we need to remember to use this '@' for all disk operations.

grub rescue> ls (hd0,9)/@/
grub rescue> ls (hd0,9)/@/boot/
grub rescue> ls (hd0,9)/@/boot/grub/

if we see the directory listings we expect, we know this is the correct partition. so we can set our root & prefix.

grub rescue> set root=(hd0,9)

grub rescue> set prefix=(hd0,9)/@/boot/grub/

this allows us to escape grub rescue, and reach the normal grub. or even better, the expected grub menu.

grub rescue> insmod normal

grub rescue> normal

there now we can breathe a sigh of relief.. but it's not over yet!!

what we do from here is pretty standard. choose the menu entry, and boot. if this fails, as it probably would.. we start our diagnostics again. but this time, we are in the normal grub, with it's full suite of commands at our disposal.

we start by checking the grub settings again, to find what is incorrect.

grub> set

now that we know all the settings we need, we can attempt to boot our kernel.

grub> insmod part_msdos
grub> insmod btrfs

grub> insmod {gzio|xzio|lzopio|??}
grub> insmod linux

grub> set root=(hd0,9)
grub> linux  /@/boot/vmlinuz-3.19.0-26-generic root=/dev/sda9 ro rootflags=subvol=@
grub> initrd /@/boot/initrd.img-3.19.0-26-generic
grub> boot

sit back and watch your os boot :-)

if it didn't, you now know what you need to do. start all over again. hopefully each attempt will get you a bit closer, as our understanding grows. i had to make many attempts before i actually understood all this. hence why, i want to document all this, before i forget. hopefully, i might not be doing this very often. but now, i have a ready reference.

hopefully all is well with our os, and any problem was grub only. so let's login, and confirm everything ok.

as of yet, we have not made any change to our system. now we resolve this problem.

# dpkg-reconfigure grub-pc

confirm no errors, and reboot.

i was on ubuntu this time. if your system is not debian based, you won't have debian toolkit to automate everything. then we do it the grub way.

# update-grub
# grub-install /dev/sda9

confirm no errors, and reboot.


  1. Thanks man, you've really helpes me alot, i was stuck at this for two hours, without finding any solutions in the web... Thank you so much.

  2. Instead of "grub rescue btrfs ubuntu", a lot more "grub rescue ubuntu" articles on the web. If i saw your article last night, it would really save me several hours!


most viewed