[TriLUG] booting an external disk with grub 0.97

Steve Litt via TriLUG trilug at trilug.org
Tue Apr 21 15:00:02 EDT 2015


On Tue, 21 Apr 2015 10:53:31 -0700 (PDT)
Joseph Mack NA3T <jmack at austintek.com> wrote:

> On Tue, 21 Apr 2015, Steve Litt via TriLUG wrote:
> 
> > No idea. Grub sux, Grub2 sux worse. LILO isn't much better.
> 
> yes ;-(
> 
> > But here's an idea. Just for fun, next time you boot, within Grub
> > modify the kernel line to add or change the init line to:
> >
> > init=/bin/bash
> 
> I didn't know you could do this, but it's well known
> 
> http://www.cyberciti.biz/faq/grub-boot-into-single-user-mode/
> 
> booting off my regular internal disk, at the grub prompt I did this
> edit (adding init=/bin/bash)
> 
> kernel (hd0,2)/boot/bzImage-3.5.3 ro root=/dev/sda3 init=/bin/bash
> 
> and booted.
> 
> The boot started as normal and then stopped at a bash prompt. Mounted
> was
> 
> /dev/sda3	/
> sysfs		/sys
> 
> all the commands in /bin etc work and I can see /dev/sd*
> 
> > Now, hopefully, you can come up using bash as a periscope to look
> > around just before your init would have run, and you can see what
> > things are called and the like.
> 
> there is no /dev/disk/ directory. I assume that requires udev (which
> hasn't loaded yet)?

Hi Joe,

You have two problems:

1) You need to teach your friend Python in a Linux environment
2) You have a fascinating boot problem


#1 is probably pretty simple: Make yourself up a Ubuntu live thumb
   drive with Python. Or just bring a Linux computer to his house for
   him to work on.

#2 I'm wondering if you *should* have an initramfs. What distro, what
   version? All that udev stuff gets done in the initramfs on Debian
   Wheezy and Manjaro OpenRC edition. Is your OS by any chance normally
   a systemd init?

More on booting: Like you, I'm a fan of no initramfs. To me, initramfs
is a compensation for edge cases and for self-inflicted injuries like

ln -s /usr/bin /bin

But guess what: You're working an edge case here :-). Booting from a
USB connected spinning drive is just not how the distro guys probably
envisioned their system being used.

An initramfs is simply a gzipped newc format cpio archive of a tree,
intended to be used as a RAM disk: In this case, your OS' first root
directory. Your bootloader loads the initramfs file into RAM, passes a
pointer to that RAM to the kernel, and the kernel knows enough to use
that RAM disk as its root directory. The kernel then runs /init
(oversimplification, but close enough for government work) to get the
computer ready to init from the disk-based init system: sysvinit,
upstart, systemd, Epoch, runit, etc.

The RAM disk's init typically starts UDEV, gets /sys and /proc going,
does some other stuff, mounts the future on-disk root partition,
copies /sys and /proc to that partition, and last but not least, uses
the switch_root command to switch the OS' root partition from the RAM
disk to the root partition on the hard disk, and to free up the RAM
formerly consumed by the RAM disk, *and* to run the init program
identified in the init= parameter of your kernel line in grub. It's
very possible that you could make a simple initramfs enabling you to
boot to your USB attached hard drive, with no references at all to the
internal hard drive.

Another possibility is to use one of the simpler init programs: Epoch
comes to mind. Epoch gives you *a lot* of control over the bringing up
of your computer, and you can have Epoch run your own, hand crafted
shellscripts to do *exactly* what you want. You could even hard-code
partition UUIDs in those shellscripts, to strongarm all action to your
USB mounted hard disk.

Is all this way too much work to set up a Python tutorial environment?
Heck yeah! Is it justified by your new understanding of how your
intricate boot works. Heck yeah!

If you do this stuff, please keep us informed.

SteveT

Steve Litt 
April 2015 featured book: Twenty Eight Tales of Troubleshooting
http://www.troubleshooters.com/28




More information about the TriLUG mailing list