From db02438df7f389164b7c0c240edfd902bee4347a Mon Sep 17 00:00:00 2001 From: vallard Date: Tue, 15 Dec 2009 20:29:50 +0000 Subject: [PATCH] fixed statelite, the xCAT graphic, and mount info git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4788 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/netboot/rh/genimage | 252 ++++++++++++--------- 1 file changed, 150 insertions(+), 102 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 9c43c4e7d..4ca404bcf 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -48,6 +48,7 @@ my $postinstall_filename; my $rootimg_dir; my $rwfiles; # these files are used by statelite for tmpfs rw + sub xdie { system("rm -rf /tmp/xcatinitrd.$$"); die @_; @@ -202,33 +203,6 @@ unless ($onlyinitrd) { close($yumconfig); mkpath "$rootimg_dir/etc"; - # statelite snapshots directory added here. - # this is where tmpfs will be created. - if($mode eq "statelite"){ - mkpath "$rootimg_dir/.snapshot"; # create place for NFS mounts. - # get all the rw files that go in tmpfs - $rwfiles = get_rwfiles_file_name($customdir); - if (!$rwfiles) { - $rwfiles= get_rwfiles_file_name($pathtofiles); - } - if(!$rwfiles){ - print "Unable to find r/w file list. Make a file called $profile.rwfiles with all the necessary read/write files\n"; - exit 1; - } - # copyt the rwfiles to /.snapshot/files for the initfs to use. - copy("$rwfiles","$rootimg_dir/.snapshot/files"); - - # also need to create stub file for booting since this is read only - mkpath "$rootimg_dir/var/lib/dhclient/"; - # create an empty file - open(FH,">$rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases"); - close(FH); - open(FH,">$rootimg_dir/var/lib/random-seed"); - close(FH); - - # link mtab. - system("ln -sf /proc/mounts $rootimg_dir/etc/mtab"); - } my $fd; open($fd,">>","$rootimg_dir/etc/fstab"); @@ -374,6 +348,33 @@ if (($postinstall_filename) && (-x $postinstall_filename)) { } } + +# statelite .statelite directory added here. +# this is where tmpfs will be created. +if($mode eq "statelite"){ + mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts. + # this script will get the directories. + unless(-f "../add-on/statelite/rc.statelite"){ + print "Can't find ../add-on/statelite/rc.statelite!\n"; + exit; + } + system("cp ../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite"); + # also need to add this file: + # may have already been made into a symbolic link, if so ignore it + + unless(-l "$rootimg_dir/var/lib/dhclient" ){ + mkpath "$rootimg_dir/var/lib/dhclient/"; + system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases"); + } + + unless(-l "$rootimg_dir/var/lib/dhcp" ){ + mkpath "$rootimg_dir/var/lib/dhcp/"; + system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases"); + } +} + + + mkinitrd(); sub getlibs { @@ -436,7 +437,7 @@ sub mkinitrd { print $inifile < /dev/null && DEBUG=1 +grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1 netstart while ! ifconfig | grep inet; do echo -e "\${RED}Failed to acquire address, retrying \${RESET}" @@ -614,36 +604,40 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` SERVER=`echo \$VALUE|awk -F: '{print \$1}'` ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - elif [ "\$KEY" == 'SNAPSHOT' ]; then + elif [ "\$KEY" == 'STATEMNT' ]; then NFSROOT=1 VALUE=`echo \$i |awk -F= '{print \$2}'` SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + # may be that there is not server and just a directory. + if [ -z \$SNAPSHOTROOT ] + then + SNAPSHOTROOT=\$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi fi done # show xCAT logo fancydisplay -# go to debug shell if shell is specified. -grep '\(shell\)' /proc/cmdline > /dev/null && shell echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug # NFSROOT code here: if [ "\$NFSROOT" = "1" ]; then - echo Setting up nfs with ram overlay. + echo Setting up Statelite # for loop back mounting capability! mknod /dev/loop0 b 7 0 mkdir -p \$NEWROOT - MAXTRIES=5 - ITER=0 - ME=`hostname` + MAXTRIES=5 + ITER=0 + ME=`hostname` while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,udp,nfsvers=3,timeo=14 do ITER=\$(expr \$ITER + 1) if [ "\$ITER" == "\$MAXTRIES" ] - then + then echo "You're dead. rpower \$ME boot to play again." echo "Possible problems: 1. This initrd wasn't created for statelite node? rerun genimage with the -m statelite flag, then rerun 'nodeset \$ME statelite' @@ -665,54 +659,108 @@ if [ "\$NFSROOT" = "1" ]; then if [ ! -e "\$NEWROOT/\$RWDIR" ] then echo "" - echo -e "\${RED}Hmmm... this NFS root directory doesn't have a /.snapshot directory for me to mount a rw filesystem. You'd better create it... \${NORMAL}" + echo -e "\${RED}Hmmm... this NFS root directory doesn't have a /\$RWDIR directory for me to mount a rw filesystem. You'd better create it... \${NORMAL}" echo "." shell fi - grep '\(shell\)' /proc/cmdline >/dev/null && shell - if [ -e "\$NEWROOT/\$RWDIR/files" ]; then - mkdir -p /rw - mount -t tmpfs rw /rw - cp \$NEWROOT/\$RWDIR/files /rw/ # copy the files from .snapshot here now - mount -n --bind /rw \$NEWROOT/\$RWDIR # remount read/writable - - for i in `grep -v "^#" \$NEWROOT/\$RWDIR/files`; do - if [ -e \$NEWROOT/\$i ]; then - mountfile \$i \$ME - fi; - done - else - echo -e "\${RED}\$NEWROOT/\$RWDIR/files does not exist! I need a list of files to mount read write... or else we'll try mounting everything read only. \$RESET" + while [ ! -e "\$NEWROOT/etc/init.d/statelite" ] + do + echo "" + echo -e "\${RED}Hmmm... \$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with the -m statelite mode" + echo "" shell + done + grep '\\(shell\\)' /proc/cmdline >/dev/null && shell + mount -t tmpfs rw \$NEWROOT/\$RWDIR + mkdir -p \$NEWROOT/\$RWDIR/tmpfs + + + # mount the SNAPSHOT directory here for persistent use. + if [ ! -z \$SNAPSHOTSERVER ] + then + mkdir -p \$NEWROOT/\$RWDIR/persistent + MAXTRIES=5 + ITER=0 + while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent + do + ITER=\$(expr \$ITER + 1) + if [ "\$ITER" == "\$MAXTRIES" ] + then + echo "You're dead. rpower \$ME boot to play again." + echo "Possible problems: +1. \$SNAPSHOTSERVER is not exporting \$SNAPSHOTROOT ? +2. Is DNS set up? Maybe that's why I can't mount \$SNAPSHOTSERVER." + shell + exit + fi + echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL}" + RS=`expr \$RANDOM % 20` + echo -e "Trying again in \$RS seconds" + sleep \$RS + done fi + grep '\\(shell\\)' /proc/cmdline >/dev/null && shell # have to preserve the initial DHCP request. So we link it. - if [ ! -d \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient ] + if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhclient ] then - mkdir -p \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient + mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhclient + fi + if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcp ] + then + mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcp fi - cp -fp /var/lib/dhclient/dhclient.leases \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient/dhclient-$prinic.leases + cp -fp /var/lib/dhclient/dhclient.leases \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhclient/dhclient-$prinic.leases + cp -fp /var/lib/dhclient/dhclient.leases \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcp/dhclient-$prinic.leases - while ! mount -n --bind \$NEWROOT/\$RWDIR/\$ME/var/lib/dhclient/dhclient-$prinic.leases \$NEWROOT/var/lib/dhclient/dhclient-$prinic.leases; + # dhclient + #while ! mount -n --bind \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhclient/dhclient-$prinic.leases \$NEWROOT/var/lib/dhclient/dhclient-$prinic.leases + #do + # echo "Can't mount /tmpfs/var/lib/dhclient/dhclient-$prinic.leases to /var/lib/dhclient/dhclient-$prinic.leases" + # shell + #done + + # dhcp + #while ! mount -n --bind \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcp/dhclient-$prinic.leases \$NEWROOT/var/lib/dhcp/dhclient-$prinic.leases + #do + # echo "Can't mount /tmpfs/var/lib/dhcp/dhclient-$prinic.leases to /var/lib/dhcp/dhclient-$prinic.leases" + # shell + #done + + + + [ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ + + + [ -e /etc/ntp/step-kickers ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc/ntp && cp /etc/ntp/step-kickers \$NEWROOT/\$RWDIR/tmpfs/etc/ntp + + + [ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ + + # now that everything is mounted, lets do this + # hmmm, apparently I'm checking this twice... so I'd better + # be really sure the file is there. + while [ -z \$NEWROOT/etc/init.d/statelite ] do - echo -e "\${RED}The file /var/lib/dhclient/dhclient-$prinic.leases on your NFS root doesn't exist. I can't bind mount to it :-( \${RESET}" - echo -e "\${PINK}You'd better create it! :-) \${RESET}" + echo "\$NEWROOT/etc/init.d/statelite does not exist in image!" shell done - # mount /etc/resolv.conf! - mkdir -p \$NEWROOT/\$RWDIR/\$ME/etc - cp /etc/resolv.conf \$NEWROOT/\$RWDIR/\$ME/etc/ - mount -n --bind \$NEWROOT/\$RWDIR/\$ME/etc/resolv.conf \$NEWROOT/\$RWDIR/\$ME/etc/resolv.conf + # do all the mounts: + \$NEWROOT/etc/init.d/statelite + + # give the debug shell just before we go if specified! + grep '\(shell\)' /proc/cmdline > /dev/null && shell echo 0x100 > /proc/sys/kernel/real-root-dev export keep_old_ip=yes export fastboot=yes export READONLY=yes + grep '\\(shell\\)' /proc/cmdline >/dev/null && shell mount -n --bind /dev /sysroot/dev umount /sys umount /proc @@ -721,7 +769,7 @@ if [ "\$NFSROOT" = "1" ]; then then echo "" echo -e "\${RED}Couldn't switch_root. Something must be wrong with NFS root image.\${RESET}" - mount -t proc proc /proc + # mount -t proc proc /proc shell fi exit