kadischi/livecd_generator livecd-mkinitrd.sh,1.24,1.25
Jasper O'neal Hartline (autopsy)
fedora-extras-commits at redhat.com
Tue Aug 29 03:04:15 UTC 2006
Author: autopsy
Update of /cvs/devel/kadischi/livecd_generator
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14095/kadischi/livecd_generator
Modified Files:
livecd-mkinitrd.sh
Log Message:
Implement hybrid initramfs with nash/busybox rather than Ext2 initrd
Index: livecd-mkinitrd.sh
===================================================================
RCS file: /cvs/devel/kadischi/livecd_generator/livecd-mkinitrd.sh,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- livecd-mkinitrd.sh 24 Aug 2006 07:37:24 -0000 1.24
+++ livecd-mkinitrd.sh 29 Aug 2006 03:04:13 -0000 1.25
@@ -2,26 +2,22 @@
# livecd-mkinitrd.sh
#
-# based on diskless-mkinitrd from readonly-root package
-#
-# diskless-mkinitrd is based heavily on mkinitrd and updateDiskless from system-config-boot
+# based on mkinitrd from Fedora Core 5
# set -x
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
export PATH
-# VERSION=0.6 # diskless-mkinitrd version
+# VERSION=0.1
VERSION=0.1
+# Always compress
compress=1
rootdir=""
imagedir="/boot/isolinux/"
image="initrd.img"
-imagesmp="initrd.smp.img"
kernel=""
-is_up_kernel=""
-is_smp_kernel=""
force=""
verbose=""
basedir=""
@@ -29,10 +25,11 @@
IMAGESIZE=10000
+
. /etc/kadischi/kadischi.conf
usage () {
- echo "usage: `basename $0` [--version] [-v] [-f] [--nocompress]" >&2
+ echo "usage: `basename $0` [--version] [-v]" >&2
echo " <rootdir> <kernel-version>" >&2
echo " (ex: `basename $0` /tmp/system 2.6.11-1.1369_FC4)" >&2
exit 1
@@ -41,7 +38,7 @@
findmodules() {
cd $rootdir/lib/modules/$kernel
for dir in $@; do
- /usr/bin/find kernel/$dir -name *.ko -o -name *.o -o -name *.o.gz
+ /usr/bin/find kernel/$dir -name *.ko -o -name *.o -o -name *.o.gz
done
}
@@ -49,21 +46,21 @@
if [ "$#" != "1" ];then
echo "usage: instmodule <module>"
return
- fi
+ fi
src=$rootdir/lib/modules/$kernel/$1
dest=$MNTIMAGE/lib/modules/$kernel/$1
dir=$(dirname $dest)
if [ ! -d $dir ]; then
- /bin/mkdir -p $dir
+ /bin/mkdir -p $dir
fi
if [ -x /usr/bin/strip ]; then
- /usr/bin/strip -g $verbose $src -o $dest
+ /usr/bin/strip -g $verbose $src -o $dest
else
- [ -n "$verbose" ] && echo "$src -> $dest"
- cp -a $src $dest
+ [ -n "$verbose" ] && echo "$src -> $dest"
+ cp -a $src $dest
fi
}
@@ -71,98 +68,42 @@
if [ "$#" != "2" ];then
echo "usage: inst <file> <destination>"
return
- fi
+ fi
[ -n "$verbose" ] && echo "$1 -> $2"
cp $1 $2
}
while [ $# -gt 0 ]; do
case $1 in
- --version)
- echo "mkinitrd: version $VERSION"
- exit 0
- ;;
-
- -v)
- verbose=-v
- ;;
-
- --nocompress)
- compress=""
- ;;
-
- --force)
- force=1
- ;;
-
-# --image-version)
-# img_vers=yes
-# ;;
-#
-# --live-cd)
-# live_cd=yes
-# ;;
-
- *)
- if [ -z "$rootdir" ]; then
- rootdir=$1
- elif [ -z "$kernel" ]; then
- kernel=$1
- else
- usage
- fi
- ;;
+ --version)
+ echo "mkinitrd: version $VERSION"
+ exit 0
+ ;;
+
+ -v)
+ verbose=-v
+ ;;
+ *)
+ if [ -z "$rootdir" ]; then
+ rootdir=$1
+ elif [ -z "$kernel" ]; then
+ kernel=$1
+ else
+ usage
+ fi
+ ;;
esac
shift
done
-is_smp_kernel() {
- echo "$kernel" | /bin/grep smp >/dev/null 2>&1
- if [ "$?" -eq "0" ]; then
- is_smp_kernel="yes"
- elif [ "$?" -ne "0" ]; then
- is_smp_kernel="no"
- fi
-}
-
-is_up_kernel() {
- echo "$kernel" | /bin/grep -v smp >/dev/null 2>&1
- if [ "$?" -eq "0" ]; then
- is_up_kernel="yes"
- elif [ "$?" -ne "0" ]; then
- is_up_kernel="no"
- fi
-}
-
-is_smp_kernel
-is_up_kernel
-
-if [ "$is_smp_kernel" == "yes" ] && [ "$is_up_kernel" == "no" ]; then
- image="initrd.smp.img"
-else
- if [ "$is_smp_kernel" == "no" ] && [ "$is_up_kernel" == "yes" ]; then
- image="initrd.img"
- fi
-fi
-
if [ -z "$rootdir" -o -z "$kernel" ]; then
usage
fi
-#if [ -n "$img_vers" ]; then
-# target="$target-$kernel"
-#fi
-
-if [ -z "$force" -a -f $rootdir/$imagedir/$image ] && [ "$is_smp_kernel" == "yes" ]; then
- echo "$rootdir/$imagedir/$image already exists. Must be 2 kernels.. continuing" >&2
-elif [ -z "$force" -a -f $rootdir/$imagedir/$image ] && [ "$is_smp_kernel" == "no" ]; then
- echo "$rootdir/$imagedir/$image already exists." >&2
- exit 1
-elif [ -z "$force" -a -f $rootdir/$imagedir/$image ] && [ -z "$force" -a -f $rootdir/$imagedir/$imagesmp ]; then
- echo "$rootdir/$imagedir/$image and $imagesmp already exists." >&2
- exit 1
-fi
+
+
+
if [ ! -d $rootdir/$imagedir ]; then
/bin/mkdir $rootdir/$imagedir
@@ -182,6 +123,7 @@
exit 1
fi
+
# find a temporary directory which doesn't use tmpfs
TMPDIR="$rootdir/.." # ************************************************
@@ -195,6 +137,7 @@
MNTPOINT=`/bin/mktemp -d ${TMPDIR}/initrd.mnt.XXXXXX`
RCFILE=$MNTIMAGE/linuxrc
+
if [ -z "$MNTIMAGE" -o -z "$IMAGE" -o -z "$MNTPOINT" ]; then
echo "Error creating temporaries. Try again" >&2
exit 1
@@ -209,6 +152,8 @@
/bin/mknod /dev/loop$i b 7 $i
fi
done
+
+
echo $kernel | grep FC5 >/dev/null
if [ "$?" -eq "0" ]; then
/bin/dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGESIZE 2> /dev/null || exit 1
@@ -226,6 +171,7 @@
/sbin/losetup ${LODEV} $IMAGE || exit 1
+
# We have to "echo y |" so that it doesn't complain about $IMAGE not
# being a block device
# We also use -b 4096 to rectify issue: BZ #202715
@@ -235,6 +181,8 @@
else
echo y | /sbin/mke2fs -b 4096 $LODEV $IMAGESIZE >/dev/null 2>/dev/null
fi
+
+
/sbin/tune2fs -i0 $LODEV >/dev/null
if [ -n "$verbose" ]; then
@@ -243,8 +191,8 @@
/bin/mkdir -p $MNTPOINT
/bin/mount -t ext2 $LODEV $MNTPOINT || {
- echo "Can't get a loopback device"
- exit 1
+ echo "Can't get a loopback device"
+ exit 1
}
/bin/mkdir -p $MNTIMAGE/lib
@@ -253,6 +201,7 @@
/bin/mkdir -p $MNTIMAGE/bin
/bin/mkdir -p $MNTIMAGE/etc
/bin/mkdir -p $MNTIMAGE/etc/modprobe.d
+/bin/mkdir -p $MNTIMAGE/etc/makedev.d
/bin/mkdir -p $MNTIMAGE/dev
/bin/mkdir -p $MNTIMAGE/proc
/bin/mkdir -p $MNTIMAGE/sys
@@ -262,10 +211,12 @@
/bin/mkdir -p $MNTIMAGE/usr/lib
/bin/mkdir -p $MNTIMAGE/var/lib/nfs/rpc_pipefs
/bin/mkdir -p $MNTIMAGE/mnt/source
+/bin/mkdir -p $MNTIMAGE/dev/mapper
/bin/ln -s bin $MNTIMAGE/sbin
# We don't need this directory, so let's save space
# /bin/rm -rf $MNTPOINT/lost+found
+cp $rootdir/etc/makedev.d/* $MNTIMAGE/etc/makedev.d
inst $rootdir/lib/ld-linux.so.2 "$MNTIMAGE/lib/ld-linux.so.2"
inst $rootdir/lib/libselinux.so.1 "$MNTIMAGE/lib/libselinux.so.1"
@@ -275,7 +226,7 @@
if [ -f $rootdir/lib/tls/libc.so.6 ]; then
inst $rootdir/lib/tls/libc.so.6 "$MNTIMAGE/lib/libc.so.6"
else
- inst $rootdir/lib/libc.so.6 "$MNTIMAGE/lib/libc.so.6"
+ inst $rootdir/lib/libc.so.6 "$MNTIMAGE/lib/libc.so.6"
fi
if [ -f $rootdir/lib/tls/libm.so.6 ]; then
@@ -289,10 +240,10 @@
inst $rootdir/lib/libcrypt.so.1 "$MNTIMAGE/lib/libcrypt.so.1"
fi
+# Install NASH
+inst /sbin/nash "$MNTIMAGE/bin/nash"
+# Install busybox
inst /sbin/busybox.anaconda "$MNTIMAGE/bin/busybox"
-for i in [ ash awk cat cut echo grep ifconfig ls lsmod mount pivot_root rmmod route sh sort umount sleep halt reboot rm clear; do
- /bin/ln -s busybox "$MNTIMAGE/bin/$i"
-done
inst $LIBEXECDIR/kadischi/find-live-cd "$MNTIMAGE/bin/find-live-cd"
inst $LIBEXECDIR/kadischi/eject-live-cd "$MNTIMAGE/bin/eject-live-cd"
@@ -315,17 +266,19 @@
fi
inst $rootdir/lib/modules/$kernel/modules.dep "$MNTIMAGE/lib/modules/$kernel/modules.dep"
-MODULES=$(findmodules drivers/parport drivers/block/loop.ko fs/squashfs drivers/cdrom/cdrom.ko drivers/ide/ide-cd.ko)
+MODULES=$(findmodules drivers/parport drivers/block/loop.ko fs/jbd/jbd.ko fs/ext3/ext3.ko fs/squashfs drivers/cdrom/cdrom.ko drivers/ide/ide-cd.ko drivers/md/dm-mirror.ko drivers/md/dm-zero.ko drivers/md/dm-mod.ko drivers/md/dm-snapshot.ko)
for MODULE in $MODULES; do
instmodule $MODULE
done
-# mknod'ing the devices instead of copying them works both with and
-# without devfs...
+
/bin/mknod $MNTIMAGE/dev/console c 5 1
/bin/mknod $MNTIMAGE/dev/null c 1 3
/bin/mknod $MNTIMAGE/dev/ram b 1 1
/bin/mknod $MNTIMAGE/dev/systty c 4 0
+/bin/mknod $MNTIMAGE/dev/zero c 1 5
+/bin/mknod $MNTIMAGE/dev/ptmx c 5 2
+/bin/mknod $MNTIMAGE/dev/initctl p
for i in 1 2 3 4; do
/bin/mknod $MNTIMAGE/dev/tty$i c 4 $i
done
@@ -335,25 +288,14 @@
inst $INSTALLDIR/initrd/livecd-linuxrc "$MNTIMAGE/linuxrc"
-(cd $MNTIMAGE; /bin/tar cf - .) | (cd $MNTPOINT; /bin/tar xf -) || exit 1
-
-/bin/umount $MNTPOINT
-/sbin/losetup -d $LODEV
-
+(cd $MNTIMAGE; ln -s linuxrc init)
+(cd $MNTIMAGE; find . | sed -e 's|./||' >files.list && cpio -c -o <files.list >initrd.cpio)
if [ "$compress" == "1" ]; then
- if [ "$is_smp_kernel" == "yes" ]; then
- /bin/gzip -9 < $IMAGE > $rootdir/$imagedir/initrd.smp.img || rc=1
- elif [ "$is_up_kernel" == "yes" ]; then
- /bin/gzip -9 < $IMAGE > $rootdir/$imagedir/$image || rc=1
- fi
-else
- if [ "$is_smp_kernel" == "yes" ]; then
- /bin/cp -a $IMAGE $rootdir/$imagedir/initrd.smp.img || rc=1
- elif [ "$is_up_kernel" == "yes" ]; then
- /bin/cp -a $IMAGE $rootdir/$imagedir/$image || rc=1
- fi
+ (cd $MNTIMAGE; /bin/gzip -9 < initrd.cpio > $rootdir/$imagedir/initrd.img || rc=1)
fi
+/bin/umount $MNTPOINT
+/sbin/losetup -d $LODEV
/bin/rm -rf $MNTIMAGE $MNTPOINT $IMAGE
echo "[kadischi]: $kernel initrd made successfully!"
More information about the fedora-extras-commits
mailing list