Nethence Newdoc Olddoc Lab Your IP BBDock  

Warning: those guides are mostly obsolete, please have a look at the new documentation.


Custom rescue/ghost initramfs
Initramfs is just the newer way for Linux to build an initrd. It uses cpio instead of a simple ext2 filesystem image. Here's how to build an LVM2 capable initramfs. Two flavors are described :
- Busybox and Slackware init
- Busybox and Redhat init
Note. the Busybox preparation may be done as user but you'll have to be root to extract the device files from the cpio archive. So might be convenient to stay as root all along.
See on how to prepare a Busybox system.
Busybox and Slackware init
Note. you need to be root to extract the device files from the cpio archive
Make sure you've got XZ ( first. It's available on recent Slackware distros. It's also available as package with Redhat/CentOS,
rpm -q xz
mv -f initrd.img initrd.dist
xz -d lvm2-2.02.64-i486-1.txz
don't forget initrd's relative kernel image, it might help to build the PXE or memstick later on !
Extract a sample initramfs,
rm -rf sample/
mkdir sample/
cd sample/
gzip -dc ../initrd.dist | cpio -id
cd ..
note. "-id" or "--extract --make-directories"
Prepare the rescue initramfs,
rm -rf tmp/
mkdir -p tmp/etc/ tmp/lib/ tmp/_keymap/
cp -a sample/dev/ tmp/
cp -a sample/lib/modules/ tmp/lib/
cp -a sample/etc/group tmp/etc/
cp -a sample/etc/passwd tmp/etc/
tar xzf sample/etc/keymaps.tar.gz -C tmp/_keymap/
sed 's/mknod --mode=600/mknod/' sample/dev/ > tmp/dev/
chmod +x tmp/dev/
Eventually enable PCMCIA,
#mkdir -p tmp/etc/rc.d
#cp -a sample/etc/rc.d/rc.pcmcia tmp/etc/rc.d
Note. for rc.pcmcia to work you also need pcmciautils package
Enable the network connectivity,
cp -a sample/scripts/ tmp/sbin/
chmod +x tmp/sbin/
Make it LVM2 capable,
rm -rf addons/
mkdir addons/
mkdir -p tmp/sbin/
tar xf lvm2-2.02.64-i486-1.tar -C addons/
cp addons/sbin/lvm.static tmp/sbin/lvm
Note. this isn't needed,
#tar xzf device-mapper-1.02.28-i486-1.tgz -C addons
Note. and there's no udev.static binary provided by Slackware.
Create the initialization script,
cd tmp/
cat > init <<EOF9
/bin/rm -f /etc/mtab* /etc/nologin 1> /dev/null 2> /dev/null
mkdir -p /proc /sys
mount -t proc none /proc
mount -t sysfs none /sys
lvm vgscan --mknodes --ignorelockingfailure
lvm vgchange -ay --ignorelockingfailure
#blkid (floppy error)
loadkmap < /_keymap/fr-latin1.bmap
echo "run to enable network cards"
exec /linuxrc
chmod 700 init
cd ..
Note. change the keymap accordingly
Configure linuxrc,
cd tmp/
mkdir -p etc/init.d/
touch etc/init.d/rcS
chmod +x etc/init.d/rcS
cd ..
Tune your environment,
cd tmp/
cat > .profile <<EOF9
alias ll='ls -alkF'
cd ..
Finish up
Generate the initramfs and clean up,
cd tmp/
find . | cpio -co | gzip -9 > ../initrd.img
cd ..
#mkdir -p /tftpboot/rescue32/
#cp bzImage /tftpboot/rescue32/
#cp initrd.img /tftpboot/rescue32/
Busybox and Redhat init
Add udev support and userspace LVM2 tools,
cp /sbin/udevd.static sbin/udevd
cp /sbin/lvm.static sbin/lvm
#cp /sbin/dmsetup.static sbin/dmsetup
#cp /sbin/kpartx.static sbin/kpartx
Note. not using dmsetup, "vgscan --mknodes" does the job
Note. not using "kpartx", udev does the job
Note. the "lvm" binary itself is enought, no need for "/etc/lvm/" conf & subdirs.
Add the missing modules,
tmp=`ls -1t /lib/modules/ | grep xen$ | head -1`
cp -f \
$tmp/kernel/fs/jbd/jbd.ko \
$tmp/kernel/fs/ext3/ext3.ko \
$tmp/kernel/drivers/scsi/scsi_mod.ko \
$tmp/kernel/drivers/scsi/sd_mod.ko \
$tmp/kernel/drivers/md/dm-mod.ko \
$tmp/kernel/drivers/md/dm-log.ko \
$tmp/kernel/drivers/md/dm-mem-cache.ko \
$tmp/kernel/drivers/md/dm-region_hash.ko \
$tmp/kernel/drivers/md/dm-message.ko \
unset tmp
chmod 600 lib/*.ko
Note. to make a XEN guest capable initramfs, add,
#$tmp/kernel/drivers/xen/blkfront/xenblk.ko \
Create the "init" file,
cat > init <<EOF9
mkdir -p /proc /sys /dev/pts /dev/shm /dev/mapper
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
# mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/rtc c 10 135
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
udevd -d
insmod /lib/xenblk.ko
insmod /lib/jbd.ko
insmod /lib/ext3.ko
insmod /lib/scsi_mod.ko
insmod /lib/sd_mod.ko
insmod /lib/dm-mod.ko
insmod /lib/dm-log.ko
insmod /lib/dm-mem-cache.ko
insmod /lib/dm-region_hash.ko
insmod /lib/dm-message.ko
lvm vgscan --mknodes --ignorelockingfailure
#lvm vgchange -ay --ignorelockingfailure
exec /linuxrc
chmod 700 init
Note. "/dev/console" is created by the kernel.
We could also add KSH93 ( into "bin/",
cp ../ksh.2009-05-05.linux.i386 bin/ksh
and install its dependencies (nonsegneg when applicable),
ldd ksh
cp /lib/ lib
cp /lib/i686/nosegneg/ lib
cp /lib/i686/nosegneg/ lib
cp /lib/ lib
Note. "" is provided by the kernel.
Using the nonsegneg (when applicable) libraries should even prevent from disabling TLS,
#echo 'hwcap 0 nosegneg' >> etc/
RHEL/XEN footnotes
Use the bare domU kernel,
cp `ls -1t /boot/vmlinuz-*xen | head -1` vmlinuz
note. the RHEL XEN kernel has both, dom0 and domU support.
and temporarly change the guest configuration,
kernel = "/data/guest1/vmlinuz"
ramdisk = "/data/guest1/initrd.img"
#bootloader = "/usr/bin/pygrub"
A simple way to add the "xenblk" module to the default initrd,
mkinitrd --fstab=/data/guest3/loop/etc/fstab \
--omit-lvm-modules --omit-raid-modules --omit-scsi-modules \
--with=xenblk --with=jbd --with=ext3 \
initrd.img 2.6.18-128.1.10.el5xen
We could also add USB support into the initramfs, adding this to its init,
echo "Loading ehci-hcd.ko module"
insmod /lib/ehci-hcd.ko
echo "Loading ohci-hcd.ko module"
insmod /lib/ohci-hcd.ko
echo "Loading uhci-hcd.ko module"
insmod /lib/uhci-hcd.ko
mount -t usbfs /proc/bus/usb /proc/bus/usb
Without udev, we would have to make the block device nodes. As for XEN tap:aio devices,
mknod /dev/xvda b 202 0
mknod /dev/xvdb b 202 16
mknod /dev/xvdc b 202 32
mknod /dev/xvdd b 202 48
mknod /dev/xvde b 202 64
mknod /dev/xvdf b 202 80
mknod /dev/xvdg b 202 96
mknod /dev/xvdh b 202 112
and make the partition devices nodes with "partprobe" or "kpartx",
kpartx -a /dev/xvda
Busybox :
Info on the 'in memory' filesystems :
Ash (Almquist Shell) Variants :
ttylinux downloads :
Buildroot: making Embedded Linux easy :
BusyBox simplifies embedded Linux systems :
Coreutils - busybox :

(obsolete, see the new doc)