In checking out Thin Clients I have a number of USB flash drives with the latest version of Tiny Core installed on them. The flash drives are of various sizes (eg 1GB/4GB/8GB) and some are set up with small(!) 1GB boot partitions. In setting up the flash drives the process is:
Although I don't always do it, it is useful to include the command line parameter tce=UUID="1234-5678". This is because, left to its own devices, Tiny Core will search for the tce directory to use. If you boot the flash drive on a system which already has Tiny Core installed on it, Tiny Core will end up using the directory on sda1 (internal drive) rather than the one on sdb1 (external USB flash drive). By specifying the UUID of the boot device you can avoid this.
The idea now is that I only have to go through the full rigmarole once to set up a 'reference' flash drive. Thereafter the process is:
I'm no shell script expert, but this apparently works.
Usage is:
dupe_ref.sh [src drive] [dest drive]
So:
dupe_ref.sh sdb1 sdc1
will copy what's necessary from /mnt/sdb1 to update /mnt/sdc1.
What it does:
#!/bin/sh
# Script to update a bog-standard Tiny Core USB pen drive
# to match a configured and running pen drive.
# It also patches syslinux.cfg file with correct UUID
usage() {
echo "Usage: dupe_ref.sh [src drive] [dest drive]."
echo "eg: dupe_ref.sh sdb1 sdc1"
exit
}
mount_check() {
if ! grep -qs "$1" /etc/mtab ; then
echo "$1 partition isn't mounted"
exit
fi
}
if [ "$1" == "" ] ; then usage; fi
if [ "$2" == "" ] ; then usage; fi
src_m="/mnt/$1"
src_d="/dev/$1"
dest_m="/mnt/$2"
dest_d="/dev/$2"
mount_check $src_m
mount_check $dest_m
while true; do
read -p "Update $dest_d from $src_d?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
mv $dest_m/cde $dest_m/tce
echo "Updating files..."
rsync -avprc --exclude "System Volume*" $src_m/* $dest_m
blkid=$(blkid $dest_d | sed 's/.* UUID="\([^"]*\)".*/\1/')
echo setting blkid to $blkid in $dest_m/boot/syslinux/syslinux.cfg
sed -Ein 's/UUID="[^"]*/UUID="'$blkid'/' $dest_m/boot/syslinux/syslinux.cfg