Tiny Core Linux
General TC => General TC Talk => Topic started by: GNUser on January 09, 2026, 03:29:03 PM
-
If I create an initramfs from two more components, like so...
$ cat modules64.gz rootfs64.gz > corepure64.gz
...then try to remaster the resulting initramfs like so...
$ sudo su -c "mkdir temp; cd temp; gunzip -c ../corepure64.gz | cpio -i"
30012 blocks
...I notice that only the contents of the first argument to cat (modules64.gz in this case) appear inside the temp directory.
Is there a way to remaster the entire corepure64.gz in this example (short of remastering its component parts then recreating corepure64.gz using cat)?
-
Does zcat work
zcat "${OLDINITRD}" | sudo cpio -i -H newc -d
-
Does zcat work
zcat "${OLDINITRD}" | sudo cpio -i -H newc -d
Hi Paul_123. zcat doesn't help:
$ cat modules64.gz rootfs64.gz > corepure64.gz
$ sudo su -c "mkdir temp; cd temp; zcat ../corepure64.gz | cpio -i -H newc -d"
30012 blocks
$ ls temp
lib/ usr/Note how only the contents of modules64.gz appear inside the temp directory.
-
Hi GNUser
Try this:
mkdir tempdir
cd tempdir
zcat /path/to/existing/rootfs.gz | sudo cpio -i
-
Hi GNUser
Try this:
mkdir tempdir
cd tempdir
zcat /path/to/existing/rootfs.gz | sudo cpio -i
Hi Rich. No luck with that, either:
$ cat modules64.gz rootfs64.gz > corepure64.gz
$ mkdir tempdir
$ cd tempdir
$ zcat ../corepure64.gz | sudo cpio -i
30012 blocks
$ ls
lib/ usr/Maybe there's a better way to create corepure64.gz from smaller initramfs'es than simply using cat.
EDIT: When a new version of TCL is released and corepure64.gz is posted, how does it get created? I have no problem remastering corepure64.gz from stable TCL releases. It's only corepure64.gz that I create using cat that misbehaves in this way.
-
It seems that using cat to combine initramfs'es results in an initramfs that is usable (for booting), but is not amenable to being remastered.
To combine initramfs'es in such a way that the result is both usable and remasterable, I wrote this little shell script for myself. I called it combine-initramfs . It can be placed anywhere in your PATH:
#!/bin/sh
# Purpose: Combine multiple initramfs'es into a single one that can be remastered later
# (just using cat results in an initramfs that does not seem amenable to being remastered)
#
# Usage example:
# $ combine-initramfs modules64.gz root64.gz
# 1. pool the contents of all initramfs arguments into temp dir
mkdir -p temp
for i in "$@"; do
i="$(realpath "$i")"
cd temp
zcat "$i" | sudo cpio -i
cd ..
done
# 2. create initramfs from temp dir
cd temp
sudo su -c "find . | cpio -H newc -o | gzip -9 > ../combined.gz"
sudo chown $(cat /etc/sysconfig/tcuser):staff ../combined.gz
# 3. clean up
cd ..
sudo rm -rf temp
Topic can be marked as Solved :)
-
Hi GNUser
This works:
tc@box:~/cat$ mkdir mnt
tc@box:~/cat$ cd mnt
tc@box:~/cat/mnt$ zcat ../initrd.gz | while sudo cpio -id; do :; doneThat's a colon semicolon sequence between do and done.
-
Hi GNUser
just a heads up about modules.gz:
tc@box:~/cat$ readlink mnt/lib/modules/6.1.2-tinycore64/kernel.tclocal
/usr/local/lib/modules/6.1.2-tinycore64/kernel/
The link is absolute to /usr/local/lib/modules/$KERNEL/kernel.
So if modules.gz is a match to the system you are running on, it
will point to your installed drivers once unpacked.
-
Maybe you can have a look at the source code for a tool (in Archlinux), which can extract both CPIO files from a init boot file
❯ ls -al /usr/bin/lsinitcpio
.rwxr-xr-x 12k root 23 Dez 2025 /usr/bin/lsinitcpio
~
❯ file /usr/bin/lsinitcpio
/usr/bin/lsinitcpio: Bourne-Again shell script, ASCII text executable
~ ❯ sudo lsinitcpio -a /boot/initramfs-linux.img ==> Image: /boot/initramfs-linux.img
==> Created with mkinitcpio 40
==> Kernel: 6.18.3-arch1-1
==> Early CPIO: 9.99 MiB
==> Size: 11.99 MiB
==> Compressed with: zstd
-> Uncompressed size: 30.58 MiB (.392 ratio)
-> Estimated decompression time: 0,082s
==> Included modules (38):
cec drm_gpuvm hid-multitouch intel-gtt mmc_core rpmb-core spi-pxa2xx-platform virtio_scsi
drm_buddy drm_suballoc_helper hkdf intel-lpss nvme serio_raw ttm wmi
drm_display_helper drm_ttm_helper i2c-algo-bit intel-lpss-pci nvme-auth spi-intel uas xe
drm_exec dw_dmac i915 intel-vsec nvme-core spi-intel-pci usb-storage
drm_gpusvm_helper gpu-sched idma64 mmc_block nvme-keyring spi-pxa2xx-core video
==> Included binaries (14):
blkid e2fsck kmod mount plymouthd switch_root udevadm
busybox fsck loginctl plymouth setfont systemd-tmpfiles umount
==> Early hook run order:
udev
❯ lsinitcpio -h
lsinitcpio 40
usage: lsinitcpio [action] [options] <initramfs>
Actions:
-a, --analyze analyze contents of image
-c, --config show configuration file image was built with
-l, --list list contents of the image (default)
-x, --extract extract image to disk
Options:
-h, --help display this help
-n, --nocolor disable colorized output
-V, --version display version information
-v, --verbose more verbose output
--cpio list or extract only the main CPIO image
--early list or extract only the early CPIO image
❯ sudo lsinitcpio -l --early /boot/initramfs-linux-cachyos.img
bin
early_cpio
kernel/
kernel/x86/
kernel/x86/microcode/
kernel/x86/microcode/GenuineIntel.bin <--here stop first cpio for ucode intel firmware
lib
lib64
sbin
usr/
usr/lib/
usr/lib/firmware/
-
Hi GNUser
This works:
tc@box:~/cat$ mkdir mnt
tc@box:~/cat$ cd mnt
tc@box:~/cat/mnt$ zcat ../initrd.gz | while sudo cpio -id; do :; doneThat's a colon semicolon sequence between do and done.
Hi Rich. That sure does work! I like it better than my solution (which was really not a solution but a workaround to combine initramfs'es without using cat).
The while loop in your solution is infinite--I have to send the loop SIGINT (Ctrl+c) when I notice that all components of the initrd have been extracted. Is there a way to avoid an infinite loop?
-
Hi GNUser
... Is there a way to avoid an infinite loop?
Yes. Switch to the GNU versions of zcat and/or cpio. It will then
spit out a bunch of warnings which can be silenced like this:
zcat ../initrd.gz | while sudo cpio -W none -id; do :; done
-
Hi Rich. That's just beautiful! I'm in your debt, as usual.
Happy hacking!
-
... Is there a way to avoid an infinite loop?
Yes. Switch to the GNU versions of zcat and/or cpio.
At the risk of stating the obvious:
Another way to avoid an infinite loop, while sticking to the default (busybox) versions of zcat and cpio, is to exit the loop after a certain number of iterations:
i=0
zcat ../initrd.gz | while [ $i -lt 10 ]; do sudo cpio -id; i=$((i+1)); done
The above assumes the user's initrd.gz was built by concatenating no more than 10 initramfs'es together, which seems like a reasonable assumption.
I think we can confidently mark the thread as Solved :)
-
Hi GNUser
... I think we can confidently mark the thread as Solved :)
So marked. ;D