Cutom tinycore

From RobotinoWiki


Based on [1]

sudo apt install qemu-utils qemu-system-x86 grub-pc-bin

mkdir tinycore
cd tinycore

qemu-img create -f qcow2 core-image.img 64M

Mount the image

sudo modprobe nbd max_part=8
sudo qemu-nbd -c /dev/nbd0 core-image.img
sudo mkdir /media/cdrom
sudo mount TinyCore-current.iso /media/cdrom

sudo fdisk /dev/nbd0

sudo mkfs.ext2 /dev/nbd0p1

sudo mkdir /media/image
sudo mount /dev/nbd0p1 /media/image

sudo mkdir /media/image/boot
sudo mkdir -p /media/image/tce/optional

sudo cp /media/cdrom/boot/core.gz /media/image/boot/
sudo cp /media/cdrom/boot/vmlinuz /media/image/boot/
sudo touch /media/image/tce/onboot.lst

sudo grub-install --boot-directory=/media/image/boot /dev/nbd0

Unmount the image

sudo umount /dev/nbd0p1
sudo qemu-nbd -d /dev/nbd0
qemu-system-i386 core-image.img

linux (hd0,msdos1)/boot/vmlinuz
initrd (hd0,msdos1)/boot/core.gz

sudo qemu-nbd -c /dev/nbd0 core-image.img
sudo mount /dev/nbd0p1 /media/image

sudo bash -c "cat <<EOF > /media/image/boot/grub/grub.cfg
set timeout=3
set root='hd0,msdos1'
menuentry 'Boot TinyCore' {
    linux /boot/vmlinuz waitusb=5 superuser
    initrd /boot/core.gz

If you want to pass the boot process some arguments, append them after the path to the linux kernel. TinyCore supports a bunch of those, here are some of the more useful:

Parameter Usage Example Effect
waitusb waitusb=5 Wait for USB devices to become ready before mounting. This might help if the image fails to load its extensions.
norestore norestore Do not restore from persistence file (explained later in this guide)
lst lst=ext.lst Load extensions specified by ext.lst
superuser superuser Start with a root shell
quiet quiet Suppress much of the debug information during boot

qemu networking

echo "allow virbr0" > /etc/qemu/bridge.conf

sudo qemu-system-i386 core-image.img -net bridge,br=virbr0 -net nic,model=virtio

Use nm-connection-editor to configure virbr0


tce-load -wi compiletc squashfs-tools submitqc

Setup permissions

cd /tmp/robotinorestore
chown -R root:root .
chown tc:staff usr/local/tce.installed/robotinorestore
chmod 755 usr/local/etc/profile.d/
chmod 755 usr/local/tce.installed/robotinorestore
find -L . \
  \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
    -o -perm 511 \) -exec chmod 755 {} \; -o \
  \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
    -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
chown root:staff usr/local/tce.installed
chmod 775 usr/local/tce.installed

Build extension

mksquashfs /tmp/robotinorestore/ /tmp/robotinorestore.tcz

Make ISO image

tar xvf syslinux-6.03.tar.gz
mkdir tinycore-cdrom

cp syslinux-6.03/bios/core/isolinux.bin tinycore-cdrom/isolinux/
cp syslinux-6.03/bios/com32/elflink/ldlinux/ldlinux.c32 tinycore-cdrom/isolinux/

cat <<EOF > tinycore-cdrom/isolinux/isolinux.cfg
display boot.msg
default microcore
label microcore
	kernel /boot/vmlinuz
	initrd /boot/core.gz
	append loglevel=3 nofstab

label mc
	kernel /boot/vmlinuz
	append initrd=/boot/core.gz loglevel=3
implicit 0	
prompt 1	
timeout 5
F1 boot.msg
F2 f2
F3 f3
F4 f4

xorriso -as mkisofs -iso-level 3 -full-iso9660-filenames -volid "Robotino4Inst" \
        -eltorito-boot isolinux/isolinux.bin -boot-load-size 4 \
        -eltorito-catalog isolinux/ -boot-info-table \
        -no-emul-boot -output "CoreCustom20210922.iso" "tinycore-cdrom"