1

The file shows 56 blocks as the size. I am using the system Ubuntu 16.04 and I need a solution that does not require me to update the kernel.

2

Although it may be named initrd, it is actually an initramfs. That means, it can be a concatenation of multiple cpio archives, each of which may or may not be compressed. You may have managed to extract just the first part.

Proper procedure for extracting an initramfs file

More specifically, the first cpio part is usually an "early microcode update", which for Intel processors has a pathname kernel/x86/microcode/GenuineIntel.bin. If you just run cpio -iv /boot/initrd.img-<kernel version>, this is all you get extracted. (The microcode is typically not compressed because it's encrypted and so won't compress much at all.)

To fully extract a modern initramfs in a Debian/Ubuntu system, you should use the unmkinitramfs command.

If that command is not available for some reason, you can do it manually like this:

mkdir /some/temporary/directory
cd /some/temporary/directory
cat /boot/initrd.img-$(uname -r) | (cpio -iv; zcat | cpio -iv; file -)

assuming that the initramfs has only two parts.

The idea is that the cat command will output the contents from the beginning to the end to the commands within the parentheses. Within them, the first cpio will take the beginning of the file and extract the early microcode update. Once it finishes, the next command will pick up from where the first command left off. When the second, compressed cpio archive ends, the file - command checks to see whether or not there is still more to come.

If the last line of extraction output is not

/dev/stdin: empty

...then you'll know there is a further part in the initramfs file, and the file command output tells you whether it's compressed or not. Then add another cpio -iv; or zcat | cpio -iv; element within the parentheses just before the filecommand.

For example, to extract a three-part initramfs with two compressed parts after the early microcode update:

cat /boot/initrd.img-$(uname -r) | (cpio -iv; zcat | cpio -iv; zcat | cpio -iv; file -)

If your initrd is really only 56 blocks in size

In this case, the initrd creation process may have failed. You can use

sudo update-initramfs -u

to tell the system to regenerate it based on your current kernel and modules. This is also a good command to run after any configuration changes that may affect things that need to happen early in the system start-up, before the real root filesystem is mounted.

  • For nitpickers: sure, technically this is an "useless use of cat command", but making it explicit that the initramfs file is read only once might make it easier to understand what is going on. – telcoM Apr 8 at 12:41
  • Thank you for responding! The command 'unmkinitramfs' works fine when executed on Ubuntu 18.04, but not in 16.04. Also, for the command above, I'm getting error saying 'gzip: stdin: not in gzip format' and 'cpio: premature end of archive' – priyalsoni Apr 9 at 5:47
  • Interesting... perhaps the initramfs file creation process has indeed failed, or maybe Ubuntu uses a different compression; try just cpio -iv; file - inside the parentheses. – telcoM Apr 9 at 7:03
  • Oh no, It's still pulling just the kernel module – priyalsoni Apr 9 at 7:24
  • I think I once saw something similar when the system ran out of disk space while creating the initramfs file: it managed to build the first cpio archive, but the second one was zero-sized because the process to build and compress the second part failed as disk space ran out. Ensure that you have plenty of free disk space in /tmp and run the sudo update-initramfs -u. If it displays any error messages, those might be enlightening. – telcoM Apr 9 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.