dracut二, 09/03/2021 - 12:44 的修訂版本

修訂版本可以讓你追蹤文章的多個版本的不同之處。

最後更新: 2021-03-01

介紹

dracut - low-level tool for generating an initramfs/initrd image

目錄

 


"dracut" Usage

 

dracut [OPTION...] [image [kernel-version]]

 * kernel-version 係對應 /lib/modules 內的 folder

 * If kernel version is omitted, then the version of the actual running kernel is used.

 * If <image> isomitted or empty, then the default location /boot/initramfs-<kernel version>.img is used.

Config File

  • /etc/dracut.conf
  • /etc/dracut.conf.d/*.conf

 


Contents in initramfs

 

# To see the contents of the image created by dracut

lsinitrd | less

#  To display the contents of a file in the initramfs

lsinitrd -f /etc/ld.so.conf

 


Modules

 

# To see a list of available dracut modules, use the --list-modules option:

dracut --list-modules

# Omitting dracut Modules

dracut -o "multipath lvm" no-multipath-lvm.img

# Adding Kernel Modules

# 亦可以在 /etc/dracut.conf 或 /etc/dracut.conf.d/mymod.conf 設定

dracut --add-drivers "mymod" initramfs-with-mymod.img

i.e.

不 load 一堆用不到的 module

/etc/dracut.conf.d/myflags.conf

omit_dracutmodules+="iscsi resume lvm nbd rdma nfs cifs crypt crypt-loop crypt-gpg ecryptfs"

設定檔: /etc/dracut.conf.d/mymod.conf

dracutmodules+=" <dracut modules> "

Specify a space-separated list of dracut modules to call when building the initramfs.

Modules are located in /usr/lib/dracut/modules.d.

This option forces dracut to only include the specified dracut modules.

In most cases the "add_dracutmodules" option is what you want to use.

# Equivalent to -a "module"

add_dracutmodules+=" module" # Note leading space

# Equivalent to -o "module"

omit_dracutmodules+=" module" # Note leading space

 


Kernel cmdline

 

# To get a quick start for the suitable kernel command line on your system

dracut --print-cmdline

man dracut.cmdline

Boot disable all USB storage devices

/etc/dracut.conf

kernel_cmdline="... rd.driver.blacklist=usb-storage,uas"

# dracut will automatically source this file and create a /etc/cmdline.d/01-default.conf file and place it inside the initramfs

/etc/dracut.conf.d/cmdline.conf -> initramfs(/etc/cmdline.d/01-default.conf)

加速 boot 機

rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0