[Wylug-help] USB Flash: device numbers, filenames and grub
John Hodrien
johnh at comp.leeds.ac.uk
Mon Jan 29 15:23:39 GMT 2007
On Mon, 29 Jan 2007, Dave Fisher wrote:
> Thanks John, I look into it.
>
> I didn't really assume, I merely didn't know enough about intrds to guide me
> in digging around inside one.
That's sort of what I meant. In the past I've tended to view initrds as
mythical black boxes that aren't supposed to be poked. More recent work with
network booting machines with nfs roots has forced me to work out more
convincingly how the sods work.
> All the initrd documentation that I've found so far, says that the initrd's
> /linuxrc normally determines how the root filesystem is mounted.
>
> Or:
>
> "If /linuxrc is not executed or when /linuxrc terminates, the normal
> root file system is mounted." (initrd man page)
>
> There is no linuxrc in any of the initrds that I've looked into.
Indeed not.
> However, http://en.wikipedia.org/wiki/Initrd says:
>
> "Most initial root file systems implement "/linuxrc" as a shell script
> and thus include a minimal shell (usually /bin/ash) along with some
> essential user-space utilities (usually the BusyBox toolkit)."
>
> I'm guessing (not assuming) from what I see in the extracted initrd,
> that the busybox utilities have configuration and init files similar to
> those in a normal linux filesystem.
Yes. In the ones I use there's actually a replacement for init, so the
startup is *very* simple. Effectively a single ash script (busybox).
> For example, I can see an /etc/udev/rules.d/ directory in the initrd,
> including a rules file which seems to assign device names as it might on
> a normal filesystem.
>
> Could I do any harm by adding my own rules file to that directory (as
> Anne does for a normal system), then re-archiving the initrd and trying
> to boot from it?
Sounds tempting to me.
> The ability to scan 'available devices, rather than assuming their location'
> does sound interesting, but I've barely the faintest idea about how I might use
> it in this case.
>
> What do you have in mind, i.e. how might it work?
>
> If the booting kernel can scan LVMs for a device matching a root="" parameter
> set in grub, what exactly would it be trying to match?
Well take this for example as my grub for a Fedora box:
title Fedora Core (2.6.19-1.2895.fc6)
root (hd0,2)
kernel /vmlinuz-2.6.19-1.2895.fc6 ro noht
root=/dev/VolGroup01/FC6 rhgb quiet
initrd /initrd-2.6.19-1.2895.fc6.img
So it's got an idea of the name it's expecting the lvm lv to be. The initrd
script is then quite simple and uses nash (I've cut the relevent bits out).
Beyond the basic setup you have:
echo "Loading dm-mirror.ko module"
insmod /lib/dm-mirror.ko
echo "Loading dm-zero.ko module"
insmod /lib/dm-zero.ko
echo "Loading dm-snapshot.ko module"
insmod /lib/dm-snapshot.ko
echo Making device-mapper control node
mkdmnod
mkblkdevs
echo Scanning logical volumes
lvm vgscan --ignorelockingfailure
echo Activating logical volumes
lvm vgchange -ay --ignorelockingfailure VolGroup01
By this stage you actually have a useful /dev/ with all the bits in that you
including by now /dev/VolGroup01/FC6. So from there on out it's easy.
All the LVM scanning is done by LVM itself. Effectively PVs are labelled with
enough information for lvm to work out what they are. I just happily accept
that it works for the moment.
> N.B. I realise that may be a big and/or utterly implausible, "if". I've
> simply not got enough knowledge to deduce what you have in mind, hence the
> question and the vague guess.
I have an overly Fedora slant to my knowledge on this front, but it should
basically be the same (although potentially more or less complicated) with
other initrd styles.
> I've read incomplete snippets of documentation suggesting that Live CDs
> don't require the booting kernel to be given a root="" parameter at all ...
> and that the technique can be adapted to boot from a specific USB device
> rather than a specific CDROM.
> Does anyone know of some documentation that actually explains the process?
I was thinking it might be worth pulling apart the Knoppix initrd. I've no
idea how they do it.
jh
--
"Come friendly bombs, and fall on Slough!
It isn't fit for humans now,
There isn't grass to graze a cow.
Swarm over, Death." -- Sir John Betjeman
More information about the Wylug-help
mailing list