Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Last active January 3, 2023 15:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save max-mapper/6dfa0d6fbe61ce75b00f to your computer and use it in GitHub Desktop.
Save max-mapper/6dfa0d6fbe61ce75b00f to your computer and use it in GitHub Desktop.
create a tinycorelinux fs with custom .tcz packages
# create a tinycorelinux fs with custom .tcz packages
# prerequisites: apt-get install squashfs-tools, npm i nugget -g
# dl release + packages (add your packages here)
nugget http://tinycorelinux.net/6.x/x86/release/TinyCore-current.iso http://tinycorelinux.net/6.x/x86/tcz/{nodejs,fuse,openssl-1.0.1,python,pkg-config,make,gcc,cloog,isl,gmp,mpfr,binutils,mpc,gcc_base-dev,gcc_libs-dev,gcc_libs,glibc_base-dev,linux-3.16.2_api_headers}.tcz -c
# node (add your packages here)
unsquashfs -f nodejs.tcz
unsquashfs -f openssl-1.0.1.tcz
# to support compiling addons
unsquashfs -f python.tcz
unsquashfs -f pkg-config.tcz
unsquashfs -f make.tcz
unsquashfs -f gcc.tcz
unsquashfs -f cloog.tcz
unsquashfs -f isl.tcz
unsquashfs -f gmp.tcz
unsquashfs -f mpfr.tcz
unsquashfs -f binutils.tcz
unsquashfs -f mpc.tcz
unsquashfs -f gcc_base-dev.tcz
unsquashfs -f gcc_libs-dev.tcz
unsquashfs -f gcc_libs.tcz
unsquashfs -f glibc_base-dev.tcz
unsquashfs -f linux-3.16.2_api_headers.tcz
# custom packages (add yours here)
unsquashfs -f fuse.tcz
# extract kernel, fs files from iso
sudo mkdir /mnt/tmp
sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro
cp /mnt/tmp/boot/vmlinuz vmlinuz
cp /mnt/tmp/boot/core.gz core.gz
sudo umount /mnt/tmp
sudo rm -rf /mnt/tmp
# extract core
mkdir core
( cd core ; zcat ../core.gz | sudo cpio -idm )
# setup python
sudo tar xzf squashfs-root/usr/local/share/python/files/files.tar.gz -C squashfs-root/
sudo ln -sf /usr/local/bin/python2.7 squashfs-root/usr/local/bin/python
# copy extracted packages into fs
sudo cp -Rp squashfs-root/usr/ core/
# enables terminal (i think, blindly copied from xhyve example)
sudo sed -i '/^# ttyS0$/s#^..##' core/etc/securetty
sudo sed -i '/^tty1:/s#tty1#ttyS0#g' core/etc/inittab
# repackage core into output.gz
( cd core ; find | sudo cpio -o -H newc ) | gzip -c > output.gz
# cleanup
sudo rm -rf squashfs-root/ core/
# now boot vmlinuz and output.gz like this https://github.com/mist64/xhyve/blob/cd782515fff03bd4b80da60e29108f6b33476bf5/xhyverun.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment