page counter next up previous contents
Next: LUKS 安全漏洞 Up: LUKS 檔案系統加解密 Previous: LUKS Mapping 掛載   Contents   DYWANG_HOME

initramfs 處理

  1. 預設的 Initialized RAM disk initramfs image 可能沒有 luks 的 driver,開機時無法開啟 luks 的 mapping,必須新增 dracut 參數,加入 lvm 及 crypt 模組,如果要用 USB 隨身碟放 LUKS 開機解密的 keyfile,也必須加入 usb_storage driver,ext4, vfat 等隨身碟分割區可能的格式,否則無法掛載。
    [root@kvm7 ~]# vim /etc/dracut.conf.d/autounlock.conf
    [root@kvm7 ~]# cat /etc/dracut.conf.d/autounlock.conf
    # dracut modules to omit
    omit_dracutmodules+=" systemd"
    
    # dracut modules to add to the default
    add_dracutmodules+=" lvm crypt"
    
    # dracut drivers to add to the default
    add_drivers+=" usb_storage xts aes-x86_64"
    
    filesystems+=" ext4 vfat xfs"
    
  2. dracut 產生 initramfs 檔。
    [root@kvm7 ~]# dracut /boot/initramfs-`uname -r`-luks-root.img `uname -r`
    
  3. 查看 /boot 目錄下的 initramfs 檔,多了 initramfs-xxxx-luks-root.img。
    [root@kvm7 ~]# ll /boot/initramfs-`uname -r`*
    -rw-------. 1 root root 26460783 May 20  2019 /boot/initramfs-3.10.0-862.2.3.el7.x86_64.img
    -rw-------. 1 root root 26821231 Dec  5 13:04 /boot/initramfs-3.10.0-862.2.3.el7.x86_64-luks-root.img
    
  4. initrd 使用新建的 initramfs-xxxx-luks-root.img。
    [root@kvm7 ~]# vim /boot/grub2/grub.cfg 
    [root@kvm7 ~]# grep luks /boot/grub2/grub.cfg 
    	initrd16 /initramfs-3.10.0-862.2.3.el7.x86_64-luks-root.img
    



De-Yu Wang 2020-05-14