grub rescue btrfs

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.. 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: http://sdtimes.com/bcache-grows-into-a-full-file-system. 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 stuck at grub rescue prompt as below. understanding troubleshooting concepts and the grub/btrfs architecture helps us recover from this problem. 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.

slackware netinstall

you won't see many docs about minimal netinstall slackware. indeed, you might see many experts saying there is no such thing. and your only option is to download the entire lot. sad, i know!

slackware can be installed over the network without downloading that humunguous recommended dvd. not everyone wants kde, compilers, etc. netinst is very efficient, particularly if you need a minimal install.

if you don't have a dvd-drive to boot, then you are not left with much choice. you also need to consider, if bandwidth is an issue. do you need to download that whole dvd content, if you are only installing a minimal system?

however, if you are a slackware newbie, you might install multiple times before you get it right. in that case, a one-time download might be more efficient. still, unless one is installing all the bells n whistles, an entire dvd worth of installs is a bit ott!

choose a nearby mirror from http://mirrors.slackware.com/mirrorlist/
ps: the main mirrors - slackware.org | slackware.org.uk - are throttled and may ban you, if you connect multiple times. so choose another mirror.

go to /slackware-current/usb-and-pxe-installers
download usbboot.img
read README_USB.TXT

ignore all of that, but create your usb bootable slackware installer.
boot it, and start setup.

when asked to choose your install source media, select "4 Install from FTP/HTTP server"



server is your mirror from above. for eg, http://slackware.org.uk

location is the directory containing PACKAGES.TXT. for eg, /slackware/slackware-current/slackware/

that's it!

most popular posts