All details on this page supplied by:-

https://majek.sh/en/initrd-in-slackware/

Install everything, setup lilo, timezones etc as usual. At the end DON’T reboot at the end of setup – system isn’t finished yet!

Now, it’s time to prepare new initrd.

Chroot to /mnt (where new system should be already mounted) Make copy of default mkinitrd config:

cp /etc/mkinitrd.conf.sample /etc/mkinitrd.conf

Edit new /etc/mkinitrd.conf with your favourite editor and set few options:

uncomment and set MODULE_LIST and ROOTFS to type of your root filesystem, for example

ROOTFS=“ext3”

MODULE_LIST=“ext3”

You don’t need to worry about all related modules, they will be added automatically.

if you use software raid, uncomment and set

RAID=“1” if you use lvm or encryption, uncomment and set

LVM=“1”

I strongly recommend to set SOURCE_TREE and OUTPUT_IMAGE to some more unique names, for example

SOURCE_TREE=“/boot/initrd-tree-3.10.12”

OUTPUT_IMAGE=“/boot/initrd-3.10.12.gz”

You don’t have to do this if you don’t want to play with custom kernels etc.

make new initrd with mkinitrd -F

add initrd image to lilo.conf adding it just after ‘image’ line, so it will look like this:

image = /boot/vmlinuz-generic-3.10.12
 initrd = /boot/initrd-3.10.12.gz
get out of chroot and rebuild lilo with:
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
lilo -r /mnt

Right now you could reboot system and enjoy new Slackware with initrd:-)

What’s an advantage of this way instead of running mkinitrd with many bizarre options? See next part.

Normal usage Sometimes you need to change kernel, upgrade or something like that.

There are 2 ways of maintaining Slackware with initrd:

Use one initrd for all kernels Use separate initrd for every kernel or even every entry in lilo One initrd for all At start, make sure that you have commented out CLEAR_TREE or set it to 0 in mkinitrd.conf!

After installation of new kernel and running still from old one, you need to to set KERNEL_VERSION to version of your new kernel, for example

KERNEL_VERSION=“3.17.4” Then just run mkinitrd -F That’s all about initrd – now image has required modules for both/all your kernels. Of course you need new entry in lilo.conf for new kernel with exactly the same initrd as old one. If you are making kernel upgrade (replace old kernel package) you don’t even need to touch lilo.conf. But in both cases, you must run lilo at the end.

From time to time, you could clean initrd tree from old modules from kernel you don’t use anymore. In this case just remove all directory with that modules from /boot/initrd-tree/lib/modules/old-kernel-version and regenerate initrd using as usual mkinitrd -F. And rerun lilo of course 🙂

Now, you probably see advantage of using mkinitrd.conf instead of remembering all those weird switches you used last time to generate this image.

Separate initrd for every kernel This way have a little sense if you only use one root filesystem and only stock kernel which you sometimes only upgrade.

Separate initrd is even easier than ‘one for all’ attitude. One drawback is that mkinitrd with -F flag only reads one default /etc/mkinitrd.conf file, so each time you have to copy saved configuration back to this file. So, for first kernel you should customize at least SOURCE_TREE, OUTPUT_IMAGE and KERNEL_VERSION. Generate new initrd with mkinitrd -F, then make backup of mkinitrd.conf to for example mkinitrd.conf.3.10.17. For next kernel with different options customize mkinitrd.conf again, create new initrd, make backup and so on. That way you could have different initrds and saved all options to regenerate each of them. It’s safe attitude as playing with new kernel and initrd configuration you always have working old one.

all content below here from:-

https://www.thegeekstuff.com/2009/07/how-to-view-modify-and-recreate-initrd-img/

How to View, Modify and Recreate initrd.img by SASIKALA on JULY 10, 2009 Question: How do I view, modify and recreate the new initrd.img on Ubuntu, Debian, CentOS, Fedora, Red-Hat, Arch Linux, or SUSE distributions?

1. How To View Content Of initrd.img file? initrd.img is in gzip format. So move initrd.img to initrd.gz as shown below.

