Difference between revisions of "Cutom tinycore"

From RobotinoWiki
(Make ISO image)
 
(34 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
==Overview==
 +
Based on [https://fabianstumpf.de/articles/tinycore_images.htm]
 +
 
<pre>
 
<pre>
 +
sudo apt install qemu-utils qemu-system-x86 grub-pc-bin
 +
 
mkdir tinycore
 
mkdir tinycore
 
cd tinycore
 
cd tinycore
Line 5: Line 10:
  
 
qemu-img create -f qcow2 core-image.img 64M
 
qemu-img create -f qcow2 core-image.img 64M
 +
</pre>
  
 +
==Mount the image==
 +
<pre>
 
sudo modprobe nbd max_part=8
 
sudo modprobe nbd max_part=8
 
sudo qemu-nbd -c /dev/nbd0 core-image.img
 
sudo qemu-nbd -c /dev/nbd0 core-image.img
 +
</pre>
  
 +
<pre>
 
sudo mkdir /media/cdrom
 
sudo mkdir /media/cdrom
 
sudo mount TinyCore-current.iso /media/cdrom
 
sudo mount TinyCore-current.iso /media/cdrom
Line 33: Line 43:
 
sudo touch /media/image/tce/onboot.lst
 
sudo touch /media/image/tce/onboot.lst
  
sudo apt install grub-pc-bin
 
 
sudo grub-install --boot-directory=/media/image/boot /dev/nbd0
 
sudo grub-install --boot-directory=/media/image/boot /dev/nbd0
 +
</pre>
 +
 +
==Unmount the image==
 +
<pre>
 +
sudo umount /dev/nbd0p1
 +
sudo qemu-nbd -d /dev/nbd0
 +
</pre>
 +
 +
<pre>
 +
qemu-system-i386 core-image.img
 +
 +
linux (hd0,msdos1)/boot/vmlinuz
 +
initrd (hd0,msdos1)/boot/core.gz
 +
boot
 +
 +
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
 +
}
 +
EOF"
 +
 +
</pre>
 +
 +
If you want to pass the boot process some arguments, append them after the path to the linux kernel. TinyCore supports a [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes bunch of those], here are some of the more useful:
 +
 +
{| border="1"
 +
!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==
 +
<pre>
 +
echo "allow virbr0" > /etc/qemu/bridge.conf
 +
 +
sudo qemu-system-i386 core-image.img -net bridge,br=virbr0 -net nic,model=virtio
 +
</pre>
 +
 +
Use nm-connection-editor to configure virbr0
 +
 +
==robotinorestore==
 +
<pre>
 +
tce-load -wi compiletc squashfs-tools submitqc
 +
</pre>
 +
 +
==Setup permissions==
 +
<pre>
 +
cd /tmp/robotinorestore
 +
chown -R root:root .
 +
chown tc:staff usr/local/tce.installed/robotinorestore
 +
chmod 755 usr/local/etc/profile.d/robotinorestore.sh
 +
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
 +
</pre>
 +
 +
==Build extension==
 +
<pre>
 +
mksquashfs /tmp/robotinorestore/ /tmp/robotinorestore.tcz
 +
</pre>
 +
 +
==Make ISO image==
 +
<pre>
 +
wget https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz
 +
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
 +
EOF
 +
 +
xorriso -as mkisofs -iso-level 3 -full-iso9660-filenames -volid "Robotino4Inst" \
 +
        -eltorito-boot isolinux/isolinux.bin -boot-load-size 4 \
 +
        -eltorito-catalog isolinux/boot.cat -boot-info-table \
 +
        -no-emul-boot -output "CoreCustom20210922.iso" "tinycore-cdrom"
 
</pre>
 
</pre>

Latest revision as of 11:25, 22 September 2021

Overview

Based on [1]

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

mkdir tinycore
cd tinycore
wget http://tinycorelinux.net/12.x/x86/release/TinyCore-current.iso

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
n
p
1
enter
enter
p
w

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
boot

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
}
EOF"

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

robotinorestore

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/robotinorestore.sh
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

wget https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz
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
EOF

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