mrm-initrd Script
#!/bin/sh

# ------------------------------------------------------------
# Create initrd as cpio archive from a directory.
# ------------------------------------------------------------

# variables
[ -z "$BASEDIR" ] && BASEDIR=${HOME}/livecd
[ -z "$INITRDDIR" ] && INITRDDIR=${BASEDIR}/initrd
[ -z "$MASTERDIR" ] && MASTERDIR=${BASEDIR}/master/boot
[ -z "$INITRDNAME" ] && INITRDNAME="initrd.img"

# sanity check
for i in "${BASEDIR}" "${INITRDDIR}" "${MASTERDIR}"; do
  if ! [ -d "$i" ]; then
    echo "ERROR: Directory \"$i\" does not exist."
    exit 1
  fi
done

# clean up
rm -f ${BASEDIR}/${INITRDNAME}
rm -f ${MASTERDIR}/${INITRDNAME}
rm -rf ${INITRDDIR}/lib/modules
mkdir ${INITRDDIR}/lib/modules

# cpio initrd into an archive
echo "Creating initrd..."
find ${INITRDDIR} | cpio -o -H newc | gzip -9 >${BASEDIR}/${INITRDNAME}
chmod 644 ${BASEDIR}/${INITRDNAME}
cp -p ${BASEDIR}/${INITRDNAME} ${MASTERDIR}/
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.