Tiny Core Linux: Difference between revisions
pipe |
No edit summary |
||
| Line 2: | Line 2: | ||
== PXE Boot == | == PXE Boot == | ||
If | If PXE boot TinyCore, create a boot menu that loads the kernel and core.gz image: | ||
{{highlight|lang=text|code= | {{highlight|lang=text|code= | ||
LABEL Core | LABEL Core | ||
| Line 10: | Line 10: | ||
}} | }} | ||
The standard image will not have any extensions and will drop you into a shell. To get a GUI, you will need to load {{code|Xvesa}}, {{code|wbar}}, {{code|flwm_topside}} and their dependencies. The simplest way is to provide TinyCore with a NFS share containing these extensions like so: | |||
{{highlight|lang=text|code= | |||
LABEL Core | |||
MENU LABEL Core | |||
kernel /images/core/vmlinuz | |||
INITRD /images/core/core.gz nfsmount=10.1.1.1:/tftpboot/images/tinycore | |||
}} | |||
Where {{code|/tftpboot/images/tinycore}} contains: | |||
{{highlight|lang=text|code= | |||
$ ls /tftpboot/images/tinycore | |||
tce | |||
$ ls /tftpboot/images/tinycore/tce | |||
mydata.tgz onboot.lst optional | |||
}} | |||
When TinyCore boots, the NFS share will be mounted as {{code|/mnt/nfs}}. | |||
Alternatively, if you don't have a NFS server, you can specify a {{code|httplist}} that specifies the web server and the path to a file that contains a list of URIs (on that server) that TinyCore should download and load. | |||
{{highlight|lang=text|code= | {{highlight|lang=text|code= | ||
LABEL Core | LABEL Core | ||
MENU LABEL Core | MENU LABEL Core | ||
kernel /images/core/vmlinuz | kernel /images/core/vmlinuz | ||
INITRD /images/core/core.gz | INITRD /images/core/core.gz httplist=pages.cpsc.ucalgary.ca:80/~leo/boot/pxe/linux/data/tinycore/list.txt | ||
}} | |||
The list file contains: | |||
{{highlight|lang=text|code= | |||
/~leo/boot/pxe/linux/data/tinycore/8.x/libICE.tcz | |||
/~leo/boot/pxe/linux/data/tinycore/8.x/imlib2.tcz | |||
/~leo/boot/pxe/linux/data/tinycore/8.x/libSM.tcz | |||
... | |||
}} | |||
The only drawback to this feature is that the packages are downloaded from the server hosting that list. This means that you won't be able to make TinyCore download packages from an existing mirror. | |||
{{Info|1=Apache Mod_Rewrite Proxy|Since these extensions can get quite large, you can avoid making a copy of the extensions using mod_rewrite. In the case above, I had this {{code|.htaccess}} file in the 8.x directory that forwards package requests to a mirror. | |||
{{highlight|lang=htaccess|code= | |||
RewriteEngine on | |||
RewriteCond %{REQUEST_FILENAME} !-f | |||
RewriteRule (.*) http://mirror.cpsc.ucalgary.ca/mirror/tinycorelinux/8.x/x86/tcz/$1 [P,L] | |||
}} | |||
}} | |||
== Customization == | |||
I have made the following changes to {{code|/etc/init.d/tc-functions}} | |||
{{highlight|lang=diff|code= | |||
--- /home/staff/leo/tc-config 2017-04-08 08:40:04.000000000 -0600 | |||
+++ /tmp/tc-config 2017-08-18 17:12:14.000000000 -0600 | |||
@@ -61,6 +61,7 @@ | |||
rsyslog=* ) RSYSLOG=${i#*=}; SYSLOG=1 ;; | |||
blacklist* ) BLACKLIST="$BLACKLIST ${i#*=}" ;; | |||
iso* ) ISOFILE=${i#*=} ;; | |||
+ postexec*) POSTEXEC=${i#*=} ;; | |||
esac | |||
;; | |||
*) | |||
@@ -613,6 +614,13 @@ | |||
[ -z "$NORTC" ] {{!}}{{!}} /etc/init.d/settime.sh & | |||
fi | |||
+# Post run script | |||
+# Blindly run the script given from postexec= | |||
+if [ -n "$POSTEXEC" ]; then | |||
+ [ -z "$DHCP_RAN" ] && wait4Server $HOST $NOPING | |||
+ wget -O - "$POSTEXEC" {{!}} sh | |||
+fi | |||
+ | |||
[ -n "$CRON" ] && /etc/init.d/services/crond start | |||
/sbin/loadcpufreq 2>/dev/null & | |||
}} | |||
With this modification, you can pass {{code|postexec}} as a kernel argument which then gets executed after all the extensions have loaded, but before the user-side programs start. Eg: | |||
{{highlight|lang=text|code= | |||
kernel http://${base_url}/linux/data/tinycore/8.x/vmlinuz httplist=pages.cpsc.ucalgary.ca:80/~leo/boot/pxe/linux/data/tinycore/list.txt showapps postexec=http://pages.cpsc.ucalgary.ca/~leo/boot/pxe/linux/data/tinycore/post_install.sh | |||
}} | }} | ||
== Installing to Hard Drive == | == Miscellaneous == | ||
=== Installing to Hard Drive === | |||
The installer can be used to install TinyCore on a hard drive. Get the {{code|tc-install}} package and run it. | The installer can be used to install TinyCore on a hard drive. Get the {{code|tc-install}} package and run it. | ||
== | === Mirrors === | ||
The mirror can be selected by editing {{code|/opt/tcemirror}}. | The mirror can be selected by editing {{code|/opt/tcemirror}}. | ||
| Line 30: | Line 103: | ||
}} | }} | ||
== Modifying {{code|mydata.tgz}} == | |||
If you are running TinyCore on a NFS share, you might not be able to modify the system and then save the changes like you normally would with {{code|filetool.sh -b}}. | === Modifying {{code|mydata.tgz}} === | ||
If you are running TinyCore on a NFS share, you might not be able to modify the system and then save the changes like you normally would with {{code|filetool.sh -b}} because {{code|/mnt/nfs}} may be read only. | |||
To modify {{code|mydata.tgz}} outside of the TinyCore environment: | To modify {{code|mydata.tgz}} outside of the TinyCore environment: | ||
| Line 52: | Line 126: | ||
== Altering Initrd Image == | === Altering {{code|core.gz}} - Initrd Image === | ||
Follow the steps below if you wish to have the system include a set of packages out of the box without needing to load it as extensions. | Follow the steps below if you wish to have the system include a set of packages out of the box without needing to load it as extensions. | ||
=== Extract === | ==== Extract ==== | ||
Extract the {{code|core.gz}} file. | Extract the {{code|core.gz}} file. | ||
| Line 67: | Line 141: | ||
The extract directory should now contain the contents of the initrd file system. | The extract directory should now contain the contents of the initrd file system. | ||
=== Adding Additional Packages === | ==== Adding Additional Packages ==== | ||
Download the .tcz files you want installed from the repository. Store them somewhere (say {{code|/tmp/tinycore/packages}}). Each package is a squashfs filesystem which can be extracted using the {{code|unsquashfs}} utility. | Download the .tcz files you want installed from the repository. Store them somewhere (say {{code|/tmp/tinycore/packages}}). Each package is a squashfs filesystem which can be extracted using the {{code|unsquashfs}} utility. | ||
| Line 77: | Line 151: | ||
If you wish to run something on startup, put it in {{code|/opt/bootsync.sh}} or {{code|/opt/bootlocal.sh}}. {{code|/opt/bootsync.sh}} gets called by {{code|/etc/init.d/tc-config}}. Just note that networking might not be up immediately since the dhcp client runs asynchronously. I got around this by running {{code|while true ; do wget -O - http://somewhere.com && break ; done}} just to verify networking is up. | If you wish to run something on startup, put it in {{code|/opt/bootsync.sh}} or {{code|/opt/bootlocal.sh}}. {{code|/opt/bootsync.sh}} gets called by {{code|/etc/init.d/tc-config}}. Just note that networking might not be up immediately since the dhcp client runs asynchronously. I got around this by running {{code|while true ; do wget -O - http://somewhere.com && break ; done}} just to verify networking is up. | ||
=== Remastering === | ==== Remastering ==== | ||
With the changes made to the root file system, you will want to package the directory back up to create the initrd image. To do this, do: | With the changes made to the root file system, you will want to package the directory back up to create the initrd image. To do this, do: | ||
Revision as of 23:16, 18 August 2017
TinyCore is a nifty linux distro that's extremely small. It's main appeal is the small size and also the ability to save or revert any changes to the system.
PXE Boot
If PXE boot TinyCore, create a boot menu that loads the kernel and core.gz image:
LABEL Core
MENU LABEL Core
kernel /images/core/vmlinuz
INITRD /images/core/core.gz
The standard image will not have any extensions and will drop you into a shell. To get a GUI, you will need to load Xvesa, wbar, flwm_topside and their dependencies. The simplest way is to provide TinyCore with a NFS share containing these extensions like so:
LABEL Core
MENU LABEL Core
kernel /images/core/vmlinuz
INITRD /images/core/core.gz nfsmount=10.1.1.1:/tftpboot/images/tinycore
Where /tftpboot/images/tinycore contains:
$ ls /tftpboot/images/tinycore
tce
$ ls /tftpboot/images/tinycore/tce
mydata.tgz onboot.lst optional
When TinyCore boots, the NFS share will be mounted as /mnt/nfs.
Alternatively, if you don't have a NFS server, you can specify a httplist that specifies the web server and the path to a file that contains a list of URIs (on that server) that TinyCore should download and load.
LABEL Core
MENU LABEL Core
kernel /images/core/vmlinuz
INITRD /images/core/core.gz httplist=pages.cpsc.ucalgary.ca:80/~leo/boot/pxe/linux/data/tinycore/list.txt
The list file contains:
/~leo/boot/pxe/linux/data/tinycore/8.x/libICE.tcz
/~leo/boot/pxe/linux/data/tinycore/8.x/imlib2.tcz
/~leo/boot/pxe/linux/data/tinycore/8.x/libSM.tcz
...
The only drawback to this feature is that the packages are downloaded from the server hosting that list. This means that you won't be able to make TinyCore download packages from an existing mirror.
.htaccess file in the 8.x directory that forwards package requests to a mirror.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://mirror.cpsc.ucalgary.ca/mirror/tinycorelinux/8.x/x86/tcz/$1 [P,L]
Customization
I have made the following changes to /etc/init.d/tc-functions
--- /home/staff/leo/tc-config 2017-04-08 08:40:04.000000000 -0600
+++ /tmp/tc-config 2017-08-18 17:12:14.000000000 -0600
@@ -61,6 +61,7 @@
rsyslog=* ) RSYSLOG=${i#*=}; SYSLOG=1 ;;
blacklist* ) BLACKLIST="$BLACKLIST ${i#*=}" ;;
iso* ) ISOFILE=${i#*=} ;;
+ postexec*) POSTEXEC=${i#*=} ;;
esac
;;
*)
@@ -613,6 +614,13 @@
[ -z "$NORTC" ] || /etc/init.d/settime.sh &
fi
+# Post run script
+# Blindly run the script given from postexec=
+if [ -n "$POSTEXEC" ]; then
+ [ -z "$DHCP_RAN" ] && wait4Server $HOST $NOPING
+ wget -O - "$POSTEXEC" | sh
+fi
+
[ -n "$CRON" ] && /etc/init.d/services/crond start
/sbin/loadcpufreq 2>/dev/null &
With this modification, you can pass postexec as a kernel argument which then gets executed after all the extensions have loaded, but before the user-side programs start. Eg:
kernel http://${base_url}/linux/data/tinycore/8.x/vmlinuz httplist=pages.cpsc.ucalgary.ca:80/~leo/boot/pxe/linux/data/tinycore/list.txt showapps postexec=http://pages.cpsc.ucalgary.ca/~leo/boot/pxe/linux/data/tinycore/post_install.sh
Miscellaneous
Installing to Hard Drive
The installer can be used to install TinyCore on a hard drive. Get the tc-install package and run it.
Mirrors
The mirror can be selected by editing /opt/tcemirror.
To use CPSC's mirror, edit /opt/tcemirror and replace it with:
http://mirror.cpsc.ucalgary.ca/mirror/tinycorelinux/
Modifying mydata.tgz
If you are running TinyCore on a NFS share, you might not be able to modify the system and then save the changes like you normally would with filetool.sh -b because /mnt/nfs may be read only.
To modify mydata.tgz outside of the TinyCore environment:
# umask 022 # In case you have a weird umask, default to 022.
# mkdir tce # this dir should be 755 (anything less will kill your tce image)
# cd tce
# tar --numeric-owner -xzpf ../mydata.tgz # Keep permissions and ownership!
## make your changes
# tar --numeric-owner -czpf ../mydata.tgz * # Re-create the tarball with permissions
Overwrite the old mydata.tgz on the NFS share and then test the changes on TinyCore by running:
# filetoool.sh -r
Any changes you've made should be visible immediately.
Altering core.gz - Initrd Image
Follow the steps below if you wish to have the system include a set of packages out of the box without needing to load it as extensions.
Extract
Extract the core.gz file.
$ mkdir -p /tmp/tinycore/extract
$ mv core.gz /tmp/tinycore # where core.gz is the initrd file
$ cd /tmp/tinycore/extract
$ zcat ../core.gz | cpio -i
The extract directory should now contain the contents of the initrd file system.
Adding Additional Packages
Download the .tcz files you want installed from the repository. Store them somewhere (say /tmp/tinycore/packages). Each package is a squashfs filesystem which can be extracted using the unsquashfs utility.
$ cd /tmp/tinycore/extract
$ for i in `ls ../packages/*.tcz` ; do unsquashfs -f -d . $i ; done
If you wish to run something on startup, put it in /opt/bootsync.sh or /opt/bootlocal.sh. /opt/bootsync.sh gets called by /etc/init.d/tc-config. Just note that networking might not be up immediately since the dhcp client runs asynchronously. I got around this by running while true ; do wget -O - http://somewhere.com && break ; done just to verify networking is up.
Remastering
With the changes made to the root file system, you will want to package the directory back up to create the initrd image. To do this, do:
$ cd /tmp/tinycore/extract
$ find | cpio -o -H newc > ../core
$ cd ..
$ gzip core
$ advdef -z4 core.gz # this step is optional, but may save you ~2% of space.