dracut 基本介绍
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 是一個事件驅(qū)動的 initramfs 基礎(chǔ)設(shè)施。dracut(工具)被用來通過拷貝工具和文件,從一個已經(jīng)安裝的系統(tǒng)創(chuàng)建一個initramfs 鏡像,并將鏡像與dracut框架結(jié)合在一起。通常發(fā)現(xiàn)在/usr/lib/dracut/modules.d/.
不像已經(jīng)存在的initramfs框架,dracut的框架嘗試有盡可能更少的硬編碼進(jìn)入initramfs。initramfs在生命中有一個基本的目標(biāo):獲取已經(jīng)掛載的rootfs,以致我們能夠過渡到真正的rootfs。這是所有驅(qū)動裝置的可用性。因此,取代腳本硬編碼去做各種事情,dracut的 initramfs 依賴 udev 去創(chuàng)建符號鏈接到設(shè)備節(jié)點,接著,當(dāng)rootfs的設(shè)備節(jié)點出現(xiàn)的時候,它被掛載和根切換到rootfs設(shè)備。 這個有助于保持在initramfs里要求的時間盡可能的少,以致一些事情,如5s鐘啟動,作為一個initramfs的存在結(jié)果不是不可能的。
在dracut中,大部分的initramfs生成器功能由一群生成模塊提供,這些模塊是被主要的dracut工具采購,來安裝特定的功能進(jìn)入initramfs。他們存在于這些模塊的子目錄。和使用由dracut-functions提供的功能去做他們的工作。
dracut 作為新一代的 initramfs 系統(tǒng),和前一代的initramfs系統(tǒng)的 mkinitrd 的不同點在于, dracut設(shè)計上就考慮到了映像尺寸的問題,盡量避免硬編碼,以提高生成的 cpio 映像載入內(nèi)存的速度。實際上,由于initramfs的唯一作用就是掛載rootfs(因此不需要把一堆無用的比如 plymouth 等都裝進(jìn)去),它主要依賴 udev 去獲取 rootfs 的設(shè)備節(jié)點,一旦 rootfs 節(jié)點出現(xiàn)則立刻切換過去。按照官方維基的說法:5秒啟動不是夢。另外它采用了模塊化的方式,使用者可自由在 %{_libdir}/dracut/modules.d 下創(chuàng)建他需要的特殊模塊,可擴(kuò)展性很強(qiáng)。最后它的使用方式和 mkinitrd 非常接近,遷移成本較低。
dracut用于制作initrd啟動鏡像文件,dracut-network會為鏡像內(nèi)添加nfs等網(wǎng)絡(luò)支持.
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創(chuàng)建虛擬磁盤映像,提供給內(nèi)核,預(yù)加載塊設(shè)備模塊(例如 IDE,SCSI或者RAID),通過加載這些設(shè)備模塊訪問根文件系統(tǒng)。
dracut [OPTION...] [<image> [<kernel version>]]
創(chuàng)建一個帶有kernel版本號,為kernel使用的 initramfs 鏡像。如果 <kernel version> 被省略,那么使用實際運行的內(nèi)核版本號。如果 <image> 被省略或為空,那么缺省的位置/boot/initramfs-<kernel version>.img 被使用
在啟動時,內(nèi)核解包這個存檔進(jìn)入內(nèi)存,掛載和使用它作為初始化根文件系統(tǒng)。所有發(fā)現(xiàn)的根設(shè)備發(fā)生在這個早期的用戶空間。
完整的內(nèi)核命令行選項,詳看 dracut.cmdline(7).
如果被降到一個緊急shell,當(dāng)啟動你的 initramfs時,文件/run/initramfs/rdsosreport.txt 被創(chuàng)建,這個文件能被安全(手動掛載)的成為一個分區(qū)(通用 /啟動)或一個USB盤. 通過在內(nèi)核命令添加 rd.debug 產(chǎn)生附件的調(diào)試信息。/run/initramfs/rdsosreport.txt 包含所有的日志和一些工具的輸出。這個文件應(yīng)該被聯(lián)系到關(guān)于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>/initrdor /boot/initramfs-<kernel-version>.img.
lsinitrd [OPTION...] [<image> [<filename> [<filename> [...] ]]]
lsinitrd [OPTION...] -k <kernel-version>
lsinitrd 顯示一個 initramfs 鏡像的內(nèi)容。 如果 <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 調(diào)用 dracut 來產(chǎn)生 initramfs。
mkinitrd [OPTION...] [<initrd-image>] <kernel-version>
mkinitrd 通過調(diào)用 dracut 去創(chuàng)建一個 initramfs 帶有<kernel-version>版本的鏡像 <initrd-image> 鏡像。
注意: 如果需要生成一個更細(xì)粒度控制的鏡像,“dracut”應(yīng)該被直接調(diào)用。
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 theconfiguration 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.
服務(wù)
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 鏡像創(chuàng)建的日志文件
/tmp/dracut.log initramfs 鏡像創(chuàng)建的日志文件, 如果/var/log/dracut.log 沒有被寫。
參考:
PXE啟動服務(wù)器及客戶端鏡像制作http://blog.csdn.net/beck_chen/article/details/52672324
總結(jié)
以上是生活随笔為你收集整理的dracut 基本介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【命令】Maven命令
- 下一篇: 苹果 10 月 24 日前推送 iOS