initramfs

cpio’s block skipping sucks ass.

dracut will automatically gzip your initramfs, so things look awry if you rebuild and it looks like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
root(root)@qcow1 [modules]# /sbin/dracut -M -f -k /lib/modules/3.10.0-123.20.1.el7.x86_64 /root/buttholes.img 3.10.0-123.20.1.el7.x86_64
bash
nss-softokn
i18n
network
ifcfg
drm
plymouth
dm
kernel-modules
mdraid
qemu
qemu-net
rootfs-block
terminfo
udev-rules
biosdevname
systemd
usrmount
base
fs-lib
shutdown
root(root)@qcow1 [modules]# file /root/buttholes.img
/boot/buttholes.img: ASCII cpio archive (SVR4 with no CRC)

Then try to inspect it

1
2
3
4
5
6
7
8
root(root)@qcow1 [~]# cpio -itd < buttholes.img
.
early_cpio
kernel
kernel/x86
kernel/x86/microcode
kernel/x86/microcode/GenuineIntel.bin
58 blocks

Not gzipped, a whopping 58 blocks, and only contains the GenuineIntel.bin.

Use dd to skip the first x blocks of non gzip’d data to view the rest of the initramfs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
root(root)@qcow1 [~]# mkdir ish; mv buttholes.img ish; cd ish
root(root)@qcow1 [ish]# ls
buttholes.img
root(root)@qcow1 [ish]# dd if=buttholes.img of=realboy.img.gz bs=512 skip=58
34719+1 records in
34719+1 records out
17776538 bytes (18 MB) copied, 0.0549043 s, 324 MB/s
root(root)@qcow1 [ish]# gunzip realboy.img.gz
root(root)@qcow1 [ish]# ls
buttholes.img realboy.img
root(root)@qcow1 [ish]# cpio -id < realboy.img
77179 blocks
root(root)@qcow1 [ish]# ls
bin buttholes.img dev etc init lib lib64 proc realboy.img root run sbin shutdown sys sysroot tmp usr var

Rebuild initramfs

1
dracut -M -f -k  /boot/initramfs-$(uname -r).img $(uname -r)