Discussion:
modified initrd for setup gives kernel panic
(too old to reply)
K. Venken
2019-11-19 20:32:08 UTC
Permalink
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.

The Slackware version used is current (actually from 20190917). I burned
it on a DVD and succesfully installed from the DVD. I setup dnsmasq with
tftpboot to which I copied the files from DVD. Without modification, I
can boot another system over the network and run the installer. Trying
to add some files in initrd fails however.

This is what I did:

Copy the existing initrd from DVD or whatever directory the current
version is mirrored (call it $DISTRO):

# cd /tmp
# cp $DISTRO/isolinux/initrd.img .

Now I noticed that since 14.2, the compression has changed to xz:

# file initrd.img
initrd.img: XZ compressed data

Decompressing can only be done after fixing the subscript:

# mv initrd.img initrd.xz
# xz -kd initrd.xz

The new file initrd is as expected a cpio archive:

# file initrd
initrd: ASCII cpio archive (SVR4 with no CRC)

Which can be extracted in a subdirectory:

# mkdir initrd.tmp
# cd initrd.tmp
# cpio -id <../initrd
160839 blocks

At this point I can browse the files and in ./scripts. There is a file
network.sh where I wanted to add my own file. I skipped this for now.

The next steps are to pack the initrd again. This goes like:

# find . | cpio -o --format=newc >../initrd.2
160839 blocks

This looks OK, checking the filesize gives the same size:

# cd ..
# ls -l -d initrd*
-rw-r--r-- 1 root root 82349568 Nov 19 20:56 initrd
-rw-r--r-- 1 root root 82349568 Nov 19 21:06 initrd.2
drwxr-xr-x 20 root root 4096 Nov 19 21:02 initrd.tmp
-rw-r--r-- 1 root root 38147436 Nov 19 20:56 initrd.xz

Next, compress:

# xz -kz initrd.2

At this point it gets suspicious, the filesizes differ:

# ls -l -d initrd*
-rw-r--r-- 1 root root 82349568 Nov 19 20:56 initrd
-rw-r--r-- 1 root root 82349568 Nov 19 21:06 initrd.2
-rw-r--r-- 1 root root 38902212 Nov 19 21:06 initrd.2.xz
drwxr-xr-x 20 root root 4096 Nov 19 21:02 initrd.tmp
-rw-r--r-- 1 root root 38147436 Nov 19 20:56 initrd.xz

Using this initrd.2.xz as initrd.img, I get the boot prompt, kernel
loads and then aborts with a kernel panic.

Actually, I verified with Midnight Commander that I can enter the new
initrd.img just like the other one, suggesting that the file is OK.

So I am wondering if the "boot-stuff" has specific requirements for
compression? I tried xz with --format=raw but this changes nothing.

