General TC > Programming & Scripting - Unofficial
NFS storage base scripts mod for PXE booting [split]
gerald_clark:
Latest update with patches.
I have eliminated the need to load nfs into the base.
I have added two boot options. Ex:
append initrd=../tcl-23/boot/tinycore.gz nfsmount=openvz:/tftpboot/nfs/tc2-music tftplist=openvz:/nfs/tc2-music/tftp/tcz.lst tz=CST+6CDT
tftplist=server:/directory/tczlist
This defines a tftp server and the path to a file that contains a list of tcz to load. My tcz.list is:
/nfs/tc2-music/tftp/nfs-utils.tcz
nfsmount=server:/directory
This defines an NFS share that will be mounted into /mnt/nfs.
This directory works just like /mnt/hda1 or /mnt/sda1 or any other device for the storage of mydata.tgz and a tce directory.
Backup is to 'nfs'.
By combining these two additions, a diskless workstation can PXE boot TC, load the NFS utilities over tftp, and
then loop mount a full compliment of tcz extensions over NFS.
I use this to boot a diskless music player over the network. It is accessed via vnc to play music from an NFS export.
No disk, no SD card, no thumb drive.
Here are the two patches
--- Code: ---*** tc-functions.orig 2009-08-29 22:40:18.000000000 -0500
--- tc-functions 2009-08-29 22:40:35.000000000 -0500
***************
*** 80,85 ****
--- 80,90 ----
MOUNTPOINT=""
MOUNTED="no"
D2="$1"
+ if [ "$D2" == "nfs" ]; then
+ MOUNTPOINT=/mnt/nfs
+ MOUNTED="yes"
+ return
+ fi
if [ "${D2:0:5}" == "UUID=" ]; then
D2=`/sbin/blkid -lt $D2 -o device`
if [ "$?" != 0 ]; then
***************
*** 117,123 ****
autoscan(){
FOUND=""
! for DEVICE in `grep "^/dev/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- 122,128 ----
autoscan(){
FOUND=""
! for DEVICE in `grep "/mnt/" /etc/fstab | grep -vf /etc/init.d/tc_noscan.lst | awk 'FS="/" { print $3}'`; do
find_mountpoint $DEVICE
if [ -n "$MOUNTPOINT" ]; then
if [ "$MOUNTED" == "no" ]; then
--- End code ---
--- Code: ---*** tc-config.orig 2009-08-29 22:40:18.000000000 -0500
--- tc-config 2009-08-29 22:40:35.000000000 -0500
***************
*** 171,176 ****
--- 171,178 ----
settime*) SETTIME=${i#*=} ;;
thm*) THEME=${i#*=} ;;
bkg*) BACKGROUND=${i#*=} ;;
+ nfsmount* ) NFSMOUNT=${i#*=} ;;
+ tftplist* ) TFTPLIST=${i#*=} ;;
esac
;;
*)
***************
*** 251,256 ****
--- 253,300 ----
/sbin/ifconfig lo 127.0.0.1 up
/sbin/route add 127.0.0.1 lo &
+ # dhcp.sh runs udhcpc async, so it exits before network is up
+ waitfor() {
+ [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh
+ CNT=0
+ until ping -c 1 $1 >/dev/null 2>&1
+ do
+ [ $((CNT++)) -gt 30 ] && break || sleep 1
+ done
+ DHCP_RAN=1
+ }
+
+ # First process tftp entries
+ modprobe -q squashfs 2>/dev/null
+ if [ -n "$TFTPLIST" ]; then
+ SERVER=`echo $TFTPLIST | awk -F\: '{ print $1 }'`
+ FILE=`echo $TFTPLIST | awk -F\: '{ print $2 }'`
+ waitfor $SERVER
+ ( mkdir /tmp/tftp ; cd /tmp/tftp
+ NAME=`basename $FILE`
+ tftp -g -r $FILE $SERVER
+ echo -ne "${BLUE}TFTP Loading Extensions ${YELLOW}"
+ while read EXTENSION
+ do
+ tftp -g -r $EXTENSION $SERVER
+ EXTNAME=`basename $EXTENSION`
+ echo -ne "$EXTNAME "
+ tcloop_mount "$EXTNAME" $(getbasefile "$EXTNAME" 1)
+ done < $NAME
+ echo "${GREEN} Done.${NORMAL}"
+ rm $NAME
+ )
+ fi
+
+ if [ -n "$NFSMOUNT" ]; then
+ SERVER=`echo $NFSMOUNT | awk -F\: '{ print $1 }'`
+ waitfor $SERVER
+ echo "$NFSMOUNT /mnt/nfs nfs defaults,nolock 0 0" >> /etc/fstab
+ echo "Mounting $NFSMOUNT"
+ mkdir /mnt/nfs
+ mount /mnt/nfs
+ fi
+
if [ -n "$CHECKFS" ]; then
touch /etc/sysconfig/checkfs
wait $fstab_pid
***************
*** 302,308 ****
tceSetup
#
! modprobe -q squashfs 2>/dev/null
if [ "$(ls -A /opt/tce)" ]; then
echo "${BLUE}Checking for /opt/tce items... ${NORMAL}"
gettceapps "/opt/tce"
--- 346,352 ----
tceSetup
#
! # modprobe -q squashfs 2>/dev/null
if [ "$(ls -A /opt/tce)" ]; then
echo "${BLUE}Checking for /opt/tce items... ${NORMAL}"
gettceapps "/opt/tce"
***************
*** 552,558 ****
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! /etc/init.d/dhcp.sh &
fi
[ -n "$CRON" ] && /etc/init.d/crond start
[ -n "$SSH" ] && /etc/init.d/dropbear start >/dev/null && echo " ${GREEN}ssh started.${NORMAL}"
--- 596,602 ----
if [ -n "$NODHCP" ]; then
echo "${GREEN}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}"
else
! [ -z "$DHCP_RAN" ] && /etc/init.d/dhcp.sh &
fi
[ -n "$CRON" ] && /etc/init.d/crond start
[ -n "$SSH" ] && /etc/init.d/dropbear start >/dev/null && echo " ${GREEN}ssh started.${NORMAL}"
--- End code ---
That is it. Hope someone else finds it useful.
curaga:
Suggesting a name change:
- the function "waitfor" is not really descriptive, how about waitfordhcp/waitforserver/etc?
gutmensch:
Keep up the good work, Gerald! I think it's one of the most interesting features since tinycore is so small you can use it on Wyse Terminals and other clients with very little RAM and absolutely no disk space ;-)
I agree that it should be incorporated into tinycore!
btw. I nearly did the same but also swapped out over nfs (because just 50 MB ram) and reduced the tinycore.gz to the mininum by exporting unneeded libs which can be loaded after the nfs connection, so atm I'm working with a 3.5 MB tinycore.gz :)
Best regards,
Robert
alu:
3.5 MB? awesome. i would be interested in it, and i would ask the TC-team in order to know their mind about this concept:
- 3.5MB core of the core as new concept for microcore;
- a lib.tar.gz or lib.tcz extension file with the needed libraries to push up the core of the core to the current microcore.
what do you think?
gutmensch:
@alu: I never thought about an extension, but you're right... thinking in tc{e,z} structure this would be the right approach! But since the minimization always depends on a NFS server it would be merely some kind of "new" distro (like the LTSP project). Nevertheless one could do:
a.) Minimize the kernel bzImage by using as many modules as possible.
b.) Reduce tinycore.gz to the least minimum (e.g. just busybox, libc, tftp-patches from Gerald, ...)
c.) Use boot params like Geralds and import the "nfs-utils.tcz", "lib.tcz", ... from an tftp/nfs, additionally any other extensions.
I think it would be possible to netboot with this way only 4 MB (bzImage + tinycore.gz) and it would be quite fast for thin clients.
One problem I see is, that it wouldn't reduce the amount of used ram with this extensions, as I need every byte I couldn't even afford to download and loop mount it (right now I'm loading it from nfs directly into ram, when it's needed, and it's "gone" from ram, when I close it).
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version