I know this is an old topic but came across it while I was looking for a way to add gpg keys to an openSUSE iso that was remastered to include several custom packages. I had some issues finding the information that I needed so I figured I would add some detailed instructions just in case someone else finds them useful. Different parts of these instructions were found on other sites. I just placed them together to form a detailed list. They do work which is what really matters.
I wrote them for modifying a local initrd instead of an initrd from an iso image but the process is the same.
Note: The instructions below are what I used for my system which is using /boot/initrd-3.16.7-24-desktop for its' initrd. The commands will need to be modified if your current initrd file is not /boot/initrd-3.16.7-24-desktop.
This is the procedure:
Do a long listing on /boot/initrd to see which file it is pointing to:
root@host:~ # ls -l /boot/initrd
lrwxrwxrwx 1 root root 24 Sep 10 10:08 /boot/initrd -> initrd-3.16.7-24-desktop
Create some directories to work in:
root@host:~ # mkdir -p -m 755 mod-initrd/new-initrd
Copy the current initrd to the working directory:
root@host:~ # cp /boot/initrd-3.16.7-24-desktop mod-initrd/initrd.xz
cd to the directory where the initrd will be extracted:
root@host:~/mod-initrd # cd mod-initrd/new-initrd
Extract the initrd:
root@host:~/mod-initrd/new-initrd # xzcat ../initrd.xz | cpio -d -i -m
Make the changes that you want to make.
Save a copy of the original initrd:
root@host:~/mod-initrd/new-initrd # mv ../initrd.xZ ../initrd-original
Compress the modified intird:
root@host:~/mod-initrd/new-initrd # find . | cpio -o -H newc | xz --check=crc32 --x86 --lzma2=dict=512KiB > ../initrd.xz
Replace the current initrd with the modified initrd. This will make the modified version active upon reboot.
root@host:~/mod-initrd/newinitrd # mv ../initrd.xz /boot/initrd-3.16.7-24-desktop
Reboot to test the changes that you made.
root@host:~/mod-initrd/new-initrd # init 6
Do not delete the extracted initrd until your changes have been tested. This way, if any adjustments need to be made steps 6, 8, 9, and 10 are all that are required.
For anyone trying to add their own GPG key to an openSUSE image so the key will be trusted automatically, this is one way it can be done:
Get the ID of your GPG key by running:
One of the lines should begin with something like this:
In the example above, the ID would be "BB6D5E99"
Export the public GPG key by running:
gpg --export -a "BB6D5E99" > "file-name-for-the-exported-key"
Add the gpg key to the extracted initrd by running:
echo "file-name-for-the-exported-key" | cpio -o -H newc -A -F "full-path-of-directory-holding-extracted-initrd"