What's more. I used the same kind of setup with 14.2 and there it was
OK, but 14.2 uses gz compression in stead of xz.
Jerry Peters
2019-11-19 21:31:59 UTC
Permalink
Post by K. Venken
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.
The Slackware version used is current (actually from 20190917). I burned
it on a DVD and succesfully installed from the DVD. I setup dnsmasq with
tftpboot to which I copied the files from DVD. Without modification, I
can boot another system over the network and run the installer. Trying
to add some files in initrd fails however.
Copy the existing initrd from DVD or whatever directory the current
# cd /tmp
# cp $DISTRO/isolinux/initrd.img .
# file initrd.img
initrd.img: XZ compressed data
# mv initrd.img initrd.xz
# xz -kd initrd.xz
# file initrd
initrd: ASCII cpio archive (SVR4 with no CRC)
# mkdir initrd.tmp
# cd initrd.tmp
# cpio -id <../initrd
160839 blocks
At this point I can browse the files and in ./scripts. There is a file
network.sh where I wanted to add my own file. I skipped this for now.
# find . | cpio -o --format=newc >../initrd.2
160839 blocks
# cd ..
# ls -l -d initrd*
-rw-r--r-- 1 root root 82349568 Nov 19 20:56 initrd
-rw-r--r-- 1 root root 82349568 Nov 19 21:06 initrd.2
drwxr-xr-x 20 root root 4096 Nov 19 21:02 initrd.tmp
-rw-r--r-- 1 root root 38147436 Nov 19 20:56 initrd.xz
# xz -kz initrd.2
# ls -l -d initrd*
-rw-r--r-- 1 root root 82349568 Nov 19 20:56 initrd
-rw-r--r-- 1 root root 82349568 Nov 19 21:06 initrd.2
-rw-r--r-- 1 root root 38902212 Nov 19 21:06 initrd.2.xz
drwxr-xr-x 20 root root 4096 Nov 19 21:02 initrd.tmp
-rw-r--r-- 1 root root 38147436 Nov 19 20:56 initrd.xz
Using this initrd.2.xz as initrd.img, I get the boot prompt, kernel
loads and then aborts with a kernel panic.
Actually, I verified with Midnight Commander that I can enter the new
initrd.img just like the other one, suggesting that the file is OK.
So I am wondering if the "boot-stuff" has specific requirements for
compression? I tried xz with --format=raw but this changes nothing.
What's more. I used the same kind of setup with 14.2 and there it was
OK, but 14.2 uses gz compression in stead of xz.
Try your new initrd without compressing it, if it still fails, then
the compression is eliminated as a problem.
K Venken
2019-11-20 07:23:34 UTC
Permalink
Post by Jerry Peters
Post by K. Venken
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.
The Slackware version used is current (actually from 20190917). I burned
it on a DVD and succesfully installed from the DVD. I setup dnsmasq with
tftpboot to which I copied the files from DVD. Without modification, I
can boot another system over the network and run the installer. Trying
to add some files in initrd fails however.
Copy the existing initrd from DVD or whatever directory the current
# cd /tmp
# cp $DISTRO/isolinux/initrd.img .
# file initrd.img
initrd.img: XZ compressed data
# mv initrd.img initrd.xz
# xz -kd initrd.xz
# file initrd
initrd: ASCII cpio archive (SVR4 with no CRC)
# mkdir initrd.tmp
# cd initrd.tmp
# cpio -id <../initrd
160839 blocks
At this point I can browse the files and in ./scripts. There is a file
network.sh where I wanted to add my own file. I skipped this for now.
# find . | cpio -o --format=newc >../initrd.2
160839 blocks
# cd ..
# ls -l -d initrd*
-rw-r--r-- 1 root root 82349568 Nov 19 20:56 initrd
-rw-r--r-- 1 root root 82349568 Nov 19 21:06 initrd.2
drwxr-xr-x 20 root root 4096 Nov 19 21:02 initrd.tmp
-rw-r--r-- 1 root root 38147436 Nov 19 20:56 initrd.xz
# xz -kz initrd.2
# ls -l -d initrd*
-rw-r--r-- 1 root root 82349568 Nov 19 20:56 initrd
-rw-r--r-- 1 root root 82349568 Nov 19 21:06 initrd.2
-rw-r--r-- 1 root root 38902212 Nov 19 21:06 initrd.2.xz
drwxr-xr-x 20 root root 4096 Nov 19 21:02 initrd.tmp
-rw-r--r-- 1 root root 38147436 Nov 19 20:56 initrd.xz
Using this initrd.2.xz as initrd.img, I get the boot prompt, kernel
loads and then aborts with a kernel panic.
Actually, I verified with Midnight Commander that I can enter the new
initrd.img just like the other one, suggesting that the file is OK.
So I am wondering if the "boot-stuff" has specific requirements for
compression? I tried xz with --format=raw but this changes nothing.
What's more. I used the same kind of setup with 14.2 and there it was
OK, but 14.2 uses gz compression in stead of xz.
Try your new initrd without compressing it, if it still fails, then
the compression is eliminated as a problem.
Yes that works, thanks for the tip! I can see the added files after
booting. This solves my problem in the sense that I can continue, but it
keeps me bothering why xz compression, the way I use it, fails.
Jerry Peters
2019-11-20 21:23:25 UTC
Permalink
Post by K Venken
Post by Jerry Peters
Post by K. Venken
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.
Try your new initrd without compressing it, if it still fails, then
the compression is eliminated as a problem.
Yes that works, thanks for the tip! I can see the added files after
booting. This solves my problem in the sense that I can continue, but it
keeps me bothering why xz compression, the way I use it, fails.
Glad to be of help. BTW, you could also build yourself a small initrd
that puts your modified files in the right place and load it after the
supplied initrd or concatenate it to the supplied initrd. The kernel
will load as many possibly compressed cpio archives as it finds,
either as a single file (or multiple files as long as the bootloader
supports multiple initrd's).

lzma has a lot of options and early boot can be picky about what it
supports. You could perhaps use gzip, or get the mkinitrd source
package and see what's special about it. I still use gzip for the
kernel and initrd's.
K. Venken
2019-11-21 21:45:53 UTC
Permalink
Post by Jerry Peters
Post by K Venken
Post by Jerry Peters
Post by K. Venken
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.
Try your new initrd without compressing it, if it still fails, then
the compression is eliminated as a problem.
Yes that works, thanks for the tip! I can see the added files after
booting. This solves my problem in the sense that I can continue, but it
keeps me bothering why xz compression, the way I use it, fails.
Glad to be of help. BTW, you could also build yourself a small initrd
that puts your modified files in the right place and load it after the
supplied initrd or concatenate it to the supplied initrd. The kernel
will load as many possibly compressed cpio archives as it finds,
either as a single file (or multiple files as long as the bootloader
supports multiple initrd's).
Interesting, I didn't realize that. I want to start my script
automatically, so I need to change the /etc/rc.d/rc.S in the existing
one anyway.
Post by Jerry Peters
lzma has a lot of options and early boot can be picky about what it
supports. You could perhaps use gzip, or get the mkinitrd source
package and see what's special about it. I still use gzip for the
kernel and initrd's.
As it was in 14.2. It's an option to try.
Jerry Peters
2019-11-22 21:12:13 UTC
Permalink
Post by K. Venken
Post by Jerry Peters
Post by K Venken
Post by Jerry Peters
Post by K. Venken
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.
Try your new initrd without compressing it, if it still fails, then
the compression is eliminated as a problem.
Yes that works, thanks for the tip! I can see the added files after
booting. This solves my problem in the sense that I can continue, but it
keeps me bothering why xz compression, the way I use it, fails.
Glad to be of help. BTW, you could also build yourself a small initrd
that puts your modified files in the right place and load it after the
supplied initrd or concatenate it to the supplied initrd. The kernel
will load as many possibly compressed cpio archives as it finds,
either as a single file (or multiple files as long as the bootloader
supports multiple initrd's).
Interesting, I didn't realize that. I want to start my script
automatically, so I need to change the /etc/rc.d/rc.S in the existing
one anyway.
Post by Jerry Peters
lzma has a lot of options and early boot can be picky about what it
supports. You could perhaps use gzip, or get the mkinitrd source
package and see what's special about it. I still use gzip for the
kernel and initrd's.
As it was in 14.2. It's an option to try.
Try changing the lzma CRC options first. I *very* vaguely remember
something about the default CRC being the wrong type, like 16 bits
instead of 32 for the kernel decompressor.
Jerry Peters
2019-11-25 21:17:44 UTC
Permalink
Post by Jerry Peters
Post by K. Venken
Post by Jerry Peters
Post by K Venken
Post by Jerry Peters
Post by K. Venken
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.
Try your new initrd without compressing it, if it still fails, then
the compression is eliminated as a problem.
Yes that works, thanks for the tip! I can see the added files after
booting. This solves my problem in the sense that I can continue, but it
keeps me bothering why xz compression, the way I use it, fails.
Glad to be of help. BTW, you could also build yourself a small initrd
that puts your modified files in the right place and load it after the
supplied initrd or concatenate it to the supplied initrd. The kernel
will load as many possibly compressed cpio archives as it finds,
either as a single file (or multiple files as long as the bootloader
supports multiple initrd's).
Interesting, I didn't realize that. I want to start my script
automatically, so I need to change the /etc/rc.d/rc.S in the existing
one anyway.
Post by Jerry Peters
lzma has a lot of options and early boot can be picky about what it
supports. You could perhaps use gzip, or get the mkinitrd source
package and see what's special about it. I still use gzip for the
kernel and initrd's.
As it was in 14.2. It's an option to try.
Try changing the lzma CRC options first. I *very* vaguely remember
something about the default CRC being the wrong type, like 16 bits
instead of 32 for the kernel decompressor.
It is indeed crc, the kernel decompressor only recognizes crc32.
K. Venken
2019-11-26 19:19:21 UTC
Permalink
Post by Jerry Peters
Post by Jerry Peters
Post by K. Venken
Post by Jerry Peters
Post by K Venken
Post by Jerry Peters
Post by K. Venken
I was trying to modify the initrd to add my own script, but the modified
version gives a kernel panic.
Try your new initrd without compressing it, if it still fails, then
the compression is eliminated as a problem.
Yes that works, thanks for the tip! I can see the added files after
booting. This solves my problem in the sense that I can continue, but it
keeps me bothering why xz compression, the way I use it, fails.
Glad to be of help. BTW, you could also build yourself a small initrd
that puts your modified files in the right place and load it after the
supplied initrd or concatenate it to the supplied initrd. The kernel
will load as many possibly compressed cpio archives as it finds,
either as a single file (or multiple files as long as the bootloader
supports multiple initrd's).
Interesting, I didn't realize that. I want to start my script
automatically, so I need to change the /etc/rc.d/rc.S in the existing
one anyway.
Post by Jerry Peters
lzma has a lot of options and early boot can be picky about what it
supports. You could perhaps use gzip, or get the mkinitrd source
package and see what's special about it. I still use gzip for the
kernel and initrd's.
As it was in 14.2. It's an option to try.
Try changing the lzma CRC options first. I *very* vaguely remember
something about the default CRC being the wrong type, like 16 bits
instead of 32 for the kernel decompressor.
It is indeed crc, the kernel decompressor only recognizes crc32.
Thanks for the information. Good to know. So far I have been using gzip
now which works as well.

Loading...