diff --git a/Readme.md b/Readme.md index e247a37..663c011 100644 --- a/Readme.md +++ b/Readme.md @@ -112,7 +112,7 @@ e.g. `root=/dev/mmcblk0p2` for the normal partition on CM4 EMMC. #### Create the boot image The `-p` product argument (pi4,pi400,cm4) tells the script to discard files which are not required by that product. This makes the image smaller and reduces the time taken to calculate the hash of the image file thereby reducing the boot time. ```bash -../tools/make-boot-image -d secure-boot-files -o boot.img -p pi4 +sudo ../tools/make-boot-image -d secure-boot-files -o boot.img -p pi4 ``` #### Sign the boot image diff --git a/tools/make-boot-image b/tools/make-boot-image index d2a5c36..8091e1d 100755 --- a/tools/make-boot-image +++ b/tools/make-boot-image @@ -8,6 +8,7 @@ IMAGE_SIZE=0 MEGABYTE=$((1024 * 1024)) BOOT_MOUNT="" LOOP="" +NAME=$(basename $0) # Define these environment variables to override mkfs options SECTOR_SIZE=${SECTOR_SIZE:-512} @@ -20,7 +21,6 @@ FAT_OVERHEAD=${FAT_OVERHEAD:-64} cleanup() { unmount_image - [ -z "${TMP_DIR}" ] && return if [ -d "${TMP_DIR}" ]; then rm -rf "${TMP_DIR}" fi @@ -56,26 +56,23 @@ createfs() { mountfs() { image="$1" - LOOP=$(udisksctl loop-setup -f "${image}" \ - | grep loop \ - | sed 's/.*\/dev\/loop\([0-9]*\).*/\/dev\/loop\1/') - [ -e "${LOOP}" ] || die "Failed to create loop device" + LOOP=$(losetup -f) + losetup ${LOOP} "${image}" + [ -e "${LOOP}" ] || die "Failed to create loop device ${LOOP}" - BOOT_MOUNT=$(udisksctl mount --options rw -b "${LOOP}" | sed 's/.*Mounted \/dev\/.* at \(.*\)\.$/\1/') + BOOT_MOUNT=$(mktemp -d) + mount "${LOOP}" "${BOOT_MOUNT}" [ -d "${BOOT_MOUNT}" ] || die "Failed to mount bootfs @ ${BOOT_MOUNT}" echo "Mounted ${LOOP} @ ${BOOT_MOUNT}" } unmount_image() { - if [ -d "${BOOT_MOUNT}" ]; then - udisksctl unmount -b "${LOOP}" > /dev/null || true - BOOT_MOUNT="" - fi - if [ -e "${LOOP}" ];then - udisksctl loop-delete -b "${LOOP}" - LOOP="" + image="$1" + if [ -f "${LOOP}" ]; then + umount "${LOOP}" > /dev/null || true fi + losetup -d "${LOOP}" } @@ -85,7 +82,7 @@ createstaging() { board="$3" mkdir -p "${staging}" || die "Failed to create ${staging}" - cp -a "${source_dir}/"* "${staging}" + cp -r "${source_dir}/"* "${staging}" # Remove files for previous hardware version if [ "${board}" = "pi4" ] || [ "${board}" = "pi400" ] || [ "${board}" = "cm4" ]; then @@ -133,15 +130,12 @@ checkDependencies() { if [ ! -f /sbin/mkfs.fat ]; then die "mkfs.fat is requried. Run this script on Linux" fi - - if ! command -v udisksctl; then - die "udisksctl ot found. Try installing the udisks2 package." - fi } usage() { cat <