WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Creating a TinyCore initrd (for Core >= 4.2)  (Read 5277 times)

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Creating a TinyCore initrd (for Core >= 4.2)
« on: January 07, 2012, 08:56:00 PM »
As I found the single file initrd (i.e. 'tinycore.gz') quite convenient (e.g. for easier upgrades, or when using QEMU with the '-kernel ... -initrd ... -append ...' parameters) I've decided to throw together a quick script that creates such a file again:

Code: (bash) [Select]
#!/bin/sh

# a quick & dirty script to create a TinyCore initrd (for Core >= 4.2)

H=$( pwd )

M=$( mount | grep iso9660 | head -1 | awk '{print $3}' )
[ -z "$M" ] && echo "can not find mounted CD-ROM" && exit 1

D=$( mktemp -d )
cd $D

[ ! -f ${M}/boot/core.gz ] && "can not find initrd file" && exit 2
zcat ${M}/boot/core.gz | sudo cpio -idum

[ ! -f ${M}/cde/copy2fs.lst ] && "can not find copy2fs.lst file" && exit 3
T=$( mktemp -d )
cat ${M}/cde/copy2fs.lst | while read F ; do
    sudo mount ${M}/cde/optional/${F} $T || ! echo "can not mount $F" || exit 4
    sudo cp -a $T/* .
    umount -d $T || ! echo "can not umount $F" || exit 5
done
sudo rm -rf $T

sed -i '$i for F in /usr/local/tce.installed/* ; do sudo $F ; done' \
    opt/bootsync.sh

sudo find . | sudo cpio -odum -H newc \
    | gzip > "${H}/tinycore_$( cat /usr/share/doc/tc/release.txt ).gz"

cd "$H"
sudo rm -rf $D

Please note, that this script assumes that the system was booted from a CD-ROM (as I typically boot TC for a "fresh" Core system in QEMU by just using the ISO image). I'm not planning to broaden the scope, e.g. to support USB or disk based installations. The few commands used are IMHO so trivial that adaptations should be easy enough.

EDIT: I've now included a small change that ensures that the startup scripts of the "CDE extensions" are getting executed as part of the boot process. This should ensure that the required adjustments to configuration files (e.g. in '/etc/sysconfig' and the home directory) are been applied. I've got to admit that I had not tested the resulting initrd file well enough and this had been overlooked. There might be other oversights "lurking around", so I'm not suggesting that the resulting initrd is a "full replacement" for the 'tinycore.gz' file of the past.
« Last Edit: January 07, 2012, 09:49:01 PM by maro »