WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: My scripts to remaster tiny core  (Read 205 times)

Offline cshrout1

  • WikiUser
  • *
  • Posts: 11
My scripts to remaster tiny core
« on: October 05, 2018, 04:55:56 AM »
Hello all,

I figured I'd pop these up here. I made some very simple bash scripts that help to automate the process of remastering TC. I tend to add these scripts into /home when I remaster the TC install so that I'll always have them for use. I've also included some instruction for adding TCZ files and modifying the OS once it's been unpacked.


######Remastering the core.gz file:######

Boot into a pre-existing tiny-core image.
Once booted run fdisk -l to find the /dev/ that contains the OS partition which you just booted from.
ls /mnt to see the pre-existing mount points present in the OS
To mount the drive:
-sudo mount /dev/sdX1 /mnt/sdX1
-After the unpack script has been added to the remaster it will mount this for you if utilized. (Won't be an option the first time)
navigate to the core.gz file location

##Unpacking the OS##
-Use the attached Tiny_Core_Unpack.bash script to automate the unpack

Manual Steps:
-mkdir /tmp/extract1
-cd /tmp/extract1
-zcat /mnt/sdX1/boot/core.gz | sudo cpio -i -H newc -d
--NOTE: This will expand all the contents of core.gz (which is a cpio file) into the /tmp/extract1 directory
--This makes /tmp/extract1 the new root or "/" directory for remastered copy of tinycore that is being built.
--Add scripts, files, libraries and modify system config files in /tmp/extract1/ in order to change what will become the remastered tiny core version.

##Adding libraries##
If the /tmp/tce/optional directory doesn't already exist then create it:
-mkdir tmp/tce
-mkdir tmp/tce/optional
--Note that the target tmp directory here is actually "/tmp/extract1/tmp/tce/optional" since we are working with the files that will be loaded onto the remaster.
---The extracted core.gz from the original boot USB resides within /tmp/extract1

NOW any .tcz files can be copied into /tmp/extract1/tmp/tce/optional
-Once this location is zipped back into the new core.gz file they will be available for use

The next step is to modify the opt/bootsync.sh file so that the tcz file is loaded at OS boot so that the package can be used immediately

so:
vi /tmp/extract1/opt/bootsync.sh

At the bottom of this file add:
su tc -c "tce-load -i ntfs-3g.tcz"
-Substitute in whatever .tcz package is meant to be loaded at boot (whatever TCZ is being added to the image)

Also, add any scripts or files to the unpacked core prior to repacking. Example:
-cp /mnt/sdb1/Tiny_Core_Pack.bash /tmp/extract1/home/Tiny_Core_Pack.bash
--After re-packing this script will be available for use in /home/Tiny_Core_Pack.bash

When done the modified directory needs to be re-packed:

##Repacking the core.gz file for remaster##
-use the attached Tiny_Core_Pack.bash to automate this. Be sure to pass in /tmp/extract1 as an argument as this is the directory which will be repacked into the new core.gz file.
--Ex: Tiny_Core_Pack.bash /tmp/extract1
--This script will locate the tinycore flash drive, find the original core.gz file, back it up and then copy the new core.gz to the proper location.
--If the script is utilized then do not worry about the steps following this point.

Manual Steps:
cd /tmp/extract1
sudo find | sudo cpio -o -H newc | gzip -2 > ../tinycore.gz
-This will create a ../tinycore.gz file in the /tmp/extract1 directory.
IT IS VERY IMPORTANT TO WRITE THIS FILE TO THE MOUNTED USB DRIVE
-At this point the new gz file exists only in memory
-It must be written to the mounted disk in order to be saved and utilized

cp /tmp/extract/tinycore.gz /mnt/sdx/

Now the file will be written to the USB flash drive and the system can be shutdown.
Take this remastered core.gz file and replace the core.gz file on the drive that was just used.
-Advise keeping a backup of the core file prior to replacement in case the changes end up breaking the OS.
-This drive will now have the ability (at boot) to utilize any tools that were loaded into it during the remaster.

I hope this proves to be useful to someone! I'm not sure if I'm following doctrine correctly here, but this has helped me shape my TC install into what I want. Took me a bit of time to figure out the OS configs and automate the unpack / pack process.
« Last Edit: October 05, 2018, 05:10:42 AM by cshrout1 »

Offline cshrout1

  • WikiUser
  • *
  • Posts: 11
Re: My scripts to remaster tiny core
« Reply #1 on: October 05, 2018, 04:56:43 AM »
And the pack script since it didn't want to attach to the last post.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 2732
Re: My scripts to remaster tiny core
« Reply #2 on: October 05, 2018, 07:32:22 AM »
Hello cshrout1

It's always rewarding to accomplish such a task, well done.   May I also point out there are many remastering scripts here in this section and at least two extensions which could have saved a tremendous amount of time.

Try the exceptional all in one tool: "ezremaster.tcz" using the "inside initrd" option.
and also "core-remaster.tcz" extension for a quick unpack, modify and repack of core.tz

:)
« Last Edit: October 05, 2018, 07:34:53 AM by coreplayer2 »

Offline cshrout1

  • WikiUser
  • *
  • Posts: 11
Re: My scripts to remaster tiny core
« Reply #3 on: October 05, 2018, 09:34:43 AM »
Hello cshrout1

It's always rewarding to accomplish such a task, well done.   May I also point out there are many remastering scripts here in this section and at least two extensions which could have saved a tremendous amount of time.

Try the exceptional all in one tool: "ezremaster.tcz" using the "inside initrd" option.
and also "core-remaster.tcz" extension for a quick unpack, modify and repack of core.tz

:)

Thank you for the info! How does one run a .tcz file if it isn't already present within the OS? I'm not sure that I ever figured that out :) I looked into ezremaster but since I wasn't running a GUI I decided against it. I didn't try core-remaster.tcz though! It looks like it accomplishes the same thing my scripts do, though I'm not sure how I'd install it on the base core without having to remaster manually first... Any info on that would be much appreciated!

Thanks again!

Offline cshrout1

  • WikiUser
  • *
  • Posts: 11
Re: My scripts to remaster tiny core
« Reply #4 on: October 05, 2018, 10:21:54 AM »
Ok could I use the command:

sudo tce-load -i ntfs-3g.tcz

And point it to a .tcz file that's stored on /mnt/sdb1? I.E. put the tcz on the root of the flash drive and then load it in after boot? I don't recall if that works or not...

Example:

sudo tce-load -i /mnt/sdb1/ntfs-3g.tcz
« Last Edit: October 05, 2018, 10:31:30 AM by cshrout1 »

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5935
Re: My scripts to remaster tiny core
« Reply #5 on: October 05, 2018, 10:45:26 AM »
Hi cshrout1
I think you really need to take an hour and read this:
http://tinycorelinux.net/book.html

Offline cshrout1

  • WikiUser
  • *
  • Posts: 11
Re: My scripts to remaster tiny core
« Reply #6 on: October 05, 2018, 11:39:07 AM »
Rich,

Thanks! I've used that as a reference in the past and it was quite helpful in making my remaster scripts. The nice thing about the remaster script is that it can be used without already having any TCZ's loaded into the OS. Helpful when you're starting from scratch!

Appreciate the info!
« Last Edit: October 05, 2018, 11:46:37 AM by cshrout1 »