dracut 維基 https://dracut.wiki.kernel.org/index.php/Main_Page
http://www.360doc.com/content/13/0428/09/12139495_281449877.shtml
dracut 官方手冊 https://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html#dracutkernel7
https://www.kernel.org/pub/linux/utils/boot/dracut/
基本介紹
dracut 是一個事件驅動的 initramfs 基礎設施。dracut(工具)被用來通過拷貝工具和文件,從一個已經安裝的系統創建一個 initramfs 鏡像,並將鏡像與dracut框架結合在一起。通常發現在 /usr/lib/dracut/modules.d/.
不像已經存在的initramfs框架,dracut的框架嘗試有盡可能更少的硬編碼進入initramfs。initramfs在生命中有一個基本的目標:獲取已經掛載的rootfs,以致我們能夠過渡到真正的rootfs。這是所有驅動裝置的可用性。因此,取代腳本硬編碼去做各種事情,dracut的 initramfs 依賴 udev 去創建符號鏈接到設備節點,接着,當rootfs的設備節點出現的時候,它被掛載和根切換到rootfs設備。 這個有助於保持在initramfs里要求的時間盡可能的少,以致一些事情,如5s鍾啟動,作為一個initramfs的存在結果不是不可能的。
在dracut中,大部分的initramfs生成器功能由一群生成模塊提供,這些模塊是被主要的dracut工具采購,來安裝特定的功能進入initramfs。他們存在於這些模塊的子目錄。和使用由dracut-functions提供的功能去做他們的工作。
dracut 作為新一代的 initramfs 系統,和前一代的initramfs系統的 mkinitrd 的不同點在於, dracut設計上就考慮到了映像尺寸的問題,盡量避免硬編碼,以提高生成的 cpio 映像載入內存的速度。實際上,由於initramfs的唯一作用就是掛載rootfs(因此不需要把一堆無用的比如 plymouth 等都裝進去),它主要依賴 udev 去獲取 rootfs 的設備節點,一旦 rootfs 節點出現則立刻切換過去。按照官方維基的說法:5秒啟動不是夢。另外它采用了模塊化的方式,使用者可自由在 %{_libdir}/dracut/modules.d 下創建他需要的特殊模塊,可擴展性很強。最后它的使用方式和 mkinitrd 非常接近,遷移成本較低。
dracut 用於制作initrd啟動鏡像文件, dracut-network會為鏡像內添加nfs等網絡支持.
centos 7.2
版本: dracut-033-359.el7.x86_64
dracut-config-rescue-033-360.el7_2.x86_64
dracut-033-360.el7_2.x86_64
dracut-network-033-360.el7_2.x86_64
centos 6
dracut-004-32.el6.noarch
dracut-kernel-004-32.el6.noarch
命令行工具:
dracut create initial ramdisk images for preloading modules。 dracut創建虛擬磁盤映像,提供給內核,預加載塊設備模塊(例如 IDE,SCSI或者RAID),通過加載這些設備模塊訪問根文件系統。
dracut [OPTION...] [<image> [<kernel version>]]
創建一個帶有kernel版本號,為kernel使用的 initramfs 鏡像。如果 <kernel version> 被省略,那么使用實際運行的內核版本號。如果 <image> 被省略或為空,那么缺省的位置 /boot/initramfs-<kernel version>.img 被使用
在啟動時,內核解包這個存檔進入內存,掛載和使用它作為初始化根文件系統。所有發現的根設備發生在這個早期的用戶空間。
完整的內核命令行選項,詳看 dracut.cmdline(7).
如果被降到一個緊急shell,當啟動你的 initramfs時,文件 /run/initramfs/rdsosreport.txt 被創建,這個文件能被安全(手動掛載)的成為一個分區(通用 /啟動)或一個USB盤. 通過在內核命令添加 rd.debug 產生附件的調試信息。 /run/initramfs/rdsosreport.txt 包含所有的日志和一些工具的輸出。這個文件應該被聯系到關於dracut問題的任何報告。
lsinitrd tool to show the contents of an initramfs image。if <image> is omitted, then lsinitrd uses the default image /boot/<machine-id>/<kernel-version>/initrd or /boot/initramfs-<kernel-version>.img.
lsinitrd [OPTION...] [<image> [<filename> [<filename> [...] ]]]
lsinitrd [OPTION...] -k <kernel-version>
lsinitrd 顯示一個 initramfs 鏡像的內容。 如果 <image> 被省略,那么 lsinitrd 用 這個缺省的鏡像 /boot/<machine-id>/<kernel-version>/initrd 或者 /boot/initramfs-<kernel-version>.img
OPTIONS
-h, --help print a help message and exit.
-s, --size sort the contents of the initramfs by size.
-f, --file <filename> print the contents of <filename>.
-k, --kver <kernel version> inspect the initramfs of <kernel version>.
mkinitrd is a compat wrapper, which calls dracut to generate an initramfs 調用 dracut 來產生 initramfs。
mkinitrd [OPTION...] [<initrd-image>] <kernel-version>
mkinitrd 通過調用 dracut 去創建一個 initramfs 帶有<kernel-version>版本的鏡像 <initrd-image> 鏡像。
注意: 如果需要生成一個更細粒度控制的鏡像,“dracut”應該被直接調用。
OPTIONS
--version print info about the version
-v, --verbose increase verbosity level
-f, --force overwrite existing initramfs file.
*--image-version append the kernel version to the target image <initrd-image>-<kernel-version>.
--with=<module> add the kernel module <module> to the initramfs.
--preload=<module> preload the kernel module <module> in the initramfs before any other kernel modules are loaded. This can be used to ensure a certain device naming, which should in theory be avoided and the use of symbolic links in /dev is encouraged.
--nocompress do not compress the resulting image.
--help print a help message and exit.
配置
/etc/dracut.conf see dracut.conf5
/etc/dracut.conf.d/*.conf see dracut.conf5
/usr/lib/dracut/dracut.conf.d/*.conf see dracut.conf5
Configuration in the initramfs
/etc/conf.d/ Any files found in /etc/conf.d/ will be sourced in the initramfs to set initial values. Command line options will override these values set in the configuration files.
/etc/cmdline Can contain additional command line options. Deprecated, better use /etc/cmdline.d/*.conf.
/etc/cmdline.d/*.conf Can contain additional command line options.
服務
dracut-cmdline.service
dracut-initqueue.service
dracut-mount.service
dracut-pre-mount.service
dracut-pre-pivot.service
dracut-pre-trigger.service
dracut-pre-udev.service
dracut-shutdown.service
日志
/var/log/dracut.log initramfs 鏡像創建的日志文件
/tmp/dracut.log initramfs 鏡像創建的日志文件, 如果 /var/log/dracut.log 沒有被寫。
參考:
PXE啟動服務器及客戶端鏡像制作 http://blog.csdn.net/beck_chen/article/details/52672324
