mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-27 01:15:34 +00:00 
			
		
		
		
	the code to enable statelite semantics on top of ramdisk is here:
there's one new attribute called "rootfstype" for the osimage; git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8564 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -573,13 +573,14 @@ notification => { | ||||
|  }, | ||||
|   }, | ||||
| osimage  => { | ||||
|  cols => [qw(imagename profile imagetype provmethod osname osvers osdistro osarch synclists postscripts postbootscripts comments disable)], | ||||
|  cols => [qw(imagename profile imagetype provmethod rootfstype osname osvers osdistro osarch synclists postscripts postbootscripts comments disable)], | ||||
|  keys => [qw(imagename)], | ||||
|     table_desc => 'Basic information about an operating system image that can be used to deploy cluster nodes.', | ||||
|  descriptions => { | ||||
|   imagename => 'The name of this xCAT OS image definition.', | ||||
|   imagetype => 'The type of operating system image this definition represents.', | ||||
|   provmethod => 'The provisioning method for node deployment. The valid values are install, netboot or statelite. It is not used by AIX.', | ||||
|   rootfstype => 'The filesystem type for the rootfs is used when the provmethod is statelite. The valid values are nfs or ramdisk. The default value is nfs', | ||||
|   profile => 'The node usage category. For example compute, service.', | ||||
|   osname => 'Operating system name- AIX or Linux.', | ||||
|   osvers => 'Not used.', | ||||
| @@ -1792,6 +1793,11 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs); | ||||
|                  tabentry => 'osimage.provmethod', | ||||
|                  access_tabentry => 'osimage.imagename=attr:imagename', | ||||
|                  }, | ||||
|  {attr_name => 'rootfstype', | ||||
|                  only_if => 'imagetype=linux', | ||||
|                  tabentry => 'osimage.rootfstype', | ||||
|                  access_tabentry => 'osimage.imagename=attr:imagename', | ||||
|                  }, | ||||
|  {attr_name => 'profile', | ||||
|                  tabentry => 'osimage.profile', | ||||
|                  access_tabentry => 'osimage.imagename=attr:imagename', | ||||
|   | ||||
| @@ -245,6 +245,7 @@ sub mknetboot | ||||
|         my $rootimgdir; | ||||
|         my $nodebootif; # nodebootif will be used if noderes.installnic is not set | ||||
|         my $dump; # for kdump, its format is "nfs://<nfs_server_ip>/<kdump_path>" | ||||
|         my $rootfstype;  | ||||
|  | ||||
|         my $ent = $oents{$node}->[0]; #ostab->getNodeAttribs($node, ['os', 'arch', 'profile']); | ||||
|         if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) { | ||||
| @@ -254,12 +255,13 @@ sub mknetboot | ||||
|         	    if (!$osimagetab) { | ||||
|         	        $osimagetab=xCAT::Table->new('osimage', -create=>1); | ||||
|         	    } | ||||
|         	    (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod'); | ||||
|         	    (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod', 'rootfstype'); | ||||
|         	    if ($ref) { | ||||
|                     $img_hash{$imagename}->{osver}=$ref->{'osvers'}; | ||||
|                     $img_hash{$imagename}->{osarch}=$ref->{'osarch'}; | ||||
|                     $img_hash{$imagename}->{profile}=$ref->{'profile'}; | ||||
|                     $img_hash{$imagename}->{provmethod}=$ref->{'provmethod'}; | ||||
|                     $img_hash{$imagename}->{rootfstype} = $ref->{rootfstype}; | ||||
|                     if (!$linuximagetab) { | ||||
|                 	    $linuximagetab=xCAT::Table->new('linuximage', -create=>1); | ||||
|                     } | ||||
| @@ -288,6 +290,8 @@ sub mknetboot | ||||
| 	        $arch  = $ph->{osarch}; | ||||
| 	        $profile = $ph->{profile}; | ||||
|  | ||||
|             $rootfstype = $ph->{rootfstype}; | ||||
|  | ||||
| 	        $rootimgdir=$ph->{rootimgdir}; | ||||
|             unless ($rootimgdir) { | ||||
|                 $rootimgdir="$installroot/netboot/$osver/$arch/$profile"; | ||||
| @@ -302,6 +306,10 @@ sub mknetboot | ||||
|             $arch    = $ent->{arch}; | ||||
|             $profile = $ent->{profile}; | ||||
|             $rootimgdir="$installroot/netboot/$osver/$arch/$profile"; | ||||
|              | ||||
|             $rootfstype = "nfs"; # TODO: try to get it from the option or table | ||||
|             # $dump; # TODO: set the dump value here | ||||
|  | ||||
|         } | ||||
|  | ||||
|         #print"osvr=$osver, arch=$arch, profile=$profile, imgdir=$rootimgdir\n"; | ||||
| @@ -328,18 +336,25 @@ sub mknetboot | ||||
|                 }); | ||||
|                 next; | ||||
|             } | ||||
| 	    if (!-r "$rootimgdir/initrd-statelite.gz") { | ||||
| 	        if (!-r "$rootimgdir/initrd-statelite.gz") { | ||||
|                 if (! -r "$rootimgdir/initrd.gz") { | ||||
|                     $callback->({ | ||||
|                         error=>[qq{Did you run "genimage" before running "liteimg"? initrd.gz or initrd-statelite.gz cannot be found}], | ||||
|                         errorcode=>[1] | ||||
| 				}); | ||||
| 				    }); | ||||
|                     next; | ||||
|                 } | ||||
| 		else { | ||||
| 		    copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-statelite.gz"); | ||||
| 		        else { | ||||
| 		            copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-statelite.gz"); | ||||
|                 } | ||||
| 	    }  | ||||
| 	        }  | ||||
|             if ( $rootfstype eq "ramdisk" and ! -r "$rootimgdir/rootimg-statelite.gz") { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{No packed image for platform $osver, architecture $arch and profile $profile, please run "liteimg" to create it.}], | ||||
|                     errorcode => [1] | ||||
|                 }); | ||||
|                 next; | ||||
|             } | ||||
|         } else { | ||||
|             unless ( -r "$rootimgdir/kernel") { | ||||
|                 $callback->({ | ||||
| @@ -347,20 +362,20 @@ sub mknetboot | ||||
|                     errorcode=>[1] | ||||
| 			    }); | ||||
|                 next; | ||||
| 	    } | ||||
| 	    if (!-r "$rootimgdir/initrd-stateless.gz") { | ||||
| 	        } | ||||
| 	        if (!-r "$rootimgdir/initrd-stateless.gz") { | ||||
|                 if (! -r "$rootimgdir/initrd.gz") { | ||||
|                     $callback->({ | ||||
|                         error=>[qq{Did you run "genimage" before running "packimage"? initrd.gz or initrd-stateless.gz cannot be found}], | ||||
|                         errorcode=>[1] | ||||
| 				}); | ||||
| 				    }); | ||||
|                     next; | ||||
|                 } | ||||
| 		else { | ||||
| 		    copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); | ||||
| 		        else { | ||||
| 		            copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); | ||||
|                 } | ||||
|             } | ||||
| 	    unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.sfs" ) { | ||||
| 	        unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.sfs" ) { | ||||
|                 $callback->({ | ||||
|                     error=>["No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage (e.g.  packimage -o $osver -p $profile -a $arch"], | ||||
|                     errorcode => [1]}); | ||||
| @@ -470,32 +485,36 @@ sub mknetboot | ||||
|         } | ||||
|         my $kcmdline; # add two more arguments: XCAT=xcatmaster:xcatport and ifname=<eth0>:<mac address> | ||||
| 	    if($statelite){ | ||||
| 		    # get entry for nfs root if it exists: | ||||
| 		    # have to get nfssvr and nfsdir from noderes table | ||||
| 		    my $nfssrv = $imgsrv; | ||||
| 		    my $nfsdir = $rootimgdir; | ||||
| 		    if($ient->{nfsserver} ){ | ||||
| 			    $nfssrv = $ient->{nfsserver}; | ||||
| 		    } | ||||
| 		    if($ient->{nfsdir} ne ''){	 | ||||
| 			    $nfsdir = $ient->{nfsdir} . "/netboot/$osver/$arch/$profile"; | ||||
|             if ($rootfstype ne "ramdisk") { | ||||
| 		        # get entry for nfs root if it exists: | ||||
| 		        # have to get nfssvr and nfsdir from noderes table | ||||
| 		        my $nfssrv = $imgsrv; | ||||
| 		        my $nfsdir = $rootimgdir; | ||||
| 		        if($ient->{nfsserver} ){ | ||||
| 			        $nfssrv = $ient->{nfsserver}; | ||||
| 		        } | ||||
| 		        if($ient->{nfsdir} ne ''){	 | ||||
| 			        $nfsdir = $ient->{nfsdir} . "/netboot/$osver/$arch/$profile"; | ||||
|                         #this code sez, "if nfsdir starts with //, then | ||||
|                         #use a absolute path, i.e. do not append xCATisms" | ||||
|                         #this is required for some statelite envs. | ||||
|                         #still open for debate. | ||||
|  | ||||
| 			    if($ient->{nfsdir} =~ m!^//!) { | ||||
| 				    $nfsdir = $ient->{nfsdir}; | ||||
| 				    $nfsdir =~ s!^/!!; | ||||
| 			    } | ||||
| 		    } | ||||
| 			        if($ient->{nfsdir} =~ m!^//!) { | ||||
| 				        $nfsdir = $ient->{nfsdir}; | ||||
| 				        $nfsdir =~ s!^/!!; | ||||
| 			        } | ||||
| 		        } | ||||
|  | ||||
|             # special case for redhat6, fedora12/13 | ||||
|             if ($osver =~ m/rhel6/ || $osver =~ m/rhels6/  | ||||
|                 || $osver =~ m/fedora12/ || $osver =~ m/fedora13/ ) { | ||||
|                 $kcmdline = "root=nfs:$nfssrv:$nfsdir/rootimg:ro STATEMNT="; | ||||
|                 # special case for redhat6, fedora12/13 | ||||
|                 if ($osver =~ m/rhel6/ || $osver =~ m/rhels6/  | ||||
|                     || $osver =~ m/fedora12/ || $osver =~ m/fedora13/ ) { | ||||
|                     $kcmdline = "root=nfs:$nfssrv:$nfsdir/rootimg:ro STATEMNT="; | ||||
|                 } else { | ||||
|                     $kcmdline = "NFSROOT=$nfssrv:$nfsdir STATEMNT=";	 | ||||
|                 } | ||||
|             } else { | ||||
|                 $kcmdline = "NFSROOT=$nfssrv:$nfsdir STATEMNT=";	 | ||||
|                 $kcmdline =  "imgurl=http://$imgsrv/$rootimgdir/rootimg-statelite.gz STATEMNT="; | ||||
|             } | ||||
|  | ||||
|             # add support for subVars in the value of "statemnt" | ||||
| @@ -523,20 +542,22 @@ sub mknetboot | ||||
| 		    $kcmdline .= $statemnt ." "; | ||||
| 		    $kcmdline .= | ||||
| 			    "XCAT=$xcatmaster:$xcatdport "; | ||||
|             # BEGIN service node | ||||
|             my $isSV = xCAT::Utils->isServiceNode(); | ||||
|             my $res = xCAT::Utils->runcmd("hostname", 0); | ||||
|             my $sip = xCAT::NetworkUtils->getipaddr($res);  # this is the IP of service node | ||||
|             if($isSV and (($xcatmaster eq $sip) or ($xcatmaster eq $res))) { | ||||
|                 # if the NFS directory in litetree is on the service node, | ||||
|                 # and it is not exported, then it will be mounted automatically | ||||
|                 xCAT::SvrUtils->setupNFSTree($node, $sip, $callback); | ||||
|                 # then, export the statemnt directory if it is on the service node | ||||
|                 if($statemnt) { | ||||
|                     xCAT::SvrUtils->setupStatemnt($sip, $statemnt, $callback); | ||||
|             if ($rootfstype ne "ramdisk") { | ||||
|                 # BEGIN service node | ||||
|                 my $isSV = xCAT::Utils->isServiceNode(); | ||||
|                 my $res = xCAT::Utils->runcmd("hostname", 0); | ||||
|                 my $sip = xCAT::NetworkUtils->getipaddr($res);  # this is the IP of service node | ||||
|                 if($isSV and (($xcatmaster eq $sip) or ($xcatmaster eq $res))) { | ||||
|                     # if the NFS directory in litetree is on the service node, | ||||
|                     # and it is not exported, then it will be mounted automatically | ||||
|                     xCAT::SvrUtils->setupNFSTree($node, $sip, $callback); | ||||
|                     # then, export the statemnt directory if it is on the service node | ||||
|                     if($statemnt) { | ||||
|                         xCAT::SvrUtils->setupStatemnt($sip, $statemnt, $callback); | ||||
|                     } | ||||
|                 } | ||||
|                 # END service node | ||||
|             } | ||||
|             # END service node | ||||
| 	    } | ||||
|         else { | ||||
|             $kcmdline = | ||||
| @@ -654,6 +675,12 @@ sub mknetboot | ||||
| 	    } | ||||
|         my $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; | ||||
|         $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz" if ($statelite); | ||||
|         # special case for the dracut-enabled OSes | ||||
|         if ($osver =~ m/rhels6/ || $osver =~ m/rhel6/ || $osver =~ m/fedora12/ || $osver =~ m/fedora13/) { | ||||
|             if($statelite and $rootfstype eq "ramdisk") { | ||||
|                 $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; | ||||
|             } | ||||
|         } | ||||
|         $bptab->setNodeAttribs( | ||||
|             $node, | ||||
|             { | ||||
|   | ||||
| @@ -311,7 +311,7 @@ sub process_request { | ||||
|     my $verb = "Packing"; | ||||
|  | ||||
|     my $temppath; | ||||
|     my $oldumask; | ||||
|     my $oldmask; | ||||
|     unless ( -d $rootimg_dir) { | ||||
|        $callback->({error=>["$rootimg_dir does not exist, run genimage -o $osver -p $profile on a server with matching architecture"]}); | ||||
|        return; | ||||
|   | ||||
| @@ -100,6 +100,7 @@ sub mknetboot | ||||
|         my $profile; | ||||
|         my $rootimgdir; | ||||
|         my $nodebootif; # nodebootif will be used if noderes.installnic is not set | ||||
|         my $rootfstype; | ||||
| 	 | ||||
| 	    my $ent= $ntents->{$node}->[0]; | ||||
|         if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) { | ||||
| @@ -109,11 +110,12 @@ sub mknetboot | ||||
| 		        if (!$osimagetab) { | ||||
| 		            $osimagetab=xCAT::Table->new('osimage', -create=>1); | ||||
| 		        } | ||||
| 		        (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod'); | ||||
| 		        (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'rootfstype', 'provmethod'); | ||||
| 		        if ($ref) { | ||||
| 		            $img_hash{$imagename}->{osver}=$ref->{'osvers'}; | ||||
| 		            $img_hash{$imagename}->{osarch}=$ref->{'osarch'}; | ||||
| 		            $img_hash{$imagename}->{profile}=$ref->{'profile'}; | ||||
|                     $img_hash{$imagename}->{rootfstype}=$ref->{'rootfstype'}; | ||||
| 		            $img_hash{$imagename}->{provmethod}=$ref->{'provmethod'}; | ||||
| 		            if (!$linuximagetab) { | ||||
| 			            $linuximagetab=xCAT::Table->new('linuximage', -create=>1); | ||||
| @@ -136,6 +138,7 @@ sub mknetboot | ||||
| 	        $osver = $ph->{osver}; | ||||
| 	        $arch  = $ph->{osarch}; | ||||
| 	        $profile = $ph->{profile}; | ||||
|             $rootfstype = $ph->{rootfstype}; | ||||
|             $nodebootif = $ph->{nodebootif}; | ||||
| 	 | ||||
| 	        $rootimgdir = $ph->{rootimgdir}; | ||||
| @@ -147,6 +150,7 @@ sub mknetboot | ||||
| 	        $osver = $ent->{os}; | ||||
| 	        $arch    = $ent->{arch}; | ||||
| 	        $profile = $ent->{profile}; | ||||
|             $rootfstype = "nfs";    # TODO: try to get it from the option or table | ||||
| 	        $rootimgdir="$installroot/netboot/$osver/$arch/$profile"; | ||||
| 	    } | ||||
|  | ||||
| @@ -177,7 +181,6 @@ sub mknetboot | ||||
|         { | ||||
|             $suffix = 'sfs'; | ||||
|         } | ||||
|         #statelite images are not packed | ||||
|  | ||||
|         if ($statelite) { | ||||
|             unless ( -r "$rootimgdir/kernel") { | ||||
| @@ -187,6 +190,13 @@ sub mknetboot | ||||
|                 }); | ||||
|                 next; | ||||
|             }  | ||||
|             if ( $rootfstype eq "ramdisk" and ! -r "$rootimgdir/rootimg-statelite.gz" ) { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{No packed rootimage for the platform $osver, arch $arch and profile $profile, please run liteimg to create it}], | ||||
|                     errorcode=>[1] | ||||
|                 }); | ||||
|                 next; | ||||
|             } | ||||
|  | ||||
| 	    if (!-r "$rootimgdir/initrd-statelite.gz") { | ||||
|                 if (! -r "$rootimgdir/initrd.gz") { | ||||
| @@ -327,22 +337,27 @@ sub mknetboot | ||||
|         my $kcmdline; | ||||
|         if ($statelite)  | ||||
|         { | ||||
|             # get entry for nfs root if it exists; | ||||
|             # have to get nfssvr, nfsdir and xcatmaster from noderes table | ||||
|             my $nfssrv = $imgsrv; | ||||
|             my $nfsdir = $rootimgdir; | ||||
|  | ||||
|             if ($restab) { | ||||
|                 my $resHash = $restab->getNodeAttribs($node, ['nfsserver', 'nfsdir']); | ||||
|                 if($resHash and $resHash->{nfsserver}) { | ||||
|                     $nfssrv = $resHash->{nfsserver}; | ||||
|                 } | ||||
|                 if($resHash and $resHash->{nfsdir} ne '') { | ||||
|                     $nfsdir = $resHash->{nfsdir} . "/netboot/$osver/$arch/$profile"; | ||||
|             if($rootfstype ne "ramdisk") { | ||||
|                 # get entry for nfs root if it exists; | ||||
|                 # have to get nfssvr, nfsdir and xcatmaster from noderes table | ||||
|                 my $nfssrv = $imgsrv; | ||||
|                 my $nfsdir = $rootimgdir; | ||||
|                  | ||||
|                 if ($restab) { | ||||
|                     my $resHash = $restab->getNodeAttribs($node, ['nfsserver', 'nfsdir']); | ||||
|                     if($resHash and $resHash->{nfsserver}) { | ||||
|                         $nfssrv = $resHash->{nfsserver}; | ||||
|                     } | ||||
|                     if($resHash and $resHash->{nfsdir} ne '') { | ||||
|                         $nfsdir = $resHash->{nfsdir} . "/netboot/$osver/$arch/$profile"; | ||||
|                     } | ||||
|                 } | ||||
|                 $kcmdline =  | ||||
|                     "NFSROOT=$nfssrv:$nfsdir STATEMNT="; | ||||
|             } else { | ||||
|                 $kcmdline = | ||||
|                     "imgurl=http://$imgsrv/$rootimgdir/rootimg-statelite.gz STATEMNT="; | ||||
|             } | ||||
|             $kcmdline =  | ||||
|                 "NFSROOT=$nfssrv:$nfsdir STATEMNT="; | ||||
|             # add support for subVars in the value of "statemnt" | ||||
|             my $statemnt=""; | ||||
|             if (exists($stateHash->{$node})) { | ||||
| @@ -368,20 +383,22 @@ sub mknetboot | ||||
|             $kcmdline .= $statemnt . " "; | ||||
|             # get "xcatmaster" value from the "noderes" table | ||||
|              | ||||
|             #BEGIN service node  | ||||
|             my $isSV = xCAT::Utils->isServiceNode(); | ||||
|             my $res = xCAT::Utils->runcmd("hostname", 0); | ||||
|             my $sip = xCAT::NetworkUtils->getipaddr($res);  # this is the IP of service node | ||||
|             if($isSV and (($xcatmaster eq $sip) or ($xcatmaster eq $res))) { | ||||
|                 # if the NFS directory in litetree is on the service node,  | ||||
|                 # and it is not exported, then it will be mounted automatically  | ||||
|                 xCAT::SvrUtils->setupNFSTree($node, $sip, $callback); | ||||
|                 # then, export the statemnt directory if it is on the service node | ||||
|                 if($statemnt) { | ||||
|                     xCAT::SvrUtils->setupStatemnt($sip, $statemnt, $callback); | ||||
|             if($rootfstype ne "ramdisk") { | ||||
|                 #BEGIN service node  | ||||
|                 my $isSV = xCAT::Utils->isServiceNode(); | ||||
|                 my $res = xCAT::Utils->runcmd("hostname", 0); | ||||
|                 my $sip = xCAT::NetworkUtils->getipaddr($res);  # this is the IP of service node | ||||
|                 if($isSV and (($xcatmaster eq $sip) or ($xcatmaster eq $res))) { | ||||
|                     # if the NFS directory in litetree is on the service node,  | ||||
|                     # and it is not exported, then it will be mounted automatically  | ||||
|                     xCAT::SvrUtils->setupNFSTree($node, $sip, $callback); | ||||
|                     # then, export the statemnt directory if it is on the service node | ||||
|                     if($statemnt) { | ||||
|                         xCAT::SvrUtils->setupStatemnt($sip, $statemnt, $callback); | ||||
|                     } | ||||
|                 } | ||||
|                 #END sevice node  | ||||
|             } | ||||
|             #END sevice node  | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|   | ||||
| @@ -55,14 +55,18 @@ sub process_request { | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
|     my $rootfstype; | ||||
|     my $exlistloc; # borrowed from packimage.pm | ||||
| 	my $osver; | ||||
| 	my $arch; | ||||
| 	my $profile; | ||||
| 	my $rootimg_dir; | ||||
|     my $exlist; # it is used when rootfstype = ramdisk | ||||
| 	my $destdir; | ||||
| 	my $imagename; | ||||
|  | ||||
| 	GetOptions( | ||||
|         "rootfstype|t=s" => \$rootfstype, | ||||
| 		"profile|p=s" => \$profile, | ||||
| 		"arch|a=s" => \$arch, | ||||
| 		"osver|o=s" => \$osver, | ||||
| @@ -110,15 +114,26 @@ sub process_request { | ||||
| 			return; | ||||
| 		} | ||||
| 		# get the os, arch, and profile from the image name table. | ||||
| 		(my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile'); | ||||
| 		(my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'rootfstype', 'osvers', 'osarch', 'profile'); | ||||
| 		if (!$ref) { | ||||
| 			$callback->({error=>["Cannot find image \'$imagename\' from the osimage table."],errorcode=>[1]}); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
|         $rootfstype = $ref->{'rootfstype'}; | ||||
| 		$osver=$ref->{'osvers'}; | ||||
| 		$arch=$ref->{'osarch'}; | ||||
| 		$profile=$ref->{'profile'}; | ||||
|  | ||||
|         # get the exlist and rootimgdir attributes | ||||
|         (my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'exlist', 'rootimgdir'); | ||||
|         unless($ref1) { | ||||
|             $callback->({error=>[qq{Cannot find image '$imagename' from the osimage table.}], errorcode => [1]}); | ||||
|         } | ||||
|         $destdir = $ref1->{'rootimgdir'}; | ||||
|         $exlistloc = $ref1->{'exlist'}; | ||||
|         $rootimg_dir = "$destdir/rootimg"; | ||||
|  | ||||
| 	} # end of case where they give us osimage. | ||||
|  | ||||
| 	unless ($osver and $arch and $profile ) { | ||||
| @@ -126,8 +141,10 @@ sub process_request { | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	$destdir="$installroot/netboot/$osver/$arch/$profile"; | ||||
| 	$rootimg_dir="$destdir/rootimg"; | ||||
|     unless ($destdir) { | ||||
| 	    $destdir="$installroot/netboot/$osver/$arch/$profile"; | ||||
| 	    $rootimg_dir="$destdir/rootimg"; | ||||
|     } | ||||
| 	my $oldpath=cwd(); | ||||
| 	 | ||||
| 	# now we have all the info we need: | ||||
| @@ -173,13 +190,28 @@ sub process_request { | ||||
| 	#    } | ||||
| 	#} | ||||
|  | ||||
|     my $distname = $osver; | ||||
|     unless ( -r "$::XCATROOT/share/xcat/netboot/$distname/" or not $distname) { | ||||
|         chop($distname); | ||||
|     } | ||||
|  | ||||
|     unless($distname) { | ||||
|         $callback->({error=>["Unable to find $::XCATROOT/share/xcat/netboot directory for $osver"], errorcode=>[1]}); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
| 	unless ($imagename) { | ||||
|         #store the image in the DB | ||||
| 	if (!$imagename) { | ||||
| 	    my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($osver, $arch, $profile, 'statelite'); | ||||
| 	    if ($ret[0] != 0) { | ||||
| 		$callback->({error=>["Error when updating the osimage tables: " . $ret[1]]}); | ||||
| 	    if ($ret[0]) { | ||||
| 		    $callback->({error=>["Error when updating the osimage tables: " . $ret[1]]}); | ||||
| 	    } | ||||
|             $imagename="$osver-$arch-statelite-$profile" | ||||
|         $imagename="$osver-$arch-statelite-$profile"; | ||||
|  | ||||
|         $exlistloc = xCAT::SvrUtils->get_exlist_file_name("$installroot/custom/netboot/$distname", $profile, $osver, $arch);  | ||||
|         unless ($exlistloc) {  | ||||
|             $exlistloc = xCAT::SvrUtils->get_exlist_file_name("$::XCATROOT/share/xcat/netboot/$distname", $profile, $osver, $arch);  | ||||
|         } | ||||
| 	} | ||||
|     # check if the file "litefile.save" exists or not | ||||
|     # if it doesn't exist, then we get the synclist, and run liteMe | ||||
| @@ -390,6 +422,84 @@ sub process_request { | ||||
|         system("cp -a $::XCATROOT/share/xcat/netboot/add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite"); | ||||
|     } | ||||
|  | ||||
|     # newly-introduced code for the rootfs with "ramdisk" as its type | ||||
|     if( $rootfstype eq "ramdisk" ) { | ||||
|         my $xcat_packimg_tmpfile = "/tmp/xcat_packimg.$$"; | ||||
|         my $excludestr = "find . "; | ||||
|         my $includestr; | ||||
|         if ($exlistloc) { | ||||
|             my $exlist; | ||||
|             my $excludetext; | ||||
|             open($exlist,"<",$exlistloc); | ||||
|             system("echo -n > $xcat_packimg_tmpfile"); | ||||
|             while (<$exlist>) { | ||||
|                 $excludetext .= $_; | ||||
|             } | ||||
|             close($exlist); | ||||
|  | ||||
|             #handle the #INLCUDE# tag recursively | ||||
|             my $idir = dirname($exlistloc); | ||||
|             my $doneincludes=0; | ||||
|             while (not $doneincludes) { | ||||
|                 $doneincludes=1; | ||||
|                 if ($excludetext =~ /#INCLUDE:[^#^\n]+#/) { | ||||
|                     $doneincludes=0; | ||||
|                     $excludetext =~ s/#INCLUDE:([^#^\n]+)#/include_file($1,$idir)/eg;  | ||||
|                 } | ||||
|             } | ||||
|          | ||||
|             my @tmp=split("\n", $excludetext); | ||||
|             foreach (@tmp) { | ||||
|                 chomp $_; | ||||
|                 s/\s*#.*//;      #-- remove comments  | ||||
|                 next if /^\s*$/; #-- skip empty lines | ||||
|                 if (/^\+/) { | ||||
|                     s/^\+//; #remove '+' | ||||
|                     $includestr .= "-path '". $_ ."' -o "; | ||||
|                 } else { | ||||
|                     s/^\-//;  #remove '-' if any | ||||
|                     $excludestr .= "'!' -path '".$_."' -a "; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $excludestr =~ s/-a $//; | ||||
|         if ($includestr) { | ||||
|             $includestr =~ s/-o $//; | ||||
|             $includestr = "find . " .  $includestr; | ||||
|         } | ||||
|  | ||||
|         print "\nexcludestr=$excludestr\n\n includestr=$includestr\n\n"; # debug | ||||
|          | ||||
|         # some rpms like atftp mount the rootimg/proc to /proc, we need to make sure rootimg/proc is free of junk  | ||||
|         # before packaging the image | ||||
|         system("umount $rootimg_dir/proc"); | ||||
|  | ||||
|         my $verb = "Packing"; | ||||
|  | ||||
|         my $temppath; | ||||
|         my $oldmask; | ||||
|         $callback->({data=>["$verb contents of $rootimg_dir"]}); | ||||
|         unlink("$destdir/rootimg-statelite.gz"); | ||||
|         if ($exlistloc) { | ||||
|             chdir("$rootimg_dir"); | ||||
|             system("$excludestr >> $xcat_packimg_tmpfile"); | ||||
|             if ( $includestr) { | ||||
|                 system("$includestr >> $xcat_packimg_tmpfile"); | ||||
|             } | ||||
|             $excludestr = "cat $xcat_packimg_tmpfile |cpio -H newc -o | gzip -c - > ../rootimg-statelite.gz"; | ||||
|         } else { | ||||
|             $excludestr = "find . |cpio -H newc -o | gzip -c - > ../rootimg-statelite.gz"; | ||||
|         } | ||||
|         $oldmask = umask 0077; | ||||
|         chdir("$rootimg_dir"); | ||||
|         xCAT::Utils->runcmd("$excludestr"); | ||||
|         chmod 0644, "$destdir/rootimg-statelite.gz"; | ||||
|         umask $oldmask; | ||||
|          | ||||
|         system("rm -f $xcat_packimg_tmpfile"); | ||||
|     } | ||||
|     chdir($oldpath); | ||||
| } | ||||
|  | ||||
| sub liteMe { | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #!/bin/sh | ||||
| echo $drivers | ||||
| dracut_install wget cpio gzip dash  modprobe touch echo cut | ||||
| dracut_install grep ifconfig hostname awk egrep grep dirname | ||||
| dracut_install fsck.ext3 fsck.ext4 | ||||
| dracut_install wget cpio gzip dash  modprobe touch echo cut wc | ||||
| dracut_install grep ifconfig hostname awk egrep grep dirname expr | ||||
| dracut_install fsck.ext3 fsck.ext4 mount.nfs | ||||
| inst "$moddir/xcatroot" "/sbin/xcatroot" | ||||
| inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| #!/bin/sh | ||||
| #!/bin/sh -x | ||||
| NEWROOT=$3 | ||||
|  | ||||
| RWDIR=.statelite | ||||
| XCATMASTER=$XCAT | ||||
|  | ||||
| if [ ! -z "$imgurl" ]; then | ||||
| @@ -50,6 +50,80 @@ elif [ -r /rootimg.gz ]; then | ||||
|     gzip -cd /rootimg.gz |cpio -idum | ||||
|   fi | ||||
|   echo Done | ||||
| elif [ -r /rootimg-statelite.gz ]; then | ||||
|   echo Setting up RAM-root tmpfs for statelite mode. | ||||
|   mount -t tmpfs rootfs $NEWROOT | ||||
|   cd $NEWROOT | ||||
|   echo -n "Extracting root filesystem:" | ||||
|   if [ -x /bin/cpio ]; then | ||||
|     gzip -cd /rootimg-statelite.gz |/bin/cpio -idum | ||||
|   else | ||||
|     gzip -cd /rootimg-statelite.gz |cpio -idum | ||||
|   fi | ||||
|   echo Done | ||||
|   # then, the statelite staffs will be processed | ||||
|   echo Setting up Statelite  | ||||
|   modprobe nfs | ||||
|   MAXTRIES=7 | ||||
|   ITER=0 | ||||
|   if [ ! -e "$NEWROOT/$RWDIR" ]; then | ||||
|     echo "" | ||||
|     echo "The /$RWDIR directory doesn't exist in the rootimg... " | ||||
|     echo "" | ||||
|     /bin/sh | ||||
|   fi | ||||
|  | ||||
|   if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then | ||||
|     echo "" | ||||
|     echo "$NEWROOT/etc/init.d/statelite doesn't exist... " | ||||
|     echo "" | ||||
|     /bin/sh | ||||
|   fi | ||||
|  | ||||
|   mount -t tmpfs rw $NEWROOT/$RWDIR | ||||
|   mkdir -p $NEWROOT/$RWDIR/tmpfs | ||||
|   ME=`hostname` | ||||
|  | ||||
|   # mount the SNAPSHOT directory here for persistent use. | ||||
|   if [ ! -z $STATEMNT ]; then | ||||
|     SNAPSHOTSERVER=${STATEMNT%:*} | ||||
|     SNAPSHOTROOT=${STATEMNT#*/} | ||||
|     if [ -z $SNAPSHOTROOT ]; then | ||||
|         SNAPSHOTROOT=$SNAPSHOTSERVER | ||||
|         SNAPSHOTSERVER= | ||||
|     fi | ||||
|   fi | ||||
|  | ||||
|   if [ ! -z $SNAPSHOTSERVER ]; then | ||||
|     mkdir -p $NEWROOT/$RWDIR/persistent | ||||
|     MAXTRIES=5 | ||||
|     ITER=0 | ||||
|     while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o nolock,rsize=32768,tcp,timeo=14; do | ||||
|         ITER=$(( ITER + 1 )) | ||||
|         if [ "$ITER" == "$MAXTRIES" ]; then | ||||
|             echo "You are 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." | ||||
|             /bin/sh | ||||
|             exit | ||||
|         fi | ||||
|         RS=$(( $RANDOM % 20 )) | ||||
|         echo "Trying again in $RS seconds ..." | ||||
|         sleep $RS | ||||
|     done | ||||
|   fi | ||||
|  | ||||
|   $NEWROOT/etc/init.d/statelite | ||||
|   fastboot=yes | ||||
|   export fastboot | ||||
|   keep_old_ip=yes | ||||
|   export keep_old_ip | ||||
|  | ||||
|   mount -n --bind /dev $NEWROOT/dev | ||||
|   mount -n --bind /proc $NEWROOT/proc | ||||
|   mount -n --bind /sys $NEWROOT/sys | ||||
|  | ||||
| else | ||||
|   echo -n Failed to download image, panicing in 5... | ||||
|   for i in 4 3 2 1 0; do | ||||
| @@ -71,24 +145,26 @@ else | ||||
|   exit | ||||
| fi | ||||
| cd / | ||||
| for lf in /tmp/dhclient.*.lease; do | ||||
|  | ||||
| if [ -z $STATEMNT ]; then | ||||
|   for lf in /tmp/dhclient.*.lease; do | ||||
|     netif=${lf#*.} | ||||
|     netif=${netif%.*} | ||||
|     cp $lf  "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" | ||||
| done | ||||
|   done | ||||
|  | ||||
| if [ ! -z "$ifname" ]; then | ||||
|   if [ ! -z "$ifname" ]; then | ||||
|     MACX=${ifname#*:} | ||||
|     ETHX=${ifname%:$MACX*} | ||||
| elif [ ! -z "$netdev" ]; then | ||||
|   elif [ ! -z "$netdev" ]; then | ||||
|     ETHX=$netdev | ||||
|     MACX=`ip link show $netdev | grep ether | awk '{print $2}'` | ||||
| elif [ ! -z "$BOOTIF" ]; then | ||||
|   elif [ ! -z "$BOOTIF" ]; then | ||||
|     MACX=$BOOTIF | ||||
|     ETHX=`ifconfig |grep -i $BOOTIF | awk '{print $1}'` | ||||
| fi | ||||
|   fi | ||||
|  | ||||
| if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then | ||||
|   if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then | ||||
|     if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then | ||||
|         touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX | ||||
|     fi | ||||
| @@ -96,6 +172,7 @@ if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then | ||||
|     echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX | ||||
|     echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX | ||||
|     echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX | ||||
|   fi | ||||
| fi | ||||
|  | ||||
| cp /etc/resolv.conf "$NEWROOT/etc/" | ||||
|   | ||||
| @@ -789,6 +789,7 @@ sub mkinitrd { | ||||
| 	 | ||||
| # add some functions | ||||
|  	print $inifile <<EOS1; 	 | ||||
| set -x | ||||
| NEWROOT="/sysroot" | ||||
| SHELL="/bin/sh" | ||||
| RWDIR=".statelite" | ||||
| @@ -998,7 +999,6 @@ for i in `cat /proc/cmdline`; do | ||||
|             rm -f \$FILENAME | ||||
|           fi | ||||
|         done | ||||
|         NFS=0 | ||||
|       fi | ||||
|       if [ "nfs" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then | ||||
|         NFS=1 | ||||
| @@ -1012,16 +1012,19 @@ for i in `cat /proc/cmdline`; do | ||||
| 	SERVER=`echo \$VALUE|awk -F: '{print \$1}'` | ||||
| 	ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` | ||||
|    elif [ "\$KEY" == 'STATEMNT' ]; then | ||||
| 	NFSROOT=1 | ||||
| 	STATELITE=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 | ||||
|     # the VALUE may be null | ||||
|     if [ ! -z \$VALUE ]; then | ||||
| 	    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 | ||||
|    fi | ||||
| done | ||||
|  | ||||
| @@ -1031,141 +1034,145 @@ fancydisplay | ||||
|  | ||||
| echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug | ||||
|  | ||||
| # NFSROOT code here: | ||||
| if [ "\$NFSROOT" = "1" ]; then | ||||
| 	echo Setting up Statelite | ||||
| 	# for loop back mounting capability! | ||||
| 	mknod /dev/loop0 b 7 0 | ||||
| 	mkdir -p \$NEWROOT | ||||
|  	MAXTRIES=5 | ||||
| 	ITER=0 | ||||
| 	ME=`hostname` | ||||
| 	while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14 | ||||
| 	do | ||||
| 		ITER=\$(expr \$ITER + 1) | ||||
| 		if [ "\$ITER" == "\$MAXTRIES" ] | ||||
|       		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' | ||||
| 2.  Is DNS set up?  Maybe that's why I can't mount \${SERVER}. | ||||
| 3.  The nfs modules aren't set right in this initfs?" | ||||
|      | ||||
| 			shell | ||||
| 			exit | ||||
| 		fi | ||||
| 		echo -e "\${RED}Could not mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" | ||||
| 		RS=`expr \$RANDOM % 30` | ||||
| 		echo -e "Trying again in \$RS seconds" | ||||
| 		sleep \$RS | ||||
| 	done | ||||
|  | ||||
| # now we need to mount the rest of the system.  This is the read/write portions | ||||
| #echo "Mounting Snapshot directories" | ||||
|  | ||||
| 	if [ ! -e "\$NEWROOT/\$RWDIR" ] | ||||
| 	then | ||||
| 		echo "" | ||||
| 		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 | ||||
|  | ||||
| 	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 run liteimg for the current osimage" | ||||
| 		echo "" | ||||
| 		shell | ||||
| 	done | ||||
| 	grep '\\(shell\\)' /proc/cmdline >/dev/null && shell | ||||
| 	mount -t tmpfs rw  -o mode=$permission \$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 -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14 | ||||
| 		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/tmpfs/var/lib/dhclient ] | ||||
| 	then | ||||
| 		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}/tmpfs/var/lib/dhclient/dhclient-\$IFACE.leases | ||||
| 	cp -fp /var/lib/dhclient/dhclient.leases \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcp/dhclient-\$IFACE.leases | ||||
|  | ||||
|  | ||||
| 	[ -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 [ ! -e \$NEWROOT/etc/init.d/statelite ] | ||||
| 	do | ||||
| 		echo "\$NEWROOT/etc/init.d/statelite does not exist in image!" | ||||
| 		shell | ||||
| # STATELITE code here: | ||||
| if [ "\$STATELITE" = "1" ]; then | ||||
|     echo Setting up Statelite | ||||
|     # for loop back mouting capability! | ||||
|     mknod /dev/loop0 b 7 0 | ||||
|     mkdir -p \$NEWROOT | ||||
|     MAXTRIES=5 | ||||
|     ITER=0 | ||||
|     ME=`hostname` | ||||
|     if [ "\$NFSROOT" = "1" ]; then | ||||
|         while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do | ||||
|             ITER=\$(expr \$ITER + 1) | ||||
|             if [ "\$ITER" == "\$MAXTRIES" ]; then | ||||
|                 echo "You are dead. rpower \$ME boot to play again." | ||||
|                 echo "Possible problems: | ||||
| 1. This initrd wasn't craeted for the statelite node? | ||||
| 2. Is DNS set up? Maybe that's why I can't mount \${SERVER}. | ||||
| 3. The nfs modules aren't set right in this initfs?" | ||||
|                 shell | ||||
|                 exit | ||||
|             fi | ||||
|             echo -e "\${RED}Could not mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" | ||||
|             RS=`expr \$RANDOM % 30` | ||||
|             echo -e "Trying again in \$RS seconds" | ||||
|             sleep \$RS | ||||
|         done | ||||
|     elif [ "\$NFS" = "1" ]; then | ||||
|         echo -e "\${RED}The \"imgurl=\" value should not be nfs-type if statelite mode is enabled \$RESET" | ||||
|         shell | ||||
|         exit | ||||
| 	done | ||||
|     else | ||||
|         # for statelite mode on top of the ramdisk | ||||
| EOMS | ||||
|     print $inifile "if [ -r /rootimg-statelite.gz ]; then\n"; | ||||
|     print $inifile "echo Setting up RAM-root tmpfs.\n"; | ||||
|     if ($rootlimit) { | ||||
|         print $inifile "    mount -o size=$rootlimit mode=755 -t tmpfs rootfs \$NEWROOT \n"; | ||||
|     } else { | ||||
|         print $inifile "    mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; | ||||
|     } | ||||
|     print $inifile <<EOMS; | ||||
|             modprobe nfs | ||||
|             cd \$NEWROOT | ||||
|             echo -n "Extracting root file system:" | ||||
|             if [ -x /bin/cpio ]; then | ||||
|                 gzip -cd /rootimg-statelite.gz |/bin/cpio -idum | ||||
|             else | ||||
|                 gzip -cd /rootimg-statelite.gz |cpio -idum | ||||
|             fi | ||||
|             echo Done | ||||
|         else | ||||
|             echo -e "\${RED} Couldnot find rootimg-statelite.gz for statelite on top of ramdisk \$RESET" | ||||
|             shell | ||||
|             exit | ||||
|         fi | ||||
|  | ||||
| 	# do all the mounts: | ||||
| 	\$NEWROOT/etc/init.d/statelite	 | ||||
|     fi | ||||
|     # now we need to mount the rest of the system.  | ||||
|     if [ ! -e "\$NEWROOT/\$RWDIR" ]; then | ||||
|         echo "" | ||||
|         echo -e "\${RED}Hmmm... this NFS root directories doesn't have a /\$RWDIR directory for me to mount a rw filesystem. You'd better to create it... \${NORMAL}" | ||||
|         echo "" | ||||
|         shell | ||||
|         exit | ||||
|     fi | ||||
|  | ||||
| 	# give the debug shell just before we go if specified! | ||||
| 	grep '\(shell\)' /proc/cmdline > /dev/null && shell | ||||
|     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 run liteimg for the current osimage" | ||||
|         echo "" | ||||
|         shell | ||||
|         exit | ||||
|     done | ||||
|  | ||||
| 	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 | ||||
|     mount -t tmpfs rw -o mode=$permission \$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 -o nolock,rsize=32768; 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 | ||||
|  | ||||
|     # have to preserve the initial DHCP request. | ||||
|     if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhclient ]; then | ||||
|         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/tmpfs/var/lib/dhclient/dhclient-\$IFACE.leases | ||||
|     cp -fp /var/lib/dhclient/dhclient.leases \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcp/dhclient-\$IFACE.leases | ||||
|  | ||||
|     [ -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/ | ||||
|  | ||||
|     while [ ! -e \$NEWROOT/etc/init.d/statelite ]; do | ||||
|         echo -e "\${RED} \$NEWROOT/etc/init.d/statelite doesn't exist in the osimge! \${NORMAL}" | ||||
|         shell | ||||
|     done | ||||
|  | ||||
|     # 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 | ||||
|     mount -n --bind /dev/ \$NEWROOT/dev | ||||
|  | ||||
|     umount /sys | ||||
|     umount /proc | ||||
|  | ||||
|     if ! exec /sbin/switch_root -c /dev/console \$NEWROOT /sbin/init; then | ||||
|         echo "" | ||||
|         echo -e "\${RED}Couldn't switch_root. Something must be wrong with the root image.\${RESET}" | ||||
|         shell | ||||
|     fi | ||||
|  | ||||
| 	if ! exec /sbin/switch_root -c /dev/console \$NEWROOT /sbin/init | ||||
| 	then | ||||
| 		echo "" | ||||
| 		echo -e "\${RED}Couldn't switch_root.  Something must be wrong with NFS root image.\${RESET}" | ||||
| 	#	mount -t proc proc /proc | ||||
| 		shell | ||||
| 	fi | ||||
| 	exit | ||||
| fi | ||||
| # END NFSROOT/Statelite code | ||||
|  | ||||
| @@ -1176,20 +1183,20 @@ if [ -r /rootimg.sfs ]; then | ||||
|   mkdir -p /rw | ||||
|   mount -t squashfs /rootimg.sfs /ro | ||||
|   mount -t tmpfs rw /rw | ||||
|   mount -t aufs -o dirs=/rw:/ro mergedroot /sysroot | ||||
|   mkdir -p /sysroot/ro | ||||
|   mkdir -p /sysroot/rw | ||||
|   mount --move /ro /sysroot/ro | ||||
|   mount --move /rw /sysroot/rw | ||||
|   mount -t aufs -o dirs=/rw:/ro mergedroot \$NEWROOT | ||||
|   mkdir -p \$NEWROOT/ro | ||||
|   mkdir -p \$NEWROOT/rw | ||||
|   mount --move /ro \$NEWROOT/ro | ||||
|   mount --move /rw \$NEWROOT/rw | ||||
| EOMS | ||||
|    print $inifile "elif [ -r /rootimg.gz ]; then\n"; | ||||
|    print $inifile "echo Setting up RAM-root tmpfs.\n"; | ||||
|    if ($rootlimit) { | ||||
|       print $inifile "  mount -o size=$rootlimit mode=755 -t tmpfs rootfs /sysroot\n"; | ||||
|       print $inifile "  mount -o size=$rootlimit mode=755 -t tmpfs rootfs \$NEWROOT\n"; | ||||
|    } else { | ||||
|       print $inifile "  mount -o  mode=755 -t tmpfs rootfs /sysroot\n"; | ||||
|       print $inifile "  mount -o  mode=755 -t tmpfs rootfs \$NEWROOT\n"; | ||||
|    } | ||||
|    print $inifile "  cd /sysroot\n"; | ||||
|    print $inifile "  cd \$NEWROOT\n"; | ||||
|    print $inifile "  echo -n \"Extracting root filesystem:\"\n"; | ||||
|    print $inifile "  if [ -x /bin/cpio ]; then\n"; | ||||
|    print $inifile "  zcat /rootimg.gz |/bin/cpio -idum\n"; | ||||
| @@ -1220,11 +1227,11 @@ EOMS | ||||
|    print $inifile "  exit\n"; | ||||
|    print $inifile "fi\n"; | ||||
|    print $inifile "cd /\n"; | ||||
|    print $inifile "cp /var/lib/dhclient/dhclient.leases /sysroot/dev/.dhclient-\$IFACE.leases\n"; | ||||
|    print $inifile "cp /var/lib/dhclient/dhclient.leases /sysroot/var/lib/dhclient/dhclient-\$IFACE.leases\n"; | ||||
|    print $inifile 'if [ -z "$SNAPSHOTSERVER" ]; then cp /etc/resolv.conf /sysroot/etc/resolv.conf; fi'."\n"; | ||||
|    print $inifile "mknod /sysroot/dev/console c 5 1\n"; | ||||
|    print $inifile "exec switch_root -c /dev/console /sysroot /sbin/init\n"; | ||||
|    print $inifile "cp /var/lib/dhclient/dhclient.leases \$NEWROOT/dev/.dhclient-\$IFACE.leases\n"; | ||||
|    print $inifile "cp /var/lib/dhclient/dhclient.leases \$NEWROOT/var/lib/dhclient/dhclient-\$IFACE.leases\n"; | ||||
|    print $inifile 'if [ -z "$SNAPSHOTSERVER" ]; then cp /etc/resolv.conf \$NEWROOT/etc/resolv.conf; fi'."\n"; | ||||
|    print $inifile "mknod \$NEWROOT/dev/console c 5 1\n"; | ||||
|    print $inifile "exec switch_root -c /dev/console \$NEWROOT /sbin/init\n"; | ||||
|    close($inifile); | ||||
|  | ||||
|    open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart"); | ||||
| @@ -1301,29 +1308,27 @@ EOMS | ||||
|       } | ||||
|    } | ||||
|  | ||||
| 	# Copy udev and network scripts into initrd for s390x | ||||
| 	if ($arch eq "s390x") { | ||||
| 		# udev | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/etc/udev"); | ||||
| 		system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev"); | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/lib/udev"); | ||||
| 		system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev"); | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/proc/self"); | ||||
| 		system("cp -r /proc/self/oom_adj /tmp/xcatinitrd.$$/proc/self"); | ||||
| 		 | ||||
| 		# Network related scripts | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/etc/sysconfig"); | ||||
| 		system("cp -r $rootimg_dir/etc/sysconfig/* /tmp/xcatinitrd.$$/etc/sysconfig"); | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/sbin"); | ||||
| 		system("cp -r $rootimg_dir/sbin/* /tmp/xcatinitrd.$$/sbin"); | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/lib/modules/$kernelver"); | ||||
| 		system("cp -r $rootimg_dir/lib/modules/$kernelver/modules.dep /tmp/xcatinitrd.$$/lib/modules/$kernelver/modules.dep"); | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/etc/init.d"); | ||||
| 		system("cp -r $rootimg_dir/etc/init.d/* /tmp/xcatinitrd.$$/etc/init.d"); | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/lib64"); | ||||
| 		system("cp -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64"); | ||||
| 		system("mkdir -p /tmp/xcatinitrd.$$/var/run/netreport"); | ||||
| 	} | ||||
| 	# Copy udev and network scripts into initrd for s390x, which also works for other platforms | ||||
| 	# udev | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/etc/udev"); | ||||
| 	system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev"); | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/lib/udev"); | ||||
| 	system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev"); | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/proc/self"); | ||||
| 	system("cp -r /proc/self/oom_adj /tmp/xcatinitrd.$$/proc/self"); | ||||
| 	 | ||||
| 	# Network related scripts | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/etc/sysconfig"); | ||||
| 	system("cp -r $rootimg_dir/etc/sysconfig/* /tmp/xcatinitrd.$$/etc/sysconfig"); | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/sbin"); | ||||
| 	system("cp -r $rootimg_dir/sbin/* /tmp/xcatinitrd.$$/sbin"); | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/lib/modules/$kernelver"); | ||||
| 	system("cp -r $rootimg_dir/lib/modules/$kernelver/modules.dep /tmp/xcatinitrd.$$/lib/modules/$kernelver/modules.dep"); | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/etc/init.d"); | ||||
| 	system("cp -r $rootimg_dir/etc/init.d/* /tmp/xcatinitrd.$$/etc/init.d"); | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/lib64"); | ||||
| 	system("cp -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64"); | ||||
| 	system("mkdir -p /tmp/xcatinitrd.$$/var/run/netreport"); | ||||
| 	 | ||||
|    #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); | ||||
|    system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-$mode.gz"); | ||||
|   | ||||
| @@ -949,14 +949,17 @@ for i in `cat /proc/cmdline`; do | ||||
|         SERVER=`echo \$VALUE|awk -F: '{print \$1}'` | ||||
|         ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` | ||||
|    elif [ "\$KEY" == 'STATEMNT' ]; then | ||||
|         NFSROOT=1 | ||||
|         STATELITE=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= | ||||
|         # VALUE may be null | ||||
|         if [ ! -z \$VALUE ]; then | ||||
|             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 | ||||
|     fi | ||||
| done | ||||
| @@ -964,35 +967,57 @@ done | ||||
| # show xCAT logo | ||||
| fancydisplay | ||||
|  | ||||
| # begin NFSROOT/Statelite code | ||||
| if [ "\$NFSROOT" = "1" ]; then | ||||
| # Statelite code is here | ||||
| if [ "\$STATELITE" = "1" ]; then | ||||
|     echo Setting up Statelite | ||||
|     # for loop back mounting capability! | ||||
|     mknod /dev/loop0 b 7 0 | ||||
|     mkdir -p \$NEWROOT | ||||
|     MAXTRIES=15 | ||||
|     ITER=0 | ||||
|     ME=`hostname` | ||||
|     while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14 | ||||
|     do | ||||
|         ITER=\$(expr \$ITER + 1) | ||||
|         if [ "\$ITER" == "\$MAXTRIES" ] | ||||
|         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' | ||||
| 2.  Is DNS set up?  Maybe that's why I can't mount \${SERVER}. | ||||
| 3.  The nfs modules aren't set right in this initfs?" | ||||
|      | ||||
|             shell | ||||
|             exit | ||||
|         fi | ||||
|         echo -e "\${RED}Could not mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" | ||||
|         RS=`expr \$RANDOM % 30` | ||||
|         echo -e "Trying again in \$RS seconds" | ||||
|         sleep \$RS | ||||
|     done | ||||
|     if [ "\$NFSROOT" = "1" ]; then | ||||
|         while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do | ||||
|             ITER=\$(expr \$ITER + 1) | ||||
|             if [ "\$ITER" = "\$MAXTRIES" ]; then | ||||
|                 echo "You're dead. rpower \$ME boot to play again." | ||||
|                 echo "Possible problems: | ||||
| 1.  This initrd wan't created for the statelite node?  | ||||
| 2.  IS DNS set up? Maybe that's why I can't mount \${SERVER}. | ||||
| 3.  The nfs modules aren't set right in this initial ramdisk?" | ||||
|                 shell | ||||
|                 exit | ||||
|             fi | ||||
|             echo -e "\${RED}Couldn't mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" | ||||
|             RS=\$(expr \$RANDOM % 30) | ||||
|             echo -e "Trying again in \$RS seconds" | ||||
|             sleep \$RS | ||||
|         done | ||||
|     else | ||||
|         # for statelite mode on top of the ramdisk | ||||
| EOMS | ||||
|     print $inifile "if [ -r /rootimg-statelite.gz ]; then \n"; | ||||
|     print $inifile "echo Setting up RAM-root tmpfs.\n"; | ||||
|     if ($rootlimit) { | ||||
|         print $inifile "    mount -o size=$rootlimit mode=755 -t tmpfs rootfs \$NEWROOT \n"; | ||||
|     } else { | ||||
|         print $inifile "    mount -o mode=755 -t tmpfs rootfs \$NEWROOT \n"; | ||||
|     } | ||||
|  | ||||
|     print $inifile <<EOMS; | ||||
|         cd \$NEWROOT | ||||
|         echo -n "Extracting root file system:" | ||||
|         if [ -x /bin/cpio ]; then | ||||
|             gzip -cd /rootimg-statelite.gz | /bin/cpio -idum | ||||
|         else | ||||
|             gzip -cd /rootimg-statelite.gz | cpio -idum | ||||
|         fi | ||||
|         echo "Done" | ||||
|     else | ||||
|         echo -e "\${RED} Couldn't find rootimg-statelite.gz for statelite semantics on top of ramdisk \${RESET}" | ||||
|         shell | ||||
|         exit | ||||
|     fi | ||||
| fi | ||||
| # now we need to mount the rest of the system.  This is the read/write portions | ||||
| #echo "Mounting Snapshot directories" | ||||
|     if [ ! -e "\$NEWROOT/\$RWDIR" ] | ||||
| @@ -1111,9 +1136,9 @@ EOMS | ||||
|    print $inifile "elif [ -r /rootimg.gz ]; then\n"; | ||||
|    print $inifile "echo Setting up RAM-root tmpfs.\n"; | ||||
|    if ($rootlimit) { | ||||
|       print $inifile "  mount -o size=$rootlimit  mode=755 -t tmpfs rootfs /sysroot\n"; | ||||
|       print $inifile "  mount -o size=$rootlimit  mode=755 -t tmpfs rootfs \$NEWROOT\n"; | ||||
|    } else { | ||||
|       print $inifile "  mount -o  mode=755 -t tmpfs rootfs /sysroot\n"; | ||||
|       print $inifile "  mount -o  mode=755 -t tmpfs rootfs \$NEWROOT\n"; | ||||
|    } | ||||
|    print $inifile "  cd /sysroot\n"; | ||||
|    print $inifile "  echo -n \"Extracting root filesystem:\"\n"; | ||||
| @@ -1142,12 +1167,12 @@ EOMS | ||||
|    print $inifile "  exit\n"; | ||||
|    print $inifile "fi\n"; | ||||
|    print $inifile "cd /\n"; | ||||
|    print $inifile "mkdir /sysroot/var/lib/dhcpcd/\n";	#neccessary for SLES11, not sure for SLES10 | ||||
|    print $inifile "cp /var/lib/dhcpcd/* /sysroot/var/lib/dhcpcd/\n"; | ||||
|    print $inifile "cp /etc/resolv.conf /sysroot/etc/\n"; | ||||
|    print $inifile "cp /etc/HOSTNAME /sysroot/etc/\n"; | ||||
|    print $inifile "mknod /sysroot/dev/console c 5 1\n"; | ||||
|    print $inifile "exec /lib/mkinitrd/bin/run-init -c /dev/console /sysroot /sbin/init\n"; | ||||
|    print $inifile "mkdir \$NEWROOT/var/lib/dhcpcd/\n";	#neccessary for SLES11, not sure for SLES10 | ||||
|    print $inifile "cp /var/lib/dhcpcd/* \$NEWROOT/var/lib/dhcpcd/\n"; | ||||
|    print $inifile "cp /etc/resolv.conf \$NEWROOT/etc/\n"; | ||||
|    print $inifile "cp /etc/HOSTNAME \$NEWROOT/etc/\n"; | ||||
|    print $inifile "mknod \$NEWROOT/dev/console c 5 1\n"; | ||||
|    print $inifile "exec /lib/mkinitrd/bin/run-init -c /dev/console \$NEWROOT /sbin/init\n"; | ||||
|    close($inifile); | ||||
|    open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart"); | ||||
|    print $inifile "#!/bin/bash \n"; | ||||
| @@ -1175,7 +1200,7 @@ END | ||||
|      } | ||||
|    } | ||||
|     if($mode eq "statelite") { | ||||
|         foreach ("sbin/ifconfig", "usr/bin/clear", "sbin/mount.nfs","sbin/umount.nfs","bin/hostname","usr/bin/egrep","bin/ln","bin/ls","usr/bin/dirname","usr/bin/expr","usr/bin/chroot","usr/bin/grep","bin/cpio","bin/sleep","bin/mount","bin/umount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","usr/bin/wc") { | ||||
|         foreach ("sbin/ifconfig", "usr/bin/clear", "sbin/mount.nfs","sbin/umount.nfs","bin/hostname","usr/bin/egrep","bin/ln","bin/ls","usr/bin/dirname","usr/bin/expr","usr/bin/chroot","usr/bin/grep","bin/cpio","bin/sleep","bin/mount","bin/umount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","usr/bin/wc", "bin/sed") { | ||||
|             getlibs($_);  | ||||
|             push @filestoadd,$_; | ||||
|         }  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user