Tiny Core Linux

General TC => General TC Talk => Topic started by: edmazing on February 24, 2026, 08:47:45 PM

Title: Bulding the kernel from source and making an ISO?
Post by: edmazing on February 24, 2026, 08:47:45 PM
I'm looking to add P9 support to the kernel (So I can hopefully run gcc as a tiny C++ compiler on V86, ). Thus recompiling it from source.

I found the kernel source over at https://distro.ibiblio.org/tinycorelinux/17.x/x86/release/src/kernel/
Ran wget for the tar.gz and configure files.
Extracted the tar.gz and copied the configure file as a .config.
Then did make menuconfig, under network support added Plan 9 Sharing Support (9P2000)
Then Filesystems -> Network File Systems -> Plan 9 Resource sharing Support (9P2000) (Unsure if the access control or security labels are needed.)

Ran make. It took about two hours but it compiled just fine.
How exactly would I package the result into an ISO?
I think I should be able to manage to add gcc and the other bloat to make it into a tiny compiler environment.

Title: Re: Bulding the kernel from source and making an ISO?
Post by: Rich on February 24, 2026, 10:20:44 PM
Hi edmazing
Welcome to the forum.

I take it you want to create a bootable ISO. This deals with making an ISO that
can boot multiple versions of Tinycore, but should provide sufficient information
for creating your own ISO:
https://forum.tinycorelinux.net/index.php/topic,27848.msg180072.html#msg180072
Title: Re: Bulding the kernel from source and making an ISO?
Post by: edmazing on February 25, 2026, 02:36:09 AM
Thanks for the warm welcome.

That does indeed create an ISO nicely.
I'm just not sure how to create core.gz and vmlinuz with the required P9 support. I can get a bzimage and vmlinux file. If I take the current kernel source and compile it.

Make isoimage in the kernel source doesn't seem to produce a file that works as expected. I think it'd be because my host is ubuntu.
Sorry if compiling from source has been asked before.
Title: Re: Bulding the kernel from source and making an ISO?
Post by: Juanito on February 25, 2026, 04:41:55 AM
You would perhaps be better off compiling the kernel natively on tinycore.

Core is comprised of rootfs.gz, modules.gz and vmlinuz (core.gz = rootfs.gz + modules.gz)
CorePure64 is comprised of rootfs64.gz, modules64.gz and vmlinuz64 (corepure64.gz = rootfs64.gz + modules64.gz)

You don't need to touch rootfs.gz/rootfs64.gz
You can replace vmlinuz/vmlinuz64 with the bzImage you compiled
You would probably need to replace the contents of modules.gz/modules64.gz with the modules you compiled
Title: Re: Bulding the kernel from source and making an ISO?
Post by: Rich on February 25, 2026, 10:01:14 AM
Hi edmazing
If you want to compile natively on Tinycore, you need to install  compiletc.tcz.
Title: Re: Bulding the kernel from source and making an ISO?
Post by: edmazing on February 27, 2026, 07:46:38 PM
Core is comprised of rootfs.gz, modules.gz and vmlinuz (core.gz = rootfs.gz + modules.gz)

Ah that's good info.
I found an old guide.
https://wiki.tinycorelinux.net/doku.php?id=wiki:custom_kernel

Anywho I've got a native tinycore running off a liveUSB flashed with RUFUS.
I learned my BIOS has an option for changing USB to legacy boot.

So what files do I need exactly? I've got a bunch of folders, arch block certs, etc.
Title: Re: Bulding the kernel from source and making an ISO?
Post by: Juanito on February 28, 2026, 04:11:20 AM
So what files do I need exactly? I've got a bunch of folders, arch block certs, etc.

What files do you need exactly for what?

To compile a kernel on tinycore?
To replace the existing modules in modules.gz?
To create a bootable tinycore iso?
Title: Re: Bulding the kernel from source and making an ISO?
Post by: edmazing on February 28, 2026, 06:02:37 AM
To replace the existing modules.

And just to double check, I can rename bzImage to vmlinuz (It's not vmlinux that needs to be renamed to just replace it with a z.)
I'll try and just use the same folders that exist in modules.gz matching the style for 9pnet_virtio.ko.gz

Hmm surely I'm doing something wrong yet. It'll boot to menu, but then kernel panics
Not syncing: VFS: unable to mount root fs on unknown-block(2,0)

Trying to mimic the testISO... I must have something wrong, since the testISO boots up fine.

Edit: I think I've got the compressing part of things wrong.
Using core.gz as provided under distribution files works.

If I uncompress core.gz and recompress it with sudo tar -zcvf
It'll panic. If I don't use sudo then the tar command mentions at the end
Tar: exiting with failure status due to previous errors, but nothing stands out as an error.
Title: Re: Bulding the kernel from source and making an ISO?
Post by: Juanito on February 28, 2026, 06:37:06 AM
You don't particularly need to rename bzImage to vmlinuz as long as your boot loader references bzImage.

To unpack modules.gz:
Code: [Select]
cp modules.gz /tmp
cd /tmp
mkdir extract
cd extract
zcat /tmp/modules.gz | sudo cpio -i -H newc -d

replace the modules under /tmp/extract/lib/modules with your newly compiled modules and add the additional ones

Move your original modules.gz from /tmp to a safe place

Pack things up again:
Code: [Select]
find | sudo cpio -o -H newc | gzip -2 > ../modules.gz
cd /tmp
advdef -z4 modules.gz
Title: Re: Bulding the kernel from source and making an ISO?
Post by: edmazing on February 28, 2026, 11:08:37 PM
That worked.

How are the individual module files compressed? If I just run g-zip then the kernel seems to hang. If I use

Code: [Select]
advdef -z4 9pnet_virtio.ko.gz then modinfo says short read, so I'm guessing that's not the thing to do.
I've got one built in module kernel/fs/9p/9p.ko (I'm guessing that gets packed into the bzImage so I don't actually need to compress anything there)
And one module I added to the modules.order
Code: [Select]
kernel/net/9p/9pnet_virtio.ko
Perhaps there's something more I need to do to load and use the 9p file system.
Title: Re: Bulding the kernel from source and making an ISO?
Post by: edmazing on March 01, 2026, 12:03:45 AM
Ah I got it

Code: [Select]
sudo insmod /lib/modules/6.18.2-tinycore/kernel/net/9p/9pnet_virtio.ko Then
Code: [Select]
sudo mount -t 9p -o trans=virtio,version=9p2000.L host9p /mnt/9p/ not sure what I did to mess up the module but now it reads the gz one with modinfo just fine.

I suppose now I'll have to try and figure out how to make it do that on init. The iso is really nicely setup so modules are easy to add.
Title: Re: Bulding the kernel from source and making an ISO?
Post by: Juanito on March 01, 2026, 05:07:06 AM
I suppose now I'll have to try and figure out how to make it do that on init.

Since you added kernel modules to modules.gz, you'll need to update things - something like this:
Code: [Select]
sudo depmod -a -b /tmp/extract 6.18.2-tinycore
This will update /tmp/extract/lib/modules/6.18.2-tinycore/modules.dep and maybe modules.alias - note that I don't think that modules.builtin, modules.builtin.modinfo and modules.order, present in tc-17.x, but not previous versions, are required, but I need to check.