Skip to content

Instantly share code, notes, and snippets.

@mdhorn
Created April 20, 2020 22:20
Show Gist options
  • Save mdhorn/ec48c8cf2b6561e5158ddbfcbdf2363c to your computer and use it in GitHub Desktop.
Save mdhorn/ec48c8cf2b6561e5158ddbfcbdf2363c to your computer and use it in GitHub Desktop.
Script to create CPIO
#!/bin/bash
CWD="$(pwd)"
ROOT="${CWD}/initramfs"
if [ -d "${ROOT}" ]
then
echo "Directory exist: ${ROOT}"
read -p "Remove ${ROOT}? [Y/N] N: " answer
if [ "${answer}" == "Y" ]
then
sudo rm -rf "${ROOT}"
else
echo "Not removing ${ROOT} ... "
fi
fi
mkdir -p "${ROOT}/etc"
CONF="${ROOT}/etc/mdadm.conf"
echo "DEVICE partitions" >> "${CONF}"
sudo mdadm --detail --scan /dev/md127 | tee -a "${CONF}" 1>/dev/null
sudo chown -R root.root "${ROOT}"
CPIO="${CWD}/freestanding-clr-mdadm.cpio"
cd "${ROOT}"
echo "Creating ${CPIO} ..."
find . -print0 | cpio -o --null --format=newc > "${CPIO}" 2>/dev/null
echo "Compressing ${CPIO} ..."
gzip -9 -f "${CPIO}" 1>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment