Posts Tagged ‘initrd’

How to extract modern Ubuntu initramfs

Thursday, May 30th, 2019

Just to remember, there is an explanation here, from which the following directive can be taken:

(cpio -id; zcat | cpio -id) < /path/to/initrd.img

Rapid-guide – Updating RedHat initrd

Saturday, December 5th, 2009

Warning: This is not the recommended method if you’re not sure you know what you’re doing.

Linux Initial Ram Disk (initrd) is a mechanism to perform disk-independent actions before attempting to mount the ‘/’ disk. These actions usually include loading disk drivers, setting up LVM or software RAID, etc.

The reason these actions are performed within initrd is that it is all based on Ram Disk loaded by the boot loader, and thus it breaks the loop of “how would I load storage drivers without storage access?”

It happens that due to some special even we need to modify it manually. To do so we need first to open it, and then to close it back in, replacing (backup the old one, will you?) the previous one.

This is rather simple. The tools used by us will be ‘gzip’ and ‘cpio’.

Lets begin.

First – create a temporary directory:

mkdir /tmp/initrd

Extracting

We have our temporary directory, so now, we need to extract the initrd into it. I assume the name of the file is /boot/initrd.img. You should replace my line with whatever the name of your initrd file:

cd /tmp/initrd

cat /boot/initrd.img | gzip -dc |  cpio -id

This will extract the contents of the initrd into /tmp/initrd.

Now you can edit its contents directly.

Package

To package initrd back in, we will need to perform the following actions.

Warning – before you do it, make sure you have an available copy of your original initrd file, in case you have created some damage.

cd /tmp/initrd

find . | cpio -o -H newc | gzip -9 > /boot/initrd.img

This line packages the initrd, and replaces the old one.

That’s all for today 🙂

Quick and dirty – modifying Boel initrd files manually

Monday, July 2nd, 2007

Boel initrd files are actually compressed cramfs files. This is a menuscript for authoring and modifying these files, if needed. Assume the file in question is /tftpboot/install-initrd-i386.img:

cp /tftpboot/install-initrd-i386.img /tmp/
cd /tmp/
gzip -S .img -d install-initrd-i386.img
mount -o loop install-initrd-i386 /mnt
mkdir initrd
cd /mnt/
tar cf – . | (cd /tmp/initrd/ ; tar vxf -) # expect errors about time. It’s OK.

cd /tmp/
umount /mnt

Here you can modify the contents of /tmp/initrd for your needs. When done, continue.

mkcramfs initrd initrd.cramfs
cat initrd.cramfs | gzip -9 > initrd.modified.img

Now you can copy the file /tmp/initrd.modified.img to your /tftpboot directory.

Warning – Never delete your original initrd, in case you made a mistake and need to go back in time.

Enjoy.

Update – Netboot on RHEL x86 (32bit) with Broadcom (tg3) – no network

Sunday, August 27th, 2006

In my post just below, I have defined a set of tests to verify the possible cause of the tg3 problem. It had nothing to do with autoneg, and was fixed in RHEL 4 Update 4. That 32bit installer works correctly.

One last thing to test – rebuild the installer initrd, and replace tg3 module by one built from source (for example, HP’s tg3 drivers from the Proliant Support Pack) for this kernel. I wonder if it will work.