Article 5JTCF Merging duplicate initrd.img and kernel files

Merging duplicate initrd.img and kernel files

by
andygoth
from LinuxQuestions.org on (#5JTCF)
The Slackware64 file tree contains two identical copies of initrd.img. It also has two identical kernels, albeit with different names:

Code:$ ls -l $(find -name initrd.img) EFI/BOOT/huge.s kernels/huge.s/bzImage
-rw-r--r-- 1 root root 48023372 Jun 7 00:16 ./EFI/BOOT/initrd.img
-rw-r--r-- 1 root root 48023372 Jun 7 00:16 ./isolinux/initrd.img
-rw-r--r-- 1 root root 10744608 Jun 4 15:13 EFI/BOOT/huge.s
-rw-r--r-- 1 root root 10744608 Jun 4 15:13 kernels/huge.s/bzImage
$ sha1sum $(find -name initrd.img) EFI/BOOT/huge.s kernels/huge.s/bzImage
94e3ea10791bbd70c4a8e71f78e3effa98d55fde ./EFI/BOOT/initrd.img
94e3ea10791bbd70c4a8e71f78e3effa98d55fde ./isolinux/initrd.img
60a5ca08172ba756823a9c5bea4e54259e5b944b EFI/BOOT/huge.s
60a5ca08172ba756823a9c5bea4e54259e5b944b kernels/huge.s/bzImageThis means every time I update my local mirror and there's been a kernel/initrd update, I have to download 56 megabytes of duplicate data.

Can we eliminate the EFI copy of initrd.img and huge.s from the file tree and, in its place, modify the xorriso call in isolinux/README.TXT to use graft points? Like so:

Code:xorriso -as mkisofs \
[... see README.TXT for the rest ...]
-output /tmp/slackware-dvd.iso \
-graft-points \
. \
EFI/BOOT/initrd.img=isolinux/initrd.img \
EFI/BOOT/huge.s=kernels/huge.s/bzImageEdit: It would be good to add a README.TXT to EFI/BOOT to explain that it will be populated with initrd.img and bzImage when the image is created with the command line found in isolinux/README.TXT.

There's also usb-and-pxe-installers/usbboot.img, but it is distinct and needs to stay that way. initrd.img and bzImage, however, are low-hanging fruit when it comes to reducing bandwidth and disk storage needs for mirrors.

As an added bonus, at least with xorriso (not sure about true-blue mkisofs), this reduces the resultant disc image by 57.2 megabytes (I measured, will obviously change along with initrd.img and huge.s). I assume the grafted filenames get mapped to the same LBA. I can dive into the ISO9660 structures to confirm if need be, but I think it's self-evident. Anyway, this will be a savings for people who download, mirror, or burn the ISO images, even if they don't care about the file tree. I imagine this will encompass the majority of Slackware end users.

Mounting the disc images created with and without -graft-points and then diff'ing their file trees shows no differences. The only difference I can spot is by listing directories with "ls -li": Even though the initrd.img and kernel files have distinct inodes, they have link counts of 2 rather than 1.

At long last, I have the answer to the ancient riddle: When is a hard link not a hard link?

I've been creating and booting custom installer images created in this manner for several months now (since January) and have had no issues. I did so because I've been making and using custom initrd.img files to add vmd and custom packages and scripts I wanted/needed during installation, before the first live boot, and I found graft points to be easier and safer than commingling my custom stuff throughout the mirrored tree, which would have necessitated carefully crafting my rsync command line to protect my files.

Actually I should qualify that statement. I didn't spot the opportunity to merge kernel files until this morning, but initrd merging I've been doing all year long. To make sure it's still good, I successfully booted a fresh image created with the above command line.

Edit 2: I booted using VirtualBox using both BIOS and EFI modes. Both worked.

This discussion applies only to 64-bit Slackware since the EFI directory doesn't appear on 32-bit Slackware.latest?d=yIl2AUoC8zA latest?i=6807tyjmm6Y:Z8Z3MCTYXS0:F7zBnMy latest?i=6807tyjmm6Y:Z8Z3MCTYXS0:V_sGLiP latest?d=qj6IDK7rITs latest?i=6807tyjmm6Y:Z8Z3MCTYXS0:gIN9vFw6807tyjmm6Y
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments