Created
April 20, 2020 22:20
-
-
Save mdhorn/ec48c8cf2b6561e5158ddbfcbdf2363c to your computer and use it in GitHub Desktop.
Script to create CPIO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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