mrm-squash Script
#!/bin/sh

# ------------------------------------------------------------
# Create squashed filesystem.
# ------------------------------------------------------------

# variables
[ -z "$BASEDIR" ] && BASEDIR=/mnt/hda1/livecd
[ -z "$MASTER" ] && MASTER=${BASEDIR}/master
[ -z "$SOURCE" ] && SOURCE=${BASEDIR}/source

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

# check for required binaries
REQ_BINS=""
which mksquashfs >/dev/null 2>&1 || REQ_BINS="mksquashfs,${REQ_BINS}"
if [ -n "${REQ_BINS}" ]; then
  echo -e "ERROR: Required binaries (${REQ_BINS}\010) are not present."
  exit 1
fi

# check for mounted proc & sys
if [ -f ${SOURCE}/proc/uptime ]; then
  echo "ERROR: Source's /proc must be unmounted."
  exit 1
fi
if [ -d ${SOURCE}/sys/devices ]; then
  echo "ERROR: Source's /sys must be unmounted."
  exit 1
fi

# create the squashfs filesystem
rm -f ${MASTER}/SQUASHED
time mksquashfs ${SOURCE} ${MASTER}/SQUASHED
chmod 0644 ${MASTER}/SQUASHED
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.