[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Problems with grub2/initramfs-tools in chroot



Over the last week I've repeatedly found my machine unbootable, in the
sense I couldn't get to a working system without intervention.
Sometimes I couldn't even get the grub2 menu.

Things are OK now, but I'm trying to understand what went wrong so I
don't do it again.

I had multiple disks and was working on the first 2.  Initially I
worked on sdb and left sda blank.  My setup involves various extras:
software RAID, crypo (cryptsetup) and LVM, though not all system
instances used all those.  Disks were GPT (or blank); everything was
wheezy amd64.

I would install a system using debootstrap following Appendix D of the
installation manual.  I bind mounted /dev and /dev/pts, and usually
/sys and /proc to the chroot before switching to it.  I usually ran
the grub setup from within the chroot.

It's not clear to me exactly what is going on running grub-install
from a chroot.  Because of the bind mounts I assume it has access to
the devices so that grub-install /dev/sdb actually installs to sdb.
But the chroot simply has a file system without knowing how it was
mounted.  The chroot might not even have the packages to deal with its
filesystem (e.g., a chroot run on an encrypted LVM volume on top of
RAID need not have mdadm, cryptsetup, or lvm2 installed---not just in
theory but in my practice).

initramfs-tools tries to figure out what modules should be in the
initrd, but it's not clear to me how it decides (consulting fstab,
mdadm.conf and related files?  install a module if the relevant
package is installed? call the OS?  consult /proc?).  I think this led
to some problems, e.g., the chroot was on a /dev/mdx, but the mdadm
tools did not end up in the initrd.

Eventually I created a system on sda and ran gub-install /dev/sda from
inside the chroot.  Not only did the system not boot off sda, when I
told it to prefer booting off sdb I didn't get back what I had before;
instead I got an older setup for sdb.

Could changing the boot order in the BIOS change the drive mappings
and screw up grub that way?

Thanks for any wisdom.

Ross Boylan

P.S. When formatted, both disks got a bios_grub partition.


Reply to: