jessieからStretchにアップグレードした後、update-initramfsは失敗します。

jessieからStretchにアップグレードした後、update-initramfsは失敗します。

私は最近Stretchを実行するようにDebianコンピュータの1つを更新しましたが、残念ながらinitramfsイメージを再構築するのに問題があります。

起動時にディレクトリとその内容が存在しなければならないことを認識していないようです/root/.ssh/。 update-initramfsが/etc/initramfs-tools/rootの内容を強制的にインポートできるようにする設定オプションを見つけましたが、イメージをビルドできずに手動で作成しましたが、運がありませんでした。最後に、私の側の設定エラーではないことを確認するためにsysresccdでdebootstrapインストールを実行しましたが、それも失敗しました。

initramfs イメージを更新しようとしたときに表示される出力は次のとおりです。

root@sysresccd:/etc/initramfs-tools# update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-4.3.0-1-amd64
/etc/initramfs-tools/hooks/mount_cryptroot: 21: /etc/initramfs-tools/hooks/mount_cryptroot: cannot create /var/tmp/mkinitramfs_uIC6Q0/root/mount_cryptroot.sh: Directory nonexistent
chmod: cannot access /var/tmp/mkinitramfs_uIC6Q0/root/mount_cryptroot.sh: No such file or directory
/etc/initramfs-tools/hooks/mount_cryptroot: 36: /etc/initramfs-tools/hooks/mount_cryptroot: cannot create /var/tmp/mkinitramfs_uIC6Q0/root/.profile: Directory nonexistent
/etc/initramfs-tools/hooks/mount_cryptroot: 21: /etc/initramfs-tools/hooks/mount_cryptroot: cannot create /var/tmp/mkinitramfs_uIC6Q0/root/mount_cryptroot.sh: Directory nonexistent
chmod: cannot access /var/tmp/mkinitramfs_uIC6Q0/root/mount_cryptroot.sh: No such file or directory
/etc/initramfs-tools/hooks/mount_cryptroot: 36: /etc/initramfs-tools/hooks/mount_cryptroot: cannot create /var/tmp/mkinitramfs_uIC6Q0/root/.profile: Directory nonexistent
E: /etc/initramfs-tools/hooks/mount_cryptroot failed with return 2.
update-initramfs: failed for /boot/initrd.img-4.3.0-1-amd64 with 2.

実際、今はアイデアが不足しています。誰もがこの問題を解決するのを手伝ってくれたらとても感謝します。

いくつかの背景情報:
私が使用するもの このガイド私のシステムをインストールしましたが、Jesseでは正常に動作しましたが、拡張したときに上記の理由で失敗しました。

ベストアンサー1

今日も同じ問題があり、この問題はオンラインでしか見つかりませんでした。だから私は自分でデバッグをしてみました...

スクリプト/etc/initramfs-tools/hooks/mount_cryptroot(行 21) は、ファイルを/var/tmp/mkinitramfs_uIC6Q0/root/ディレクトリに入れようとします。エラーメッセージによると、ディレクトリがありません。スクリプトの関連部分は次のとおりです。

SCRIPT="${DESTDIR}/root/mount_cryptroot.sh"
cat > "${SCRIPT}" << 'EOF'

この/var/tmp/mkinitramfs_uIC6Q0/ディレクトリは、新しいinitrdの内容を収集する一時ディレクトリです。私の考えでは、initrdにもはやルートサブディレクトリがないようです。それで、既存のinitrdイメージの内容を見ました。

# mkdir initrd
# cd initrd
# gunzip -c /boot/initrd.img-4.9.0-3-amd64 | cpio -i
125955 blocks
# ls
bin  conf  etc  init  lib  lib64  root-aBcDeF  run  sbin  scripts
#

ディレクトリrootには、6つの任意の文字/数字が接尾辞で付けられます(ここではに変更されますaBcDeF)。これはセキュリティ上の理由かもしれません。生成されたinitrdのサフィックスが毎回異なることがわかりました。

したがって、解決策は/etc/initramfs-tools/hooks/mount_cryptrootスクリプトを拡張してルートディレクトリの実際の名前(サフィックスを含む)を見つけ、それを代わりに使用することですroot

これは挿入によって行うことができます。

ROOTDIR="$(cd "${DESTDIR}"; echo root-*)"

欠陥のある行の前に欠陥のある行を次に変更します。

SCRIPT="${DESTDIR}/${ROOTDIR}/mount_cryptroot.sh"
cat > "${SCRIPT}" << 'EOF'

rootサフィックスを含まない2行以上の行があります。これは次のように変更する必要があります。

cat > "${DESTDIR}/${ROOTDIR}/.profile" << EOF

そして

/${ROOTDIR}/mount_cryptroot.sh && exit 1 || echo "Run ./mount_cryptroot.sh to try unlocking again"

。これは私のために問題を解決しました。

update-initramfs -u -k all

起動時にSSH経由でパスワードを入力すると、再び機能します。

私の適応後のスクリプト全体/etc/initramfs-tools/hooks/mount_cryptroot

#!/bin/sh

# Author: http://www.dont-panic.cc/capi/2012/10/24/fully-encrypted-vserver-with-ubuntu-12-04/
# This script generates two scripts in the initramfs output,
# /root-xxxxxx/mount_cryptroot.sh and /root-xxxxxx/.profile
ALLOW_SHELL=1
# Set this to 1 before running update-initramfs if you want
# to allow authorized users to type Ctrl-C to drop to a
# root shell (useful for debugging, potential for abuse.)
#
# (Note that even with ALLOW_SHELL=0 it may still be possible
# to achieve a root shell.)
#

if [ -z ${DESTDIR} ]; then
exit
fi

ROOTDIR="$(cd "${DESTDIR}"; echo root-*)"

SCRIPT="${DESTDIR}/${ROOTDIR}/mount_cryptroot.sh"
cat > "${SCRIPT}" << 'EOF'
#!/bin/sh
CMD=
while [ -z "$CMD" -o -z "`pidof askpass plymouth`" ]; do
CMD=`ps -o args | grep 'open --type luks' | grep -v grep`
sleep 0.1
done
while [ -n "`pidof askpass plymouth`" ]; do
$CMD && kill -9 `pidof askpass plymouth` && echo "Success"
done
EOF

chmod +x "${SCRIPT}"

# Run mount_cryptroot by default and close the login session afterwards
# If ALLOW_SHELL is set to 1, you can press Ctrl-C to get to an interactive prompt
cat > "${DESTDIR}/${ROOTDIR}/.profile" << EOF
ctrl_c_exit() {
exit 1
}
ctrl_c_shell() {
# Ctrl-C during .profile appears to mangle terminal settings
reset
}
if [ "$ALLOW_SHELL" == "1" ]; then
echo "Unlocking rootfs... Type Ctrl-C for a shell."
trap ctrl_c_shell INT
else
echo "Unlocking rootfs..."
trap ctrl_c_exit INT
fi
/${ROOTDIR}/mount_cryptroot.sh && exit 1 || echo "Run ./mount_cryptroot.sh to try unlocking again"
trap INT
EOF

おすすめ記事