(Last modified 11/24/2010)
It's working quite well. It is designed to install TC 3.2 to any basic machine with hard drive at either /dev/hda or /dev/sda. It does wipe the hard drive as part of the task, the idea is to set up a TC machine as quickly and easily as possible. You'll want exactly one PATA or SATA hard drive in the box.
Many thanks to roberts in these forums, who helped me get the persistence mode to work, and gerald_clark, who gave me an essential boot tip for hard drive cleanup. maro and tinypoodle also, for 1.03, cleared up a serious misunderstanding I had concerning persistence needs.
My favorite method of use, is to boot up TC from CD using boot codes "tinycore base norestore", open a command prompt, get to root with 'sudo su', and type:
sudo su
wget http://pctsc.ponderworthy.org/2.0/tc.setup.sh
sh tc.setup.sh
The default is for full persistence turned on. To turn it off, add --nopersist to the end of the command line. There is also --waitforusb=NN in case it's needed, and --help of course.
There is a bit of user interaction, not much. Afterwards, reboot from hard drive, make sure it doesn't boot from CD, and I think TC will take it from there.
If anyone has a really reliable way to identify the device name of the source/boot media, that would simplify things a lot :-)
J.E.B.
#!/bin/sh
echo ""
echo "**** An Easy Installer for Tiny Core Linux ****"
echo "**** ****"
echo "**** by Jonathan E. Brickman ****"
echo "**** version 1.03 2010-11-24 ****"
echo "**** tested with TC 3.2 ****"
echo "**** ****"
echo "**** '--nopersist' disables persistence of ****"
echo "**** package installs and settings. ****"
echo "**** '--waitforusb=N' waits N seconds for USB ****"
echo "**** devices. Use 0 for new, 5 for general, ****"
echo "**** 30 for ancient. Default is 5. ****"
# This code requires 4-character tabs for proper viewing
LOG_FILE="./tc-inst.log"
rm -f $LOG_FILE
touch $LOG_FILE
TC_PERSIST=1
TC_WAITFORUSB=5
# TCTMP holds a directoryname for temporary usage
# by this installer.
TCTMP="/tmp/temp$RANDOM"
mkdir $TCTMP &> /dev/null
# Parse command-line parameters.
echo ""
for i in $*; do
case $i in
--nopersist)
echo "Persistence mode disabled."
TC_PERSIST=0
;;
--help)
echo "Usage: sh tc.setup.sh [ --nopersist ] [ --waitforusb=N ]"
exit 1
;;
--waitforusb=*)
TC_WAITFORUSB=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
*)
echo "Unknown parameter found."
echo "Usage: sh tc.setup.sh [ --nopersist ] [ --waitforusb=N ]"
exit 1
;;
esac
done
echo ""
echo "** Step 1: Check to see if running as root. **"
if [ $USER == "root" ]; then
echo "root verified."
else
echo "Running as user '"$USER"'."
echo "This script must be run as root."
exit 1
fi
echo ""
echo "** Step 2: Check network. **"
if ping -c 1 -w 3 yahoo.com &> /dev/null
then
echo "Network verified."
else
echo "Network not found."
exit 1
fi
echo ""
echo "** Step 3: Identify hard drive to use. **"
echo "Step 3" >> $LOG_FILE
fdisk -l | grep /dev/hda >> $LOG_FILE 2>&1
if [ "$?" = "0" ]; then
echo "Found hard drive at /dev/hda. Designated."
TCHD="hda"
else
fdisk -l | grep /dev/sda >> $LOG_FILE 2>&1
if [ "$?" = "0" ]; then
echo "Found hard drive at /dev/sda. Designated."
TCHD="sda"
else
echo "Did not find hard drive at /dev/hda or /dev/sda."
echo "One or the other is required for this script."
echo "Exiting."
exit 1
fi
fi
TCHDP=$TCHD""1
# If a partition is already mounted, must
# begin at beginning, booting TC with codes "base norestore"
mount | grep $TCHD >> $LOG_FILE 2>&1
if [ "$?" = "0" ]; then
echo ""
echo "Error: A TC partition already exists on the designated"
echo "hard drive, and must be removed using special Tiny Core"
echo "Linux boot setup."
echo ""
echo "Please reboot specifying 'tinycore base norestore'",
echo "and try again."
echo ""
echo "Exiting."
exit 1
fi
echo ""
echo "** Step 4: Install packages. **"
# tce-load will not run as root. Use 'sudo' to run it as user 'tc'.
# 'cfdisk' is used for auto-repartitioning. In the future, this
# will probably be replaced with just 'fdisk' which requires no
# package and will therefore speed things up and shrink them down.
# 'Xvesa' is reportedly required for the numeric keypad to work.
# It also permits the -nozap disabling of Ctrl-Alt-Backspace.
sudo -u tc tce-load -wi cfdisk.tcz \
grub-0.97-splash.tcz \
Xvesa.tcz \
kmaps.tcz
if [ "$?" != "0" ]; then
echo "Could not install packages. Perhaps your Internet"
echo "connection is down?"
exit 1
fi
echo ""
echo "** Step 5: Verify with user before continuing. **"
echo ""
echo "The next step is to wipe hard drive /dev/"$TCHD" and install Tiny Core"
echo "Linux in a 1000M first partition. ALL EXISTING DATA ON THIS DRIVE IS ABOUT"
echo "TO BE WIPED. Are you sure this is what you want to do?"
echo ""
echo "Step 5" >> $LOG_FILE
read -p "Type 'yes' (no quotes) if you are certain: "
if [ "$REPLY" != "yes" ]; then
echo "Did not receive a response of 'yes'. Terminating."
echo ""
exit
else
echo "Received clear affirmative. Proceeding."
echo ""
fi
echo ""
echo "** Step 6: Remove all existing partitions if any, and **"
echo "** create new 1000M Linux partition at beginning of drive. **"
echo "Step 6" >> $LOG_FILE
echo -n "Partitioning..."
# Unmount if mounted.
if [ `mount | grep $TCHDP` ]; then
umount /mnt/$TCHDP &> /dev/null
fi
# Remove old partition(s).
echo -e -n "Wyes\nq" | cfdisk -z /dev/$TCHD >> $LOG_FILE 2>&1
# Repartition.
echo -e -n "np900M\nbbWyes\nq" | cfdisk -z /dev/$TCHD >> $LOG_FILE 2>&1
echo "done."
echo -n "Waiting for udev to settle..."
udevadm settle
echo "done."
# In case automounting doesn't happen, format and mount.
echo -n "Checking to see if format is required..."
mount | grep $TCHDP >> $LOG_FILE 2>&1
if [ "$?" != "0" ]; then
echo -n "Format is required. Formatting..."
mkfs.ext3 /dev/$TCHDP >> $LOG_FILE 2>&1
if [ "$?" != "0" ]; then
echo "Error during format. Exiting."
exit
fi
udevadm settle
echo "done."
fi
echo -n "Checking to see if mount point exists..."
if [ ! -d /mnt/$TCHDP ]; then
echo "done."
echo -n "Creating mount point..."
mkdir /mnt/$TCHDP
fi
echo "done."
echo -n "Checking to see if mount is needed..."
mount | grep $TCHDP >> $LOG_FILE 2>&1
if [ "$?" != "0" ]; then
echo "done."
echo -n "Mounting..."
mount /dev/$TCHDP /mnt/$TCHDP >> $LOG_FILE 2>&1
if [ "$?" != "0" ]; then
echo "Mount failed. Exiting."
exit
fi
fi
echo "done."
echo ""
echo "** Step 7: Mount the source/boot media. **"
echo "Step 7" >> $LOG_FILE
echo "We now need to identify your source/boot media."
TRY_AGAIN=1
while [ $TRY_AGAIN == "1" ]; do
echo "Here are the possibles:"
echo "---"
ls /mnt
echo "---"
echo "If your CD-ROM is set up as a secondary master IDE, it's almost"
echo "certainly hdc. If it's SATA, it will be something with an 'sd'"
echo "prefix, perhaps sdb or sdc. Please study the above and enter your"
echo "best thought below."
echo ""
read -p "Device name for the CD or other media you booted from: "
# Check data entry, try to mount, and try to verify
ls /mnt | grep "$REPLY" &> /dev/null
if [ "$?" != "0" ]; then
echo ""
echo "Sorry, you did not enter a valid device name. Please try again."
echo ""
continue
elif [ $REPLY == $TCHDP ]; then
echo ""
echo "Sorry, your source/boot medium cannot equal your hard drive."
echo "Please try again."
echo ""
continue
fi
TCSOURCE=$REPLY
# Try to unmount the device first, just in case. Useful in debugging if nought else.
umount /dev/$TCSOURCE >> $LOG_FILE 2>&1
echo ""
echo "Trying to mount /dev/"$TCSOURCE"..."
mount /dev/$TCSOURCE /mnt/$TCSOURCE
if [ "$?" != "0" ]; then
echo ""
echo "Cannot mount /dev/"$TCSOURCE" . Please try again."
echo ""
continue
fi
echo "Medium successfully mounted. Checking..."
ls /mnt/$TCSOURCE/boot/tinycore.gz >> $LOG_FILE 2>&1
if [ "$?" != "0" ]; then
echo ""
echo "Mounted medium does not contain Tiny Core Linux."
echo "Please try again."
echo ""
continue
fi
echo "Source/boot medium mounted and verified!"
TRY_AGAIN=0
done
echo ""
echo "** Step 8: Create directories and copy files. **"
echo "Step 8" >> $LOG_FILE
echo -n "Working..."
echo -n "8a..."
mkdir -p /mnt/$TCHDP/boot/grub
if [ "$?" != "0" ]; then
echo "Error in creation of boot directory on hard drive (/mnt/"$TCHDP"/boot/grub)."
echo "Exiting."
exit 1
fi
echo -n "8b..."
cp -p /mnt/$TCSOURCE/boot/* /mnt/$TCHDP/boot/ &> /dev/null
# There is an "omitting directory" error here which we need to ignore
echo -n "8c..."
mkdir -p /mnt/$TCHDP/tce
if [ "$?" != "0" ]; then
echo "Error in creation of 'tce' folder (/mnt/"$TCHDP"/tce)."
echo "Exiting."
exit 1
fi
# From here:
# http://forum.tinycorelinux.net/index.php?topic=7608.msg40511#msg40511
echo -n "8d..."
touch /mnt/$TCHDP/tce/copy2fs.flg
if [ "$?" != "0" ]; then
echo "Error in creation of 'copy2fs.flg' (/mnt/"$TCHDP"/tce/copy2fs.flg)."
echo "Exiting."
exit 1
fi
echo -n "8e..."
touch /mnt/$TCHDP/tce/mydata.tgz
if [ "$?" != "0" ]; then
echo "Error in creation of 'mydata.tgz' (/mnt/"$TCHDP"/tce/mydata.tgz)."
echo "Exiting."
exit 1
fi
echo -n "8f..."
cp -p /usr/lib/grub/i386-pc/* /mnt/$TCHDP/boot/grub
if [ "$?" != "0" ]; then
echo "Error in copy of grub files to folder '/mnt/"$TCHDP"/boot/grub'."
echo "Exiting."
exit 1
fi
echo "done."
echo ""
echo "** Step 9: Configuring the GRUB boot loader. **"
echo "Step 9" >> $LOG_FILE
# Create the menu.lst for GRUB. Includes USB support on the kernel line.
echo "Creating '/mnt/"$TCHDP"/boot/grub/menu.lst'..."
if [ "$TC_PERSIST" -eq 1 ]; then
echo -n "Setting persistence in 'grub' configuration..."
# Persisting /opt, /home, and /local using boot codes.
# The method is from here:
# http://forum.tinycorelinux.net/index.php?topic=7608.msg40511#msg40511
# Thanks to Robert Shingledecker for the help!
# the tce/opt/home/local items will persist most things
# but not passwords or anything else in /etc
TC_KERNEL_LINE="kernel /boot/bzImage quiet waitusb=$TC_WAITFORUSB tce=$TCHDP opt=$TCHDP home=$TCHDP"
else
echo -n "Setting nonpersistence in 'grub' configuration..."
TC_KERNEL_LINE="kernel /boot/bzImage quiet waitusb=$TC_WAITFORUSB"
fi
echo "default 0" > $TCTMP/grub.menu.lst
echo "timeout 3" >> $TCTMP/grub.menu.lst
echo "title Tiny Core Linux" >> $TCTMP/grub.menu.lst
echo $TC_KERNEL_LINE >> $TCTMP/grub.menu.lst
echo "initrd /boot/tinycore.gz" >> $TCTMP/grub.menu.lst
mv $TCTMP/grub.menu.lst /mnt/$TCHDP/boot/grub/menu.lst
echo "done."
echo ""
echo "** Step 10: Activating the GRUB boot loader. **"
echo "Step 10" >> $LOG_FILE
echo "Activating GRUB. On some older/rarer hardware this can take"
echo -n "between 3 and 30 minutes, but it will still work..."
echo -e -n "root (hd0,0)\nsetup (hd0)\nquit\n" | grub >> $LOG_FILE 2>&1
if [ "$?" != "0" ]; then
echo "Error in GRUB activation."
echo "Exiting."
exit 1
fi
echo "done."
echo ""
echo "All done!!!"
echo ""
echo "**** Tiny Core Linux is now installed. You will need to make sure your ****"
echo "**** system does not boot from source media, at next reboot. ****"