PXE Boot TinyCore

Various Linux Stuff
Post Reply
thockman
Site Admin
Posts: 104
Joined: Thu Dec 15, 2005 5:51 pm
Location: Kansas City
Contact:

PXE Boot TinyCore

Post by thockman » Thu Feb 02, 2012 12:48 pm

Here is a script I created to build a PXE Boot image for tinycore. You can just add the tcz files in the base to build the image. I pulled together several items from other forums so thanks to them....

1) create bash script in temp folder
2) mkdir build dir in same folder and place tcz files and tinycore.tgz
3) modify script variables
4) run script ( don't forget chmod 700 scriptname)
5) the script will scp new tgz file to pxe location or you can copy later.
6) add tiny to existing pxe boot by copying bzimage to correct pxe folder where tinycore.tgz is copied.

Sample pxe boot
default 0
LABEL 0
kernel tiny/bzImage
append initrd=tiny/tc.gz

Also here is a synergyc service file to put in the base dir to autostart synergyc. You will have to modify to your needs...

Code: Select all

#!/bin/sh

case "${1}" in
	start)
		synergyc -n curly hostname or ip
		;;

	stop)
		pkill synergyc
		;;

	status)
		pidof -o %PPID synergyc
		;;

	*)
		exit 1
		;;
esac
And now the code 8)

Code: Select all

!/bin/bash
clear
tinyloc=/Temp/tiny
tserver=timeserver.domain
pxe_loc=pxeservername:/location
pxe_usr=pxeserver_login

# Make sure running as root.
uid=$(/usr/bin/id -u) && [ "$uid" = "0" ] || { echo "must be root"; exit 1; }

function showusage { 
  clear
  echo "Usage: "
  echo "./build.sh envname {debug}"
} 

if grep help <<<"$@"; then 
  showusage 
  exit 0 
fi 

if [[ ! "$1" ]]; then 
  showusage
  exit 0
fi

# Check for env
if [ ! -d $1 ]; then echo "Sorry! Missing env...."; exit 1; fi

# Make dirs
if [ ! -d $tinyloc/temp ]; then mkdir $tinyloc/temp; fi
if [ ! -d $tinyloc/system ]; then mkdir $tinyloc/system; fi

# CP my base
cp $tinyloc/$1/*.tcz $tinyloc/system

# UnSquashall
cd $tinyloc/system
for i in $( ls $tinyloc/system/); do
  unsquashfs -f $tinyloc/system/$i
done

#Extract tinycore
cp $tinyloc/$1/tinycore.gz $tinyloc/temp
cd $tinyloc/temp
zcat tinycore.gz | cpio -i -H newc -d
rm -f tinycore.gz
cp -rp $tinyloc/system/squashfs-root/usr/ $tinyloc/temp
cp $tinyloc/$1/synergyc $tinyloc/temp/etc/init.d/services/
echo "/etc/init.d/services/synergyc start" >> $tinyloc/temp/etc/skel/.xsession
sed -i "s/1024x768x32/1280x1024x24/g" $tinyloc/temp/etc/skel/.xsession
# Set Central time zone
cp $tinyloc/temp/usr/local/share/zoneinfo/America/Chicago $tinyloc/temp/etc/localtime
echo "export TZ=CST6CDT" >> $tinyloc/temp/etc/profile
echo "while ! nslookup $tserver &>/dev/null ; do sleep 1; echo "Waiting for time..." ; done ; ntpclient -s -h $tserver ; hwclock -w" >> $tinyloc/temp/opt/bootlocal.sh

# Temp for view pcoip
# Built on Ubuntu 11.10 with vmware-view-client installed.
# Built the vmvlist from:
#  dpkg -L vmware-view-client > vmvlist
#  dpkg -L zenity-common >> vmvlist
#  dpkg -L zenity-common >> vmvlist
# This needs more work to use full vmware client

for i in $(cat $tinyloc/$1/vmvlist); do 
  if [ -d $i ]; then mkdir -p $tinyloc/temp$i; fi
  if [ -f $i ]; then
    cp -rp $i $tinyloc/temp$i
  fi
done

echo "i: /usr/share/pixmaps/vmware-view.png" >> $tinyloc/temp/usr/share/wbar/dot.wbar
echo "t: VMView" >> $tinyloc/temp/usr/share/wbar/dot.wbar
echo "c: exec vmware-view" >> $tinyloc/temp/usr/share/wbar/dot.wbar

find | cpio -o -H newc | gzip -2 > tc.gz
if [[ ! $2 ]]; then
  scp tc.gz $pxe_usr@$pxe_loc
  rm -rf $tinyloc/system/ $tinyloc/temp
fi
clear

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest