Skip to Content

initramfs (Dracut) Referência de comando

A partir do Ubuntu 26.04, a ferramenta de compilação initramfs mudou de initramfs-tools para Dracut. Os comandos diários mudam de acordo: os antigos update-initramfs e lsinitramfs são substituídos por dracut e lsinitrd, e o diretório de configuração se torna /etc/dracut.conf.d/.

Note

Os sistemas atualizados para 26.04 ainda podem manter initramfs-tools, caso em que os comandos antigos ainda funcionam. As novas instalações usam Dracut por padrão. Confirme com which dracut / dracut --version.

Mapeamento de comandos

Antigo (ferramentas initramfs)Novo (Dracut)Descrição
sudo update-initramfs -usudo dracut -fReconstrua o initramfs para o kernel atual (-f substitui o arquivo existente)
sudo update-initramfs -u -k allsudo dracut -f --regenerate-allReconstruir para todos os kernels instalados
sudo update-initramfs -u -k $(uname -r)sudo dracut -f --kver $(uname -r)Construa para uma versão específica do kernel
lsinitramfs /boot/initrd.img-$(uname -r)lsinitrdListar arquivos incluídos no initramfs
lsinitramfs … | grep xxxlsinitrd | grep xxxVerifique se um módulo/arquivo está compactado
/etc/initramfs-tools//etc/dracut.conf.d/Diretório de configuração
/etc/initramfs-tools/modulesforce_drivers+=" MODULE " (em conf.d)Forçar a inclusão de um módulo do kernel

Operações Comuns

# Rebuild the initramfs for the current kernel sudo dracut -f # Rebuild for all installed kernels (common after changing drivers, encryption, resume, etc.) sudo dracut -f --regenerate-all # Build for a specific kernel version to a specific path sudo dracut -f /boot/initrd.img-7.0.0-10-generic 7.0.0-10-generic

Inspecionando o initramfs

# View the contents of the current kernel's initramfs (defaults to the current kernel) lsinitrd # Inspect a specific file lsinitrd /boot/initrd.img-$(uname -r) # Confirm whether a kernel module is packed in (e.g. resume, encryption, NIC driver) lsinitrd | grep -i resume lsinitrd | grep -i nvme

Configurando Dracut

A configuração Dracut reside em arquivos *.conf em /etc/dracut.conf.d/. As alterações só terão efeito após a reconstrução do initramfs.

# Example: force-pack certain drivers into the initramfs echo 'force_drivers+=" nvme nvme_core "' | sudo tee /etc/dracut.conf.d/90-nvme.conf sudo dracut -f --regenerate-all

Opções de configuração comuns:

# /etc/dracut.conf.d/zz-local.conf # Pack only modules needed by this host (smaller, the default behavior) hostonly="yes" # Force-include specific kernel drivers force_drivers+=" MODULE " # Add specific dracut modules (such as crypt, lvm, network) add_dracutmodules+=" crypt lvm " # Include extra executables in the initramfs install_items+=" /usr/bin/vi "
Tip

Após alterar a retomada (hibernação), a criptografia de disco ou o driver do controlador que contém o sistema de arquivos raiz, lembre-se de executar sudo dracut -f --regenerate-all, ou o sistema poderá falhar ao inicializar.

Artigos relacionados

Last updated on