Dracutにcryptsetupを追加する方法

Dracutにcryptsetupを追加する方法

Dracutに切り替えようとしていますが、問題がたくさんあります。これを 1 つずつ削除するには、まずシステムが正しくブートされることを願っています。したがって、私のGrub2エントリは次のようになります。

menuentry 'dracut' {
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod ext2
        set root='hd1,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  829c0201-9b6d-4e18-8464-9d2551311ea6
        else
          search --no-floppy --fs-uuid --set=root 829c0201-9b6d-4e18-8464-9d2551311ea6
        fi
        echo    'Loading Linux 4.9.0-2-amd64 ...'
    linux   /vmlinuz-4.9.0-2-amd64 rd.shell rd.debug log_buf_len=1M
        echo    'Loading dracut initial ramdisk ...'
        initrd  /initramfs-4.9.0-2-amd64.img
}

私は回復シェルに入り、手動でルートファイルシステムを組み立てて起動を続行すると予想しましたが、回復cryptsetupシェルにはバイナリはありません。

Dracut設定ファイルは/etc/dracut.conf.d/*次のとおりです。

do_prelink=no
add_dracutmodule+="cryptsetup" 

関連モジュールのリストは次のとおりです。

# dracut --list-modules | grep crypt
dracut: Executing: /usr/bin/dracut --list-modules
crypt
crypt-gpg
crypt-loop
ecryptfs

cryptsetup(回復シェルを介して)暗号化されたパーティションを手動でロック解除できるようにこれを追加するにはどうすればよいですか?

ベストアンサー1

debian dracut-core 044+243-3、/usr/lib/dracut/modules.d/90crypt/module-setup.sh から開始:

require_any_binary $systemdutildir/systemd-cryptsetup cryptsetup || return 1

したがって、dracutは最初に/lib/systemd/systemd-cryptsetupを含めようとし、最初のエントリがない場合は/sbin/cryptsetupを含み、両方がない場合は失敗します。

これはそれぞれcryptsetup-bin 2:2.1.0-5とsystemd 241-1で提供されています。

/lib/systemd/systemd-cryptsetup の使用法は /sbin/cryptsetup と同じではありません。実際には機能が少ない。

systemd-cryptsetup attach VOLUME SOURCEDEVICE [PASSWORD] [OPTIONS]
systemd-cryptsetup detach VOLUME

Attaches or detaches an encrypted block device.

See the [email protected](8) man page for details.

したがって、/sbin/cryptsetup を含める必要があるかもしれません。

dracut --install "/sbin/cryptsetup" /boot/initrd.1 4.19.0-5-amd64

または/etc/dracut.conf.d/XXXにあります。

install_items+="/sbin/cryptsetup"

ファイル自体だけをコピーする「include」スイッチと、動的ライブラリもコピーする「install」スイッチもあります。

最後に、確認には以下が含まれますlsinitrd /boot/initrd.1

出力(おそらく|grep cryptsetup):

-rwxr-xr-x   1 root     root        47152 Jul  3 09:10 sbin/cryptsetup  
-rw-r--r--   1 root     root       363920 Feb  9 07:40 lib/x86_64-linux-gnu/libcryptsetup.so.12.4.0

おすすめ記事