<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=6106&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / [SOLVED] cryptroot-unlock in dropbear aborts with "Try again later"]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=6106</link>
		<description><![CDATA[The most recent posts in [SOLVED] cryptroot-unlock in dropbear aborts with "Try again later".]]></description>
		<lastBuildDate>Sat, 09 Dec 2023 15:14:02 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: [SOLVED] cryptroot-unlock in dropbear aborts with "Try again later"]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=46075#p46075</link>
			<description><![CDATA[<p>Just noticed this is a duplicate of <a href="https://dev1galaxy.org/viewtopic.php?id=3642" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=3642</a>, sorry!</p>]]></description>
			<author><![CDATA[dummy@example.com (unixdan22)]]></author>
			<pubDate>Sat, 09 Dec 2023 15:14:02 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=46075#p46075</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] cryptroot-unlock in dropbear aborts with "Try again later"]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=45447#p45447</link>
			<description><![CDATA[<p>Thank you for finding a workaround.</p><p>I wonder if using a script from the sysv era would fix it. The fact that is working on Debian but not on Devuan let me think only one thing: <strong>systemd</strong>... 🤦</p>]]></description>
			<author><![CDATA[dummy@example.com (Danielsan)]]></author>
			<pubDate>Thu, 16 Nov 2023 23:23:30 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=45447#p45447</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] cryptroot-unlock in dropbear aborts with "Try again later"]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=45146#p45146</link>
			<description><![CDATA[<p>Hello,</p><p>I use a Raspberry Pi with a LUKS-encrypted Devuan root partition. I installed dropbear in initramfs to be able to unlock the root partition at boot time remotely without having to attach a keyboard.</p><p>Dropbear works fine, I can access it from another machine remotely via SSH. It is showing this prompt:</p><div class="codebox"><pre><code>To unlock root partition, and maybe others like swap, run `cryptroot-unlock`.

BusyBox v1.35.0 (Debian 1:1.35.0-4+b3) built-in shell (ash)
Enter &#039;help&#039; for a list of built-in commands.

~ #</code></pre></div><p>The problem is, if I type <span class="bbc">cryptroot-unlock</span>, I get this error message:</p><div class="codebox"><pre><code>Try again later</code></pre></div><p>Here is the content of the script <span class="bbc">/usr/bin/cryptroot-unlock</span>:</p><div class="codebox"><pre class="vscroll"><code>#!/bin/busybox ash

# Remotely unlock encrypted volumes.
#
# Copyright © 2015-2018 Guilhem Moulin &lt;guilhem@debian.org&gt;
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.

set -ue
PATH=/sbin:/bin

TIMEOUT=10
PASSFIFO=/lib/cryptsetup/passfifo
ASKPASS=/lib/cryptsetup/askpass
UNLOCK_ALL=n

[ -f /lib/cryptsetup/functions ] || return 0
. /lib/cryptsetup/functions
TABFILE=&quot;/cryptroot/crypttab&quot;
unset -v IFS

if [ ! -f &quot;$TABFILE&quot; ] || [ &quot;$TABFILE&quot; -ot &quot;/proc/1&quot; ]; then
	# Too early, init-top/cryptroot hasn&#039;t finished yet
	echo &quot;Try again later&quot; &gt;&amp;2
	exit 1
fi

# Print the list of PIDs the executed command of which is $exe.
pgrep_exe() {
	local exe pid
	exe=&quot;$(readlink -f -- &quot;$1&quot; 2&gt;/dev/null)&quot; &amp;&amp; [ -f &quot;$exe&quot; ] || return 0
	ps -eo pid= | while read pid; do
		[ &quot;$(readlink -f &quot;/proc/$pid/exe&quot;)&quot; != &quot;$exe&quot; ] || printf &#039;%d\n&#039; &quot;$pid&quot;
	done
}

# Return 0 if $pid has a file descriptor pointing to $name, and 1
# otherwise.
in_fds() {
	local pid=&quot;$1&quot; name fd
	name=&quot;$(readlink -f -- &quot;$2&quot; 2&gt;/dev/null)&quot; &amp;&amp; [ -e &quot;$name&quot; ] || return 1
	for fd in $(find &quot;/proc/$pid/fd&quot; -type l); do
		[ &quot;$(readlink -f &quot;$fd&quot;)&quot; != &quot;$name&quot; ] || return 0
	done
	return 1
}

# Print the PID of the askpass process with a file descriptor opened to
# /lib/cryptsetup/passfifo.
get_askpass_pid() {
	local pid
	for pid in $(pgrep_exe &quot;$ASKPASS&quot;); do
		if in_fds &quot;$pid&quot; &quot;$PASSFIFO&quot;; then
			echo &quot;$pid&quot;
			return 0
		fi
	done
	return 1
}

# Print the number of configured crypt devices that have not been unlocked yet.
count_locked_devices() {
	local COUNT=0
	crypttab_foreach_entry count_locked_devices_callback
	printf &#039;%d\n&#039; &quot;$COUNT&quot;
}
count_locked_devices_callback() {
	dm_blkdevname &quot;$CRYPTTAB_NAME&quot; &gt;/dev/null || COUNT=$(( $COUNT + 1 ))
}

# Wait for askpass, then set $PID (resp. $BIRTH) to the PID (resp.
# birth date) of the cryptsetup process with same $CRYPTTAB_NAME.
wait_for_prompt() {
	local pid timer num_locked_devices=-1 n

	# wait for the fifo
	while :; do
		n=$(count_locked_devices)
		if [ $n -eq 0 ]; then
			# all configured devices have been unlocked, we&#039;re done
			exit 0
		elif [ $num_locked_devices -lt 0 ] || [ $n -lt $num_locked_devices ]; then
			# reset $timer if a device was unlocked (for instance using
			# a keyscript) while we were waiting
			timer=$(( 10 * $TIMEOUT ))
		fi
		num_locked_devices=$n

		if pid=$(get_askpass_pid) &amp;&amp; [ -p &quot;$PASSFIFO&quot; ]; then
			break
		fi

		usleep 100000
		timer=$(( $timer - 1 ))
		if [ $timer -le 0 ]; then
			echo &quot;Error: Timeout reached while waiting for askpass.&quot; &gt;&amp;2
			exit 1
		fi
	done

	# find the cryptsetup process with same $CRYPTTAB_NAME
	local o v
	for o in NAME TRIED OPTION_tries; do
		if v=&quot;$(grep -z -m1 &quot;^CRYPTTAB_$o=&quot; &quot;/proc/$pid/environ&quot;)&quot;; then
			eval &quot;CRYPTTAB_$o&quot;=&quot;\${v#CRYPTTAB_$o=}&quot;
		else
			eval unset -v &quot;CRYPTTAB_$o&quot;
		fi
	done
	if [ -z &quot;${CRYPTTAB_NAME:+x}&quot; ] || [ -z &quot;${CRYPTTAB_TRIED:+x}&quot; ]; then
		return 1
	fi
	if ( ! crypttab_find_entry --quiet &quot;$CRYPTTAB_NAME&quot; ); then
		# use a subshell to avoid polluting our enironment
		echo &quot;Error: Refusing to process unknown device $CRYPTTAB_NAME&quot; &gt;&amp;2
		exit 1
	fi

	for pid in $(pgrep_exe &quot;/sbin/cryptsetup&quot;); do
		if grep -Fxqz &quot;CRYPTTAB_NAME=$CRYPTTAB_NAME&quot; &quot;/proc/$pid/environ&quot;; then
			PID=$pid
			BIRTH=$(stat -c&quot;%Z&quot; &quot;/proc/$PID&quot; 2&gt;/dev/null) || break
			return 0
		fi
	done

	PID=
	BIRTH=
	return 1
}

# Wait until $PID no longer exists or has a birth date greater that
# $BIRTH (ie was reallocated).  Then return with exit value 0 if
# /dev/mapper/$CRYPTTAB_NAME exists, and with exit value 1 if the
# maximum number of tries exceeded.  Otherwise (if the unlocking
# failed), return with value 1.
wait_for_answer() {
	local timer=$(( 10 * $TIMEOUT )) b
	while [ -d &quot;/proc/$PID&quot; ] &amp;&amp; b=$(stat -c&quot;%Z&quot; &quot;/proc/$PID&quot; 2&gt;/dev/null) &amp;&amp; [ $b -le $BIRTH ]; do
		usleep 100000
		timer=$(( $timer - 1 ))
		if [ $timer -le 0 ]; then
			echo &quot;Error: Timeout reached while waiting for PID $PID.&quot; &gt;&amp;2
			exit 1
		fi
	done

	if dm_blkdevname &quot;$CRYPTTAB_NAME&quot; &gt;/dev/null; then
		echo &quot;cryptsetup: $CRYPTTAB_NAME set up successfully&quot; &gt;&amp;2
		[ &quot;$UNLOCK_ALL&quot; = y ] &amp;&amp; return 0 || exit 0
	elif [ $(( ${CRYPTTAB_TRIED:-0} + 1 )) -ge ${CRYPTTAB_OPTION_tries:-3} ] &amp;&amp;
			[ ${CRYPTTAB_OPTION_tries:-3} -gt 0 ]; then
		echo &quot;cryptsetup: maximum number of tries exceeded for $CRYPTTAB_NAME&quot; &gt;&amp;2
		exit 1
	else
		echo &quot;cryptsetup: cryptsetup failed, bad password or options?&quot; &gt;&amp;2
		return 1
	fi
}

if [ -t 0 ] &amp;&amp; [ -x &quot;$ASKPASS&quot; ]; then
	# interactive mode on a TTY: keep trying until all configured devices have
	# been unlocked or the maximum number of tries exceeded
	UNLOCK_ALL=y
	while :; do
		# note: if the script is not killed before pivot_root it should
		# exit on its own once $TIMEOUT is reached
		if ! wait_for_prompt; then
			usleep 100000
			continue
		fi
		read -rs -p &quot;Please unlock disk $CRYPTTAB_NAME: &quot;; echo
		printf &#039;%s&#039; &quot;$REPLY&quot; &gt;&quot;$PASSFIFO&quot;
		wait_for_answer || true
	done
else
	# non-interactive mode: slurp the passphrase from stdin and exit
	wait_for_prompt || exit 1
	echo &quot;Please unlock disk $CRYPTTAB_NAME&quot;
	cat &gt;&quot;$PASSFIFO&quot;
	wait_for_answer || exit 1
fi

# vim: set filetype=sh :</code></pre></div><p>I figured out, that in the following part the script fails because the timestamp of <span class="bbc">/cryptroot/crypttab</span> is older than <span class="bbc">/proc/1</span>:</p><div class="codebox"><pre><code>if [ ! -f &quot;$TABFILE&quot; ] || [ &quot;$TABFILE&quot; -ot &quot;/proc/1&quot; ]; then
	# Too early, init-top/cryptroot hasn&#039;t finished yet
	echo &quot;Try again later&quot; &gt;&amp;2
	exit 1
fi</code></pre></div><p>There is no file <span class="bbc">/scripts/init-top/cryptroot</span>.</p><p>If I manually <span class="bbc">touch /cryptroot/crypttab</span>, <span class="bbc">cryptroot-unlock</span> works fine and prompts:</p><div class="codebox"><pre><code>Please unlock disk pi_lvm_crypt:</code></pre></div><p>If I enter the LUKS password, the main system boots up normally.</p><p>How can I configure the system, so that <span class="bbc">cryptroot-unlock</span> works directly?</p><p>Thank you in advance!</p><p>P.S.: I wrote this script <span class="bbc">encrypt-disk-image.sh</span> to create an encrypted disk image from an image from <a href="https://arm-files.devuan.org/" rel="nofollow">https://arm-files.devuan.org/</a>:</p><div class="codebox"><pre class="vscroll"><code>#!/bin/bash

set -e

LUKS_NAME=pi_lvm_crypt
VG_NAME=pivg00
LV_NAME=rootfs
ROOTFS_MOUNTPOINT=&quot;/mount/newcrypt&quot;
BOOT_MOUNTPOINT=&quot;${ROOTFS_MOUNTPOINT}/boot/broadcom&quot;

LOOP_DEV_PLAIN=/dev/loop20
LOOP_DEV_ENC=/dev/loop21

cleanup () {
  trap - INT ERR TERM HUP
  echo &quot;Cleaning up...&quot;
  set +e
  umount -f -- &quot;$BOOT_MOUNTPOINT&quot; \
  &quot;${ROOTFS_MOUNTPOINT}/dev/&quot; \
  &quot;${ROOTFS_MOUNTPOINT}/sys/&quot; \
  &quot;${ROOTFS_MOUNTPOINT}/proc/&quot; \
  &quot;${ROOTFS_MOUNTPOINT}&quot;
  rm -rf -- &quot;$BOOT_MOUNTPOINT&quot; &quot;$ROOTFS_MOUNTPOINT&quot;
  vgchange -a n -- &quot;$VG_NAME&quot;
  cryptsetup luksClose -- &quot;$LUKS_NAME&quot;
  losetup -D
  echo &quot;Done.&quot;
}

exitfn () {
  cleanup
  exit 1
}

# ERR trap only works in bash
trap exitfn INT ERR TERM HUP

if [ &quot;$#&quot; -lt 2 ]; then
  echo &quot;Usage: $0 SOURCE_PLAIN_IMAGE_OR_DEVICE TARGET_CIPHER_IMAGE_OR_DEVICE [DROPBEAR_PUBLIC_KEY_FILE]&quot; &gt;&amp;2
  exit 1
fi

SOURCE_PLAIN_IMAGE_OR_DEVICE=&quot;$1&quot;
TARGET_CIPHER_IMAGE_OR_DEVICE=&quot;$2&quot;
DROPBEAR_PUBLIC_KEY_FILE=&quot;$3&quot;

# If image files are given as arguments, these files are set up as virtual block devices

if [ -b &quot;$SOURCE_PLAIN_IMAGE_OR_DEVICE&quot; ] ; then
  echo &quot;Source is a device, continuing.&quot;
  PLAIN_DEV=&quot;$SOURCE_PLAIN_IMAGE_OR_DEVICE&quot;
else
  echo &quot;Setting up plain image as virtual block device...&quot;
  PLAIN_DEV=&quot;$LOOP_DEV_PLAIN&quot;
  losetup -Pr --direct-io=on -- &quot;$PLAIN_DEV&quot; &quot;$SOURCE_PLAIN_IMAGE_OR_DEVICE&quot;
  echo &quot;Done.&quot;
fi

PART_SIZES=&quot;$(/sbin/sfdisk -lo Sectors -- &quot;$PLAIN_DEV&quot; | awk &#039;/^Sectors$/{flag=1;next}{$1=$1};flag&#039;)&quot;

if [ &quot;$(echo &quot;${PART_SIZES}&quot; | wc -l)&quot; -ne 2 ] ; then
  echo &quot;Expected 2 partitions (boot and rootfs) on the source device&quot; &gt;&amp;2
  exit 10
fi

BOOT_SIZE=&quot;$(echo &quot;${PART_SIZES}&quot; | head -1)&quot;
ROOTFS_SIZE=&quot;$(echo &quot;${PART_SIZES}&quot; | tail -1)&quot;

echo &quot;Boot size (sectors): ${BOOT_SIZE}&quot;
echo &quot;Rootfs size (sectors): ${ROOTFS_SIZE}&quot;

# LUKS header has a size of up to 32MiB
# LVM overhead should be 2MiB
# =&gt; Reserving 64 MiB for any headers
# 64M / 512 = 131072
RESERVE=131072

SECTOR_SIZE=512

BOOT_START=8192
BOOT_END=&quot;$((BOOT_START + BOOT_SIZE - 1))&quot;

LUKS_START=&quot;$((BOOT_START + BOOT_SIZE))&quot;
LUKS_START=&quot;$((LUKS_START + LUKS_SECTOR_SIZE - LUKS_START % 8))&quot;
LUKS_SIZE=&quot;$((ROOTFS_SIZE + RESERVE))&quot;
LUKS_SIZE=&quot;$((LUKS_SIZE + LUKS_SECTOR_SIZE - LUKS_SIZE % 8))&quot;
LUKS_END=&quot;$((LUKS_START + LUKS_SIZE))&quot;

if [ -b &quot;$TARGET_CIPHER_IMAGE_OR_DEVICE&quot; ] ; then
  echo &quot;Target is a device, continuing.&quot;
  ENC_DEV=&quot;$TARGET_CIPHER_IMAGE_OR_DEVICE&quot;
else
  echo &quot;Fallocating target image and setting it up as virtual block device...&quot;
  ENC_DEV=&quot;$LOOP_DEV_ENC&quot;
  ENC_IMG_SIZE=&quot;$((SECTOR_SIZE * (BOOT_START + BOOT_SIZE + LUKS_SIZE)))&quot;
  fallocate -l &quot;$ENC_IMG_SIZE&quot; -- &quot;$TARGET_CIPHER_IMAGE_OR_DEVICE&quot;
  losetup -P --direct-io=on -- &quot;$ENC_DEV&quot; &quot;$TARGET_CIPHER_IMAGE_OR_DEVICE&quot;
  echo &quot;Done.&quot;
fi

echo &quot;Creating MBR partition table on new image...&quot;
sfdisk -- &quot;${ENC_DEV}&quot; &lt;&lt;EOF
label: dos
${BOOT_START} ${BOOT_SIZE} b *
${LUKS_START} ${LUKS_SIZE} R -
EOF
echo &quot;Done.&quot;

PLAIN_PARTS=&quot;$(lsblk -lo NAME -- &quot;${PLAIN_DEV}&quot; | tail -2)&quot;
if [ &quot;$(echo &quot;${PLAIN_PARTS}&quot; | wc -l)&quot; -ne 2 ] ; then
  echo &quot;Expected 2 partitions (boot and rootfs) on the source device&quot; &gt;&amp;2
  exit 10
fi
PLAIN_BOOT=&quot;/dev/$(echo &quot;${PLAIN_PARTS}&quot; | head -1)&quot;
PLAIN_ROOTFS=&quot;/dev/$(echo &quot;${PLAIN_PARTS}&quot; | tail -1)&quot;

ENC_PARTS=&quot;$(lsblk -lo NAME -- &quot;${ENC_DEV}&quot; | tail -2)&quot;
if [ &quot;$(echo &quot;${ENC_PARTS}&quot; | wc -l)&quot; -ne 2 ] ; then
  echo &quot;Expected 2 partitions (boot and rootfs) on the target device after partitioning&quot; &gt;&amp;2
  exit 10
fi
ENC_BOOT=&quot;/dev/$(echo &quot;${ENC_PARTS}&quot; | head -1)&quot;
ENC_ROOTFS=&quot;/dev/$(echo &quot;${ENC_PARTS}&quot; | tail -1)&quot;

echo &quot;Copying boot partition...&quot;
dd if=&quot;$PLAIN_BOOT&quot; of=&quot;$ENC_BOOT&quot; bs=4K conv=fsync status=progress
echo &quot;Done.&quot;

echo &quot;Creating LUKS partition...&quot;
cryptsetup -y -v --type luks2 luksFormat \
--sector-size 4096 \
--cipher xchacha20,aes-adiantum-plain64 \
--hash sha256 --key-size 256 \
-- &quot;$ENC_ROOTFS&quot;
echo &quot;Done.&quot;

echo &quot;Opening encrypted partition...&quot;
cryptsetup luksOpen -- &quot;$ENC_ROOTFS&quot; &quot;$LUKS_NAME&quot;
echo &quot;Done.&quot;

echo &quot;Creating LVM physical volume on LUKS partition...&quot;
pvcreate -- &quot;/dev/mapper/$LUKS_NAME&quot;
vgcreate -- &quot;$VG_NAME&quot; &quot;/dev/mapper/$LUKS_NAME&quot;
lvcreate -n &quot;$LV_NAME&quot; -l 100%FREE -- &quot;$VG_NAME&quot;
echo &quot;Done.&quot;

echo &quot;Copying rootfs partition...&quot;
dd if=&quot;$PLAIN_ROOTFS&quot; of=&quot;/dev/${VG_NAME}/${LV_NAME}&quot; bs=4K conv=fsync status=progress
echo &quot;Done.&quot;

echo &quot;Getting LUKS partition UUID...&quot;
LUKS_UUID=&quot;$(blkid -s UUID -o value -- &quot;${ENC_ROOTFS}&quot;)&quot;
echo &quot;Done. LUKS_UUID=${LUKS_UUID}&quot;

echo &quot;Getting encrypted ROOTFS partition UUID...&quot;
ROOTFS_UUID=&quot;$(blkid -s UUID -o value -- &quot;/dev/${VG_NAME}/${LV_NAME}&quot;)&quot;
echo &quot;Done. ROOTFS_UUID=${ROOTFS_UUID}&quot;

echo &quot;Mounting partitions...&quot;
mkdir -p -- &quot;$ROOTFS_MOUNTPOINT&quot; &quot;$BOOT_MOUNTPOINT&quot;
mount -- &quot;/dev/${VG_NAME}/${LV_NAME}&quot; &quot;$ROOTFS_MOUNTPOINT&quot;
mount -- &quot;$ENC_BOOT&quot; &quot;$BOOT_MOUNTPOINT&quot;
echo &quot;Done.&quot;

echo &quot;Patching rootfs...&quot;

echo &quot;${LUKS_NAME} UUID=${LUKS_UUID} none luks,initramfs&quot; &gt; &quot;${ROOTFS_MOUNTPOINT}/etc/crypttab&quot;

mkdir -p -- &quot;${ROOTFS_MOUNTPOINT}/etc/initramfs-tools&quot;

cat &gt;&gt; &quot;${ROOTFS_MOUNTPOINT}/etc/initramfs-tools/modules&quot; &lt;&lt;-&quot;EOF&quot;
algif_skcipher
xchacha20
adiantum
aes_arm
sha256
nhpoly1305
dm_crypt
EOF

DROPBEAR_CONFIG=&quot;${ROOTFS_MOUNTPOINT}/etc/dropbear/initramfs/dropbear.conf&quot;
mkdir -p -- &quot;$(dirname -- &quot;${DROPBEAR_CONFIG}&quot;)&quot;
cat &gt;&gt; &quot;${DROPBEAR_CONFIG}&quot; &lt;&lt;-&quot;EOF&quot;
DROPBEAR_OPTIONS=&quot;-p 2222&quot;
EOF

if [ -n &quot;${DROPBEAR_PUBLIC_KEY_FILE}&quot; ] ; then
  DROPBEAR_AUTHORIZED_KEYS=&quot;${ROOTFS_MOUNTPOINT}/etc/dropbear/initramfs/authorized_keys&quot;
  mkdir -p -- &quot;$(dirname -- &quot;${DROPBEAR_AUTHORIZED_KEYS}&quot;)&quot;
  cat -- &quot;${DROPBEAR_PUBLIC_KEY_FILE}&quot; &gt; &quot;${DROPBEAR_AUTHORIZED_KEYS}&quot;
fi

echo &quot;console=serial0,115200 console=tty1 root=UUID=${ROOTFS_UUID} cryptdevice=UUID=${LUKS_UUID}:${LUKS_NAME} rootfstype=ext4 fsck.repair=yes loglevel=5 net.ifnames=0 firmware_class.path=/lib/firmware/updates/brcm rootwait rootdelay=2&quot; &gt; &quot;${BOOT_MOUNTPOINT}/cmdline.txt&quot;

# Problem:
# If /cryptroot/crypttab is older than /proc/1,
# cryptdisks-unlock aborts with the message &quot;Try again later&quot;.
# /scripts/init-top/cryptroot is expected to update /cryptroot/crypttab,
# but there is no such script on my target machine.
# /cryptroot/crypttab is present anyways.
#
# Tried workaround (did not help):
# Add an initramfs script to update the timestamp of /cryptroot/crypttab.

TOUCH_CRYPTTAB_SCRIPT=&quot;${ROOTFS_MOUNTPOINT}/etc/initramfs-tools/scripts/init-premount/touch_crypttab&quot;
mkdir -p -- &quot;$(dirname -- &quot;${TOUCH_CRYPTTAB_SCRIPT}&quot;)&quot;
cat &gt; &quot;${TOUCH_CRYPTTAB_SCRIPT}&quot; &lt;&lt;-&quot;EOF&quot;
#!/bin/sh

PREREQ=&quot;&quot;

prereqs()
{
    echo &quot;$PREREQ&quot;
}

case $1 in
prereqs)
    prereqs
    exit 0
    ;;
esac

touch /cryptroot/crypttab
EOF

chmod +x -- &quot;${TOUCH_CRYPTTAB_SCRIPT}&quot;

echo &quot;Done.&quot;

echo &quot;Chrooting into new image...&quot;
mount --bind /dev &quot;${ROOTFS_MOUNTPOINT}/dev/&quot;
mount --bind /sys &quot;${ROOTFS_MOUNTPOINT}/sys/&quot;
mount --bind /proc &quot;${ROOTFS_MOUNTPOINT}/proc/&quot;

cp -- /usr/bin/qemu-arm-static &quot;${ROOTFS_MOUNTPOINT}/usr/bin/&quot;

chroot -- &quot;${ROOTFS_MOUNTPOINT}&quot; /bin/bash &lt;&lt;-&quot;EOF&quot;
DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get install -yq -o Dpkg::Options::=--force-confold fdisk e2fsprogs lvm2 busybox cryptsetup initramfs-tools cryptsetup-initramfs dropbear-initramfs keyutils &amp;&amp; \
/usr/sbin/update-rc.d cryptdisks-early enable &amp;&amp; \
/usr/sbin/update-initramfs -vu &amp;&amp; \
/bin/cp -t /boot/broadcom /boot/initrd*
EOF

echo &quot;Returned from chroot.&quot;

cleanup</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (unixdan22)]]></author>
			<pubDate>Sun, 29 Oct 2023 14:20:05 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=45146#p45146</guid>
		</item>
	</channel>
</rss>
