我安装了新的 gentoo,唯一需要时间的引导步骤是:
Trying to unpack rootfs image as initramfs...
启动时大约需要 10 秒。我尝试阅读 initramfs 来找出为什么这一步需要更长的时间,但对我来说仍然非常神秘。我的启动分区中有一个 initramfs:
~ $ cd /boot/
malcolm@Host-002 /boot $ ls
grub lost+found
initramfs-genkernel-x86_64-4.12.12-gentoo System.map-genkernel-x86_64-4.12.12-gentoo
kernel-genkernel-x86_64-4.12.12-gentoo
grub2-mkconfig -o /boot/grub/grub.cfg
确实找到了 initramfs-genkernel 它在我的/boot/grub/grub.cfg
:
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuent$
load_video
if [ "x$grub_platform" = xefi ]; then
set gfxpayload=keep
fi
insmod gzio
insmod part_gpt
insmod ext2
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --$
else
search --no-floppy --fs-uuid --set=root 80e1a69b-be52-4845-a6c7-4f7e8353bc1e
fi
echo 'Loading Linux x86_64-4.12.12-gentoo ...'
linux /kernel-genkernel-x86_64-4.12.12-gentoo root=UUID=2eb28949-50a7-4178-9d0a-309$
echo 'Loading initial ramdisk ...'
initrd /initramfs-genkernel-x86_64-4.12.12-gentoo
}
我很困惑,不知道什么unpacking roots image as initramfs
意思。由于需要 initramfs 来加载加载系统所需的工具,因此我认为我的系统会将 initramfs-genkernel 解压到我的启动分区上。这个 rootfs 镜像是什么?
我知道这是一个非常令人困惑的问题,但我也是,任何关于如何使它变得更好的提示将不胜感激。
编辑:
/var/log/dmesg
围绕 initramfs 的实际点
[ 0.275512] pci_bus 0000:00: resource 4 [io 0x0000-0x0cf7 window]
[ 0.275514] pci_bus 0000:00: resource 5 [io 0x0d00-0xffff window]
[ 0.275515] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff window]
[ 0.275516] pci_bus 0000:00: resource 7 [mem 0xd0000000-0xfebfffff window]
[ 0.275517] pci_bus 0000:00: resource 8 [mem 0xfed40000-0xfed4bfff window]
[ 0.275518] pci_bus 0000:03: resource 0 [io 0x2000-0x2fff]
[ 0.275519] pci_bus 0000:03: resource 1 [mem 0xd0100000-0xd02fffff]
[ 0.275520] pci_bus 0000:03: resource 2 [mem 0xd0300000-0xd04fffff 64bit pref]
[ 0.275521] pci_bus 0000:04: resource 1 [mem 0xf1000000-0xf10fffff]
[ 0.275611] NET: Registered protocol family 2
[ 0.275839] TCP established hash table entries: 65536 (order: 7, 524288 bytes)
[ 0.276037] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
[ 0.276238] TCP: Hash tables configured (established 65536 bind 65536)
[ 0.276353] UDP hash table entries: 4096 (order: 5, 131072 bytes)
[ 0.276455] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes)
[ 0.276597] NET: Registered protocol family 1
[ 0.276691] pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
[ 0.277288] PCI: CLS 64 bytes, default 64
[ 0.277324] Trying to unpack rootfs image as initramfs...
[ 5.396096] Freeing initrd memory: 38272K
[ 5.396183] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
[ 5.396270] software IO TLB [mem 0xba0af000-0xbe0af000] (64MB) mapped at [ffff918efa0af000$
[ 5.396465] RAPL PMU: API unit is 2^-32 Joules, 4 fixed counters, 655360 ms ovfl timer
[ 5.396587] RAPL PMU: hw unit of domain pp0-core 2^-14 Joules
[ 5.396670] RAPL PMU: hw unit of domain package 2^-14 Joules
[ 5.396752] RAPL PMU: hw unit of domain dram 2^-14 Joules
[ 5.396835] RAPL PMU: hw unit of domain pp1-gpu 2^-14 Joules
[ 5.397284] audit: initializing netlink subsys (disabled)
[ 5.397435] audit: type=2000 audit(1513038122.396:1): state=initialized audit_enabled=0 re$
[ 5.397762] Initialise system trusted keyrings
[ 5.397883] workingset: timestamp_bits=46 max_order=21 bucket_order=0
[ 5.398161] SELinux: Registering netfilter hooks
[ 5.398739] Key type asymmetric registered
尽管日志显示 5 秒,但我在启动时看到的实际时间以及输出的时间约为 10 秒:/
答案1
解压存档取决于两件事(恕我直言):
- 使用的算法
- 存档中文件的大小
因此我认为你的初始化内存盘太大了。
为了加快该过程,您可以尝试最小化大小并使用各种受支持的归档算法,看看哪种算法最适合您的设置。
对我来说,它是用 LZ4 压缩的最小内核,没有 init ramdisk。有了这个,我在 hp envy 14(1.8GHZ 上的 amd apu)上从 grub 到 sysv init 的时间达到了 0.9 秒。如果您对优化进程感兴趣,您可以找到一个很好的指南来最小化内核和 init ram 磁盘尺寸在这里https://www.dotslashlinux.com/post/the-linux-kernel-configuration-guide-part-1-introduction/