On Monday 17 January 2005 11:28 am, Travis Osterman <[EMAIL PROTECTED]> 
wrote:
> > I see at least two options:
> >
> > 1. Running a tiny Rescue-Gentoo on another partition formatted with a
> > less sensitive FS.
> >
> > 2. Use initrd
>
> Since all I need is jfs and lvm support; jfs_fsck, vgscan, and
> vgchange commands; and a prompt, I was hoping to do it with something
> like initrd ... or even just dropping me into my /boot directory where
> I could copy my utils would be fine.

It's (fairly) easy to set up an initrd.

As you may already know, an initrd is simply a (optionally compressed) file 
that is loaded into memory and mounted as root.  Here's how to make one:

# Make the initrd, here we make an 8MB file of all 0s:
# Use any file name you want.
dd if=/dev/zero of=/boot/initrd-lvm2_jfs bs=512 count=16384

# Format the initrd; to mount it we will need a filesystem
# Here we use ext2, for widest support.  Also, we don't need or
# want journaling overhead.
# You can use any options you want, as long as your kernel can
# mount the filesystem with no modules loaded.
mke2fs -F /boot/initrd-lvm2_jfs

Okay, now that gives something that is theoretically an initrd.  
Unfortunately, using it as an initrd will not be helpful since it doesn't 
get our system to the point where /sbin/init can be run.

In order to make our initrd functional, we'll need to put some files on the 
filesystem.  Do do that, we'll need to mount it.  You'll also repeat this 
step if you need to modify the initrd because you made a mistake or your 
system has changed.

# Make the mount point, if it doesn't exist (you can use any mount point)
mkdir /boot/initrd

# Mount the file using loopback (must have kernel support).
mount -o loop /boot/initrd-lvm2_jfs /boot/initrd

Okay, now you'll have to fill it with files.  After the kernel mounts the 
initrd (on /), it will execute the file /linuxrc.  You'll fill this file 
with any commands you want to run before init starts.  Be sure to move the 
commands over to the new initrd as well as any libraries they may require.  
You'll need to install a shell, too.  My initrds use nash, but there are 
others that should work fine.

You can determine what libraries a command will need using ldd.

You'll probably also need to make a few device nodes in your initrd.  
Neither devfs or udev will actually be running, yet, IIRC.  I can't 
remember if you have to have /proc or not; I know my initrd doesn't 
explicitly mount it, but does explicitly unmount it, after pivot_root

Once you get done throwing files onto your initrd.  You'll need to unmount 
it and modify /boot/grub/grub.conf or /etc/lilo.conf.  If using lilo, 
you'll wnat to do the lilo update thingy (I use grub, can you tell?).

Once you get the uncompressed initrd working, which will probably take a 
few tries, you can use gzip compress it and the kernel should 
transparently uncompress it as part of mounting it.  This may or may not 
speed the amount of time it takes to boot.  You won't have to mess with 
any boot options as long as your initrd keeps the same name.

# Compressing the initrd.
gzip /boot/initrd-lvm2_jfs

# Renaming the compressed file.
mv /boot/initrd-lvm2_jfs.gz /boot/initrd-lvm2_jfs

Of course, you need not generate an initrd completely from scratch.  There 
are quite a few scripts out there that will do most of the job for you.  
The gentoo way is genkernel, but it doesn't actually support / on LVM last 
time I checked and it's startup proceedure (linuxrc) is a bit complex (so, 
it's harder to modify).  I simply used mkinitrd by Erik Troan 
<[EMAIL PROTECTED]>, but qpkg (and I) don't know where I got it.  Again, it 
doesn't support / on LVM out of the box, so I had to modify it which is 
how I got to learn about initrds. :)

-- 
Boyd Stephen Smith Jr.
[EMAIL PROTECTED]
ICQ: 514984 YM/AIM: DaTwinkDaddy

--
gentoo-user@gentoo.org mailing list

Reply via email to