# cp /tftpboot/el5/initrd.img .

# ls cdrom initrd.img

# mv initrd.img initrd.gz Unzip the initrd.gz file as shown below.

# gunzip initrd.gz

# ls cdrom initrd After unziping the initrd.gz file, the initrd is further in cpio ‘newc’ format. So extract the files from initrd using cpio ‘newc’ format as shown below. Note: info cpio will give more information about ‘newc’ format.

# mkdir tmp2

# cd tmp2/

# cpio -id < ../initrd 16524 blocks Now you can view the content of initrd.img file

# ls bin dev etc init modules proc sbin selinux sys tmp var 2. How To Modify Content of Image and Recreate New Image? After extracting the file as shown below, make appropriate modification to any of those files. Then pack the files back into the archive using the following commands. Pack the modified files back to cpio ‘newc’ format.

# find . | cpio –create –format='newc' > /tmp/newinitrd 16524 blocks

# ls /tmp/ cdrom initrd newinitrd tmp2

# ls -l /tmp/newinitrd -rw-r–r– 1 root root 8460288 Jul 2 14:50 /tmp/newinitrd Gzip the archive file.

# gzip newinitrd

# ls cdrom initrd newinitrd.gz tmp2

# ls -l newinitrd.gz -rw-r–r– 1 root root 6649867 Jul 2 14:50 newinitrd.gz Move file as an image file. You can use the newinitrd.img as your new boot image.

# mv newinitrd.gz newinitrd.img

# ls -l newinitrd.img -rw-r–r– 1 root root 6649867 Jul 2 14:50 newinitrd.img

all content below here from:-

https://access.redhat.com/solutions/24029

How to unpack/uncompress and repack/re-compress an initial ramdisk (initrd/initramfs) boot image file on RHEL 5,6 ? SOLUTION VERIFIED - Updated August 7 2024 at 7:03 AM - English Environment Red Hat Enterprise Linux 6 Red Hat Enterprise Linux 5 Note: For RHEL7 and RHEL8, refer to How to extract the contents of initramfs image on RHEL7?

Issue How do I unpack or uncompress, and then repack or re-compress, an initrd or initramfs boot image file? How do I modify the contents of an initrd or initramfs? How do I view an initrd or initramfs? Resolution First, create a temporary work directory and switch into it. This will be the location where the initramfs/initrd contents will be viewed, edited, and re-compressed if required:

Raw mkdir /tmp/initrd cd /tmp/initrd Identify compression format of the image Use the file command on the initramfs/initrd to identify the compression format:

Raw file /boot/initramfs-$(uname -r).img The $(uname -r) will use the file for the current kernel version. You may also specify a specific file, such as:

Raw file /boot/initramfs-2.6.32-754.el6.x86_64.img The most common is a gzip-format image which displays as:

Raw # file /boot/initramfs-$(uname -r).img /boot/initramfs-2.6.32-754.el6.x86_64.img: gzip compressed data However, there may also be an XZ/LZMA-format image which displays as:

Raw # file /boot/initramfs-$(uname -r).img /boot/initramfs-2.6.32-754.el6.x86_64.img: LZMA compressed data Select the appropriate instructions below to extract or repack the correct image type for your system.

gzip format - Extract / Uncompress Uncompress and extract the contents of the image in the /boot/ directory:

Raw zcat /boot/initrd-$(uname -r).img | cpio -idmv gzip format - Repack / Recompress Still in the working directory, find all files and add them to a new boot image file:

Raw find . | cpio -o -c -R root:root | gzip -9 > /boot/new.img xz/LZMA format - Extract / Uncompress Uncompress and extract the contents of the image in the /boot/ directory:

Raw xz -dc < /boot/initrd-$(uname -r).img | cpio -idmv xz/LZMA format - Repack / Recompress Still in the working directory, find all files and add them to a new boot image file:

Raw find . 2>/dev/null | cpio -o -c -R root:root | xz -9 –format=lzma > /boot/new.img