Code drop for local hard disk to be used as persistent storage for statelite node
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14346 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
879802ef9f
commit
427b66827f
@ -232,6 +232,7 @@ sub mknetboot
|
||||
my $crashkernelsize;
|
||||
my $rootfstype;
|
||||
my $tftpdir;
|
||||
my $cfgpart;
|
||||
if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{tftpdir}) {
|
||||
$tftpdir = $reshash->{$node}->[0]->{tftpdir};
|
||||
} else {
|
||||
@ -257,7 +258,7 @@ sub mknetboot
|
||||
if (!$linuximagetab) {
|
||||
$linuximagetab=xCAT::Table->new('linuximage', -create=>1);
|
||||
}
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif', 'dump', 'crashkernelsize');
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif', 'dump', 'crashkernelsize', 'partitionfile');
|
||||
if (($ref1) && ($ref1->{'rootimgdir'})) {
|
||||
$img_hash{$imagename}->{rootimgdir}=$ref1->{'rootimgdir'};
|
||||
}
|
||||
@ -272,6 +273,27 @@ sub mknetboot
|
||||
if (($ref1) && ($ref1->{'crashkernelsize'})) {
|
||||
$img_hash{$imagename}->{crashkernelsize} = $ref1->{'crashkernelsize'};
|
||||
}
|
||||
if ($ref1 && $ref1->{'partitionfile'}) {
|
||||
# check the validity of the partition configuration file
|
||||
if ($ref1->{'partitionfile'} =~ /^s:(.*)/) {
|
||||
# the configuration file is a script
|
||||
if (-r $1) {
|
||||
$img_hash{$imagename}->{'cfgpart'} = "yes";
|
||||
}
|
||||
} else {
|
||||
if (open (FILE, "<$ref1->{'partitionfile'}")) {
|
||||
while (<FILE>) {
|
||||
if (/enable=yes/) {
|
||||
$img_hash{$imagename}->{'cfgpart'} = "yes";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (FILE);
|
||||
}
|
||||
|
||||
$img_hash{$imagename}->{'partfile'} = $ref1->{'partitionfile'};
|
||||
}
|
||||
} else {
|
||||
$callback->(
|
||||
{error => ["The os image $imagename does not exists on the osimage table for $node"],
|
||||
@ -279,15 +301,14 @@ sub mknetboot
|
||||
next;
|
||||
}
|
||||
}
|
||||
my $ph=$img_hash{$imagename};
|
||||
my $ph=$img_hash{$imagename};
|
||||
|
||||
$osver = $ph->{osver};
|
||||
$arch = $ph->{osarch};
|
||||
$profile = $ph->{profile};
|
||||
$osver = $ph->{osver};
|
||||
$arch = $ph->{osarch};
|
||||
$profile = $ph->{profile};
|
||||
|
||||
$rootfstype = $ph->{rootfstype};
|
||||
|
||||
$rootimgdir=$ph->{rootimgdir};
|
||||
$rootimgdir=$ph->{rootimgdir};
|
||||
unless ($rootimgdir) {
|
||||
$rootimgdir="$installroot/netboot/$osver/$arch/$profile";
|
||||
}
|
||||
@ -295,6 +316,7 @@ sub mknetboot
|
||||
$nodebootif = $ph->{nodebootif};
|
||||
$crashkernelsize = $ph->{crashkernelsize};
|
||||
$dump = $ph->{dump};
|
||||
$cfgpart = $ph->{'cfgpart'};
|
||||
}
|
||||
else {
|
||||
$osver = $ent->{os};
|
||||
@ -331,13 +353,32 @@ sub mknetboot
|
||||
$linuximagetab = xCAT::Table->new('linuximage');
|
||||
}
|
||||
if ( $linuximagetab ) {
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imgname}, 'dump', 'crashkernelsize');
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imgname}, 'dump', 'crashkernelsize', 'partitionfile');
|
||||
if($ref1 and $ref1->{'dump'}) {
|
||||
$dump = $ref1->{'dump'};
|
||||
}
|
||||
if($ref1 and $ref1->{'crashkernelsize'}) {
|
||||
$crashkernelsize = $ref1->{'crashkernelsize'};
|
||||
}
|
||||
if($ref1 and $ref1->{'partitionfile'}) {
|
||||
# check the validity of the partition configuration file
|
||||
if ($ref1->{'partitionfile'} =~ /^s:(.*)/) {
|
||||
# the configuration file is a script
|
||||
if (-r $1) {
|
||||
$cfgpart = "yes";
|
||||
}
|
||||
} else {
|
||||
if (-r $ref1->{'partitionfile'} && open (FILE, "<$ref1->{'partitionfile'}")) {
|
||||
while (<FILE>) {
|
||||
if (/enable=yes/) {
|
||||
$cfgpart = "yes";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (FILE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$callback->(
|
||||
{ error => [qq{ Cannot find the linux image called "$osver-$arch-$imgname-$profile", maybe you need to use the "nodeset <nr> osimage=<your_image_name>" command to set the boot state}],
|
||||
@ -756,6 +797,11 @@ sub mknetboot
|
||||
}
|
||||
}
|
||||
|
||||
# add the cmdline parameters for handling the local disk for stateless
|
||||
if ($cfgpart eq "yes") {
|
||||
$kcmdline .= " PARTITION";
|
||||
}
|
||||
|
||||
# add the addkcmdline attribute to the end
|
||||
# of the command, if it exists
|
||||
#my $addkcmd = $addkcmdhash->{$node}->[0];
|
||||
|
@ -111,64 +111,87 @@ sub mknetboot
|
||||
my $dump; #for kdump
|
||||
my $crashkernelsize;
|
||||
my $rootfstype;
|
||||
my $cfgpart;
|
||||
|
||||
my $ent= $ntents->{$node}->[0];
|
||||
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')) {
|
||||
my $imagename=$ent->{provmethod};
|
||||
#print "imagename=$imagename\n";
|
||||
if (!exists($img_hash{$imagename})) {
|
||||
if (!$osimagetab) {
|
||||
$osimagetab=xCAT::Table->new('osimage', -create=>1);
|
||||
}
|
||||
(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'};
|
||||
my $imagename=$ent->{provmethod};
|
||||
#print "imagename=$imagename\n";
|
||||
if (!exists($img_hash{$imagename})) {
|
||||
if (!$osimagetab) {
|
||||
$osimagetab=xCAT::Table->new('osimage', -create=>1);
|
||||
}
|
||||
(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);
|
||||
}
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif', 'dump', 'crashkernelsize');
|
||||
if (($ref1) && ($ref1->{'rootimgdir'})) {
|
||||
$img_hash{$imagename}->{rootimgdir}=$ref1->{'rootimgdir'};
|
||||
}
|
||||
$img_hash{$imagename}->{provmethod}=$ref->{'provmethod'};
|
||||
if (!$linuximagetab) {
|
||||
$linuximagetab=xCAT::Table->new('linuximage', -create=>1);
|
||||
}
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif', 'dump', 'crashkernelsize', 'partitionfile');
|
||||
if (($ref1) && ($ref1->{'rootimgdir'})) {
|
||||
$img_hash{$imagename}->{rootimgdir}=$ref1->{'rootimgdir'};
|
||||
}
|
||||
if (($ref1) && ($ref1->{'nodebootif'})) {
|
||||
$img_hash{$imagename}->{nodebootif} = $ref1->{'nodebootif'};
|
||||
}
|
||||
if (($ref1) && ($ref1->{'dump'})){
|
||||
$img_hash{$imagename}->{dump} = $ref1->{'dump'};
|
||||
}
|
||||
if (($ref1) && ($ref1->{'crashkernelsize'})) {
|
||||
if (($ref1) && ($ref1->{'dump'})){
|
||||
$img_hash{$imagename}->{dump} = $ref1->{'dump'};
|
||||
}
|
||||
if (($ref1) && ($ref1->{'crashkernelsize'})) {
|
||||
$img_hash{$imagename}->{crashkernelsize} = $ref1->{'crashkernelsize'};
|
||||
}
|
||||
} else {
|
||||
$callback->(
|
||||
{error => ["The os image $imagename does not exists on the osimage table for $node"],
|
||||
errorcode => [1]});
|
||||
next;
|
||||
}
|
||||
}
|
||||
my $ph=$img_hash{$imagename};
|
||||
$osver = $ph->{osver};
|
||||
$arch = $ph->{osarch};
|
||||
$profile = $ph->{profile};
|
||||
if ($ref1 && $ref1->{'partitionfile'}) {
|
||||
# check the validity of the partition configuration file
|
||||
if ($ref1->{'partitionfile'} =~ /^s:(.*)/) {
|
||||
# the configuration file is a script
|
||||
if (-r $1) {
|
||||
$img_hash{$imagename}->{'cfgpart'} = "yes";
|
||||
}
|
||||
} else {
|
||||
if (open (FILE, "<$ref1->{'partitionfile'}")) {
|
||||
while (<FILE>) {
|
||||
if (/enable=yes/) {
|
||||
$img_hash{$imagename}->{'cfgpart'} = "yes";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (FILE);
|
||||
}
|
||||
|
||||
$img_hash{$imagename}->{'partfile'} = $ref1->{'partitionfile'};
|
||||
}
|
||||
|
||||
} else {
|
||||
$callback->(
|
||||
{error => ["The os image $imagename does not exists on the osimage table for $node"],
|
||||
errorcode => [1]});
|
||||
next;
|
||||
}
|
||||
}
|
||||
my $ph=$img_hash{$imagename};
|
||||
$osver = $ph->{osver};
|
||||
$arch = $ph->{osarch};
|
||||
$profile = $ph->{profile};
|
||||
$rootfstype = $ph->{rootfstype};
|
||||
$nodebootif = $ph->{nodebootif};
|
||||
$provmethod = $ph->{provmethod};
|
||||
$dump = $ph->{dump};
|
||||
$crashkernelsize = $ph->{crashkernelsize};
|
||||
|
||||
$rootimgdir = $ph->{rootimgdir};
|
||||
unless ($rootimgdir) {
|
||||
$rootimgdir = "$installroot/netboot/$osver/$arch/$profile";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$osver = $ent->{os};
|
||||
$arch = $ent->{arch};
|
||||
$profile = $ent->{profile};
|
||||
$provmethod = $ph->{provmethod};
|
||||
$dump = $ph->{dump};
|
||||
$crashkernelsize = $ph->{crashkernelsize};
|
||||
$cfgpart = $ph->{'cfgpart'};
|
||||
|
||||
$rootimgdir = $ph->{rootimgdir};
|
||||
unless ($rootimgdir) {
|
||||
$rootimgdir = "$installroot/netboot/$osver/$arch/$profile";
|
||||
}
|
||||
}else {
|
||||
$osver = $ent->{os};
|
||||
$arch = $ent->{arch};
|
||||
$profile = $ent->{profile};
|
||||
$rootfstype = "nfs"; # TODO: try to get it from the option or table
|
||||
my $imgname;
|
||||
if ($statelite) {
|
||||
@ -193,26 +216,44 @@ sub mknetboot
|
||||
);
|
||||
}
|
||||
|
||||
#get the dump path and kernel crash memory side for kdump on sles
|
||||
if (!$linuximagetab){
|
||||
$linuximagetab = xCAT::Table->new('linuximage');
|
||||
}
|
||||
if ($linuximagetab){
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imgname}, 'dump', 'crashkernelsize');
|
||||
if ($ref1 && $ref1->{'dump'}){
|
||||
$dump = $ref1->{'dump'};
|
||||
}
|
||||
if ($ref1 and $ref1->{'crashkernelsize'}){
|
||||
$crashkernelsize = $ref1->{'crashkernelsize'};
|
||||
}
|
||||
}
|
||||
else{
|
||||
$callback->(
|
||||
{ error => [qq{ Cannot find the linux image called "$osver-$arch-$imgname-$profile", maybe you need to use the "nodeset <nr> osimage=<your_image_name>" command to set the boot state}],
|
||||
errorcode => [1] }
|
||||
#get the dump path and kernel crash memory side for kdump on sles
|
||||
if (!$linuximagetab){
|
||||
$linuximagetab = xCAT::Table->new('linuximage');
|
||||
}
|
||||
if ($linuximagetab){
|
||||
(my $ref1) = $linuximagetab->getAttribs({imagename => $imgname}, 'dump', 'crashkernelsize', 'partitionfile');
|
||||
if ($ref1 && $ref1->{'dump'}){
|
||||
$dump = $ref1->{'dump'};
|
||||
}
|
||||
if ($ref1 and $ref1->{'crashkernelsize'}){
|
||||
$crashkernelsize = $ref1->{'crashkernelsize'};
|
||||
}
|
||||
if($ref1 and $ref1->{'partitionfile'}) {
|
||||
# check the validity of the partition configuration file
|
||||
if ($ref1->{'partitionfile'} =~ /^s:(.*)/) {
|
||||
# the configuration file is a script
|
||||
if (-r $1) {
|
||||
$cfgpart = "yes";
|
||||
}
|
||||
} else {
|
||||
if (-r $ref1->{'partitionfile'} && open (FILE, "<$ref1->{'partitionfile'}")) {
|
||||
while (<FILE>) {
|
||||
if (/enable=yes/) {
|
||||
$cfgpart = "yes";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$callback->(
|
||||
{ error => [qq{ Cannot find the linux image called "$osver-$arch-$imgname-$profile", maybe you need to use the "nodeset <nr> osimage=<your_image_name>" command to set the boot state}],
|
||||
errorcode => [1] }
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
$rootimgdir="$installroot/netboot/$osver/$arch/$profile";
|
||||
}
|
||||
|
||||
@ -228,7 +269,7 @@ sub mknetboot
|
||||
}
|
||||
|
||||
#print"osvr=$osver, arch=$arch, profile=$profile, imgdir=$rootimgdir\n";
|
||||
my $platform;
|
||||
my $platform;
|
||||
if ($osver =~ /sles.*/)
|
||||
{
|
||||
$platform = "sles";
|
||||
@ -500,9 +541,7 @@ sub mknetboot
|
||||
}
|
||||
|
||||
|
||||
if (defined $sent->{serialport})
|
||||
{
|
||||
|
||||
if (defined $sent->{serialport}) {
|
||||
#my $sent = $hmtab->getNodeAttribs($node,['serialspeed','serialflow']);
|
||||
unless ($sent->{serialspeed})
|
||||
{
|
||||
@ -524,44 +563,46 @@ sub mknetboot
|
||||
}
|
||||
}
|
||||
|
||||
#create the kcmd for node to support kdump
|
||||
if ($dump){
|
||||
if ($crashkernelsize){
|
||||
$kcmdline .= " crashkernel=$crashkernelsize dump=$dump ";
|
||||
}
|
||||
else{
|
||||
# for ppc64, the crashkernel paramter should be "128M@32M", otherwise, some kernel crashes will be met
|
||||
if ($arch eq "ppc64"){
|
||||
$kcmdline .= " crashkernel=256M\@64M dump=$dump ";
|
||||
}
|
||||
if ($arch =~ /86/){
|
||||
$kcmdline .= " crashkernel=128M dump=$dump ";
|
||||
}
|
||||
}
|
||||
}
|
||||
#create the kcmd for node to support kdump
|
||||
if ($dump){
|
||||
if ($crashkernelsize){
|
||||
$kcmdline .= " crashkernel=$crashkernelsize dump=$dump ";
|
||||
}
|
||||
else{
|
||||
# for ppc64, the crashkernel paramter should be "128M@32M", otherwise, some kernel crashes will be met
|
||||
if ($arch eq "ppc64"){
|
||||
$kcmdline .= " crashkernel=256M\@64M dump=$dump ";
|
||||
}
|
||||
if ($arch =~ /86/){
|
||||
$kcmdline .= " crashkernel=128M dump=$dump ";
|
||||
}
|
||||
}
|
||||
}
|
||||
# add the cmdline parameters for handling the local disk for stateless
|
||||
if ($cfgpart eq "yes") {
|
||||
$kcmdline .= " PARTITION";
|
||||
}
|
||||
|
||||
my $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz";
|
||||
$initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz" if ($statelite);
|
||||
|
||||
if($statelite)
|
||||
{
|
||||
my $statelitetb = xCAT::Table->new('statelite');
|
||||
my $mntopts = $statelitetb->getNodeAttribs($node, ['mntopts']);
|
||||
|
||||
my $mntoptions = $mntopts->{'mntopts'};
|
||||
if(defined($mntoptions))
|
||||
{
|
||||
$kcmdline .= "MNTOPTS=\'$mntoptions\'";
|
||||
}
|
||||
}
|
||||
if($statelite)
|
||||
{
|
||||
my $statelitetb = xCAT::Table->new('statelite');
|
||||
my $mntopts = $statelitetb->getNodeAttribs($node, ['mntopts']);
|
||||
|
||||
my $mntoptions = $mntopts->{'mntopts'};
|
||||
if(defined($mntoptions)) {
|
||||
$kcmdline .= "MNTOPTS=\'$mntoptions\'";
|
||||
}
|
||||
}
|
||||
$bptab->setNodeAttribs(
|
||||
$node,
|
||||
{
|
||||
kernel => "xcat/netboot/$osver/$arch/$profile/kernel",
|
||||
initrd => $initrdstr,
|
||||
kcmdline => $kcmdline
|
||||
}
|
||||
);
|
||||
$node,
|
||||
{
|
||||
kernel => "xcat/netboot/$osver/$arch/$profile/kernel",
|
||||
initrd => $initrdstr,
|
||||
kcmdline => $kcmdline
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ Getopt::Long::Configure("pass_through");
|
||||
|
||||
my $cmdname = "liteimg";
|
||||
my $statedir = ".statelite";
|
||||
my $lddir = ".sllocal";
|
||||
my $verbose = "0";
|
||||
sub handled_commands {
|
||||
return {
|
||||
@ -269,6 +270,13 @@ sub process_request {
|
||||
# the directory/file in litefile table must be the absolute path ("/***")
|
||||
foreach my $entry (@$listNew) {
|
||||
my @tmp = split (/\s+/, $entry);
|
||||
|
||||
# check the validity of the option
|
||||
if ($tmp[1] !~ /^(tmpfs|persistent|localdisk|rw|link|tmpfs,rw|link,ro|link,persistent|link,con)$/) {
|
||||
$callback->({error=>[qq{ $tmp[2] has invalid option. The valid options: tmpfs persistent localdisk rw link tmpfs,rw link,ro link,persistent link,con}], errorcode=>[1]});
|
||||
return;
|
||||
}
|
||||
|
||||
unless ($tmp[2] =~ m{^/}) {
|
||||
$callback->({error=>[qq{ $tmp[2] is not one absolute path. }], errorcode=>[1]});
|
||||
return;
|
||||
@ -549,6 +557,12 @@ sub liteMe {
|
||||
xCAT::Utils->runcmd("mkdir -p $rootimg_dir/$statedir/tmpfs", 0, 1);
|
||||
}
|
||||
|
||||
# ceate the dir for local disk mount point
|
||||
unless (-d "$rootimg_dir/$lddir") {
|
||||
$callback->({info=>["creating $rootimg_dir/$lddir"]});
|
||||
xCAT::Utils->runcmd("mkdir -p $rootimg_dir/$lddir", 0, 1);
|
||||
}
|
||||
|
||||
foreach my $line (keys %{$hashNewRef}) {
|
||||
liteItem($rootimg_dir, $line, 0, $callback);
|
||||
if($hashNewRef->{$line}) { # there're children
|
||||
|
@ -15,6 +15,7 @@ SYNCLIST="${MNTDIR}/$SL/litefile" # the list of files to sync
|
||||
TREEMOUNT="${MNTDIR}/$SL/mnt" # where I mount all the trees.
|
||||
TMPFS="${MNTDIR}/$SL/tmpfs"
|
||||
DEFAULT="${MNTDIR}/.default"
|
||||
LOCAL="${MNTDIR}/.sllocal"
|
||||
LOG="${MNTDIR}/${SL}/statelite.log"
|
||||
ELIST=[] # entry list, each entry will contain the type and the path
|
||||
declare -a CLIST
|
||||
@ -387,6 +388,33 @@ ProcessType () {
|
||||
/bin/mount --bind ${TMPFS}${2} ${MNTDIR}${ORIG}>>$LOG 2>&1
|
||||
fi
|
||||
;;
|
||||
localdisk)
|
||||
ORIG=`echo ${2} | /bin/sed -e 's/\/$//'`
|
||||
TARGET=`echo ${1}`
|
||||
|
||||
if [ ! -d ${LOCAL}${PPATH} ] && [ ! -L ${LOCAL}${PPATH} ]; then
|
||||
/bin/mkdir -p ${LOCAL}${PPATH}
|
||||
echo "mkdir -p ${LOCAL}${PPATH}" >>$LOG
|
||||
fi
|
||||
|
||||
# check it is a dir or file
|
||||
if [ -d ${1} ]; then
|
||||
if [ ! -d ${LOCAL}${2} ]; then
|
||||
/bin/cp -r -a ${1} ${LOCAL}${PPATH}
|
||||
echo "cp -r -a ${1} ${LOCAL}${PPATH}" >>$LOG
|
||||
fi
|
||||
else
|
||||
if [ ! -f ${LOCAL}${2} ]; then
|
||||
/bin/cp -r -a ${1} ${LOCAL}${2}
|
||||
echo "cp -r -a ${1} ${LOCAL}${2}" >>$LOG
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$isChild" = "0" ]; then
|
||||
echo "mount --bind ${LOCAL}${2} ${MNTDIR}${ORIG}" >>$LOG
|
||||
/bin/mount --bind ${LOCAL}${2} ${MNTDIR}${ORIG}>>$LOG 2>&1
|
||||
fi
|
||||
;;
|
||||
rw) # the default option, same as "tmpfs" and "NULL"
|
||||
ORIG=`echo ${2} | /bin/sed -e 's/\/$//'`
|
||||
TARGET=`echo ${1}`
|
||||
|
@ -15,6 +15,7 @@ SYNCLIST="${MNTDIR}/$SL/litefile" # the list of files to sync
|
||||
TREEMOUNT="${MNTDIR}/$SL/mnt" # where I mount all the trees.
|
||||
TMPFS="${MNTDIR}/$SL/tmpfs"
|
||||
DEFAULT="${MNTDIR}/.default"
|
||||
LOCAL="${MNTDIR}/.sllocal"
|
||||
LOG="${MNTDIR}/${SL}/statelite.log"
|
||||
ELIST=[] # entry list, each entry will contain the type and the path
|
||||
declare -a CLIST
|
||||
@ -387,6 +388,33 @@ ProcessType () {
|
||||
/bin/mount --bind ${TMPFS}${2} ${MNTDIR}${ORIG}>>$LOG 2>&1
|
||||
fi
|
||||
;;
|
||||
localdisk)
|
||||
ORIG=`echo ${2} | /bin/sed -e 's/\/$//'`
|
||||
TARGET=`echo ${1}`
|
||||
|
||||
if [ ! -d ${LOCAL}${PPATH} ] && [ ! -L ${LOCAL}${PPATH} ]; then
|
||||
/bin/mkdir -p ${LOCAL}${PPATH}
|
||||
echo "mkdir -p ${LOCAL}${PPATH}" >>$LOG
|
||||
fi
|
||||
|
||||
# check it is a dir or file
|
||||
if [ -d ${1} ]; then
|
||||
if [ ! -d ${LOCAL}${2} ]; then
|
||||
/bin/cp -r -a ${1} ${LOCAL}${PPATH}
|
||||
echo "cp -r -a ${1} ${LOCAL}${PPATH}" >>$LOG
|
||||
fi
|
||||
else
|
||||
if [ ! -f ${LOCAL}${2} ]; then
|
||||
/bin/cp -r -a ${1} ${LOCAL}${2}
|
||||
echo "cp -r -a ${1} ${LOCAL}${2}" >>$LOG
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$isChild" = "0" ]; then
|
||||
echo "mount --bind ${LOCAL}${2} ${MNTDIR}${ORIG}" >>$LOG
|
||||
/bin/mount --bind ${LOCAL}${2} ${MNTDIR}${ORIG}>>$LOG 2>&1
|
||||
fi
|
||||
;;
|
||||
rw) # the default option, same as "tmpfs" and "NULL"
|
||||
ORIG=`echo ${2} | /bin/sed -e 's/\/$//'`
|
||||
TARGET=`echo ${1}`
|
||||
|
@ -3,5 +3,6 @@ echo $drivers
|
||||
dracut_install wget cpio gzip dash modprobe touch echo cut wc
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install mount.nfs
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
inst "$moddir/xcatroot" "/sbin/xcatroot"
|
||||
inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"
|
||||
|
@ -2,4 +2,5 @@
|
||||
echo $drivers
|
||||
dracut_install wget cpio gzip dash modprobe wc touch echo cut
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh"
|
||||
|
@ -68,6 +68,8 @@ if [ ! -z $SNAPSHOTSERVER ]; then
|
||||
fi
|
||||
|
||||
# TODO: handle the dhclient/resolv.conf/ntp, etc
|
||||
echo "Get to enable localdisk"
|
||||
$NEWROOT/etc/init.d/localdisk
|
||||
$NEWROOT/etc/init.d/statelite
|
||||
READONLY=yes
|
||||
export READONLY
|
||||
|
@ -119,6 +119,7 @@ elif [ -r /rootimg-statelite.gz ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
$NEWROOT/etc/init.d/localdisk
|
||||
$NEWROOT/etc/init.d/statelite
|
||||
fastboot=yes
|
||||
export fastboot
|
||||
|
@ -618,6 +618,7 @@ unless (-f "$cwd/../add-on/statelite/rc.statelite") {
|
||||
}
|
||||
|
||||
system("cp $cwd/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite");
|
||||
system("cp $cwd/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk");
|
||||
# also need to add this file:
|
||||
# may have already been made into a symbolic link, if so ignore it
|
||||
|
||||
@ -710,7 +711,9 @@ sub mkinitrd_dracut {
|
||||
chmod($perm&07777, "$dracutmpath/check");
|
||||
|
||||
foreach (@ndrivers) { s/\.ko$//; }
|
||||
|
||||
# Add drivers to support local disk
|
||||
push @ndrivers, "ext3";
|
||||
push @ndrivers, "ext4";
|
||||
my $add_drivers = join(' ', @ndrivers);
|
||||
my $DRACUTCONF;
|
||||
|
||||
|
@ -688,6 +688,7 @@ unless( -r "$pathtofiles/../add-on/statelite/rc.statelite") {
|
||||
exit;
|
||||
}
|
||||
system("cp $pathtofiles/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite");
|
||||
system("cp $pathtofiles/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk");
|
||||
|
||||
# the dhcp client information stores in the directory "/var/lib/dhcpcd/"
|
||||
unless(-l "$rootimg_dir/var/lib/dhcpcd") {
|
||||
@ -730,6 +731,9 @@ if (@new_order) {
|
||||
@ndrivers = (@new_order, @ndrivers);
|
||||
}
|
||||
|
||||
# add drivers for local disk support
|
||||
push @ndrivers, ("ext3.ko", "virtio_pci.ko", "virtio_blk.ko", "ata_piix.ko", "libata.ko", "scsi_mod.ko", "ibmvscsi.ko", "megaraid_sas.ko", "pcieport.ko", "scsi_mod.ko", "sd_mod.ko");
|
||||
|
||||
open($moddeps,"<","$rootimg_dir/lib/modules/$kernelver/modules.dep");
|
||||
my @moddeps = <$moddeps>;
|
||||
my @checkdeps = @ndrivers;
|
||||
@ -941,6 +945,10 @@ EOS1
|
||||
|
||||
# Start udev
|
||||
print $inifile <<EOMS;
|
||||
|
||||
PATH="\$PATH:/usr/sbin:/sbin"
|
||||
export PATH
|
||||
|
||||
# Start udev to find devices attached to node
|
||||
# This script can be found in /lib/mkinitrd
|
||||
echo "Creating device nodes with udev"
|
||||
@ -1009,16 +1017,6 @@ done
|
||||
ip addr add dev lo 127.0.0.1/8
|
||||
ip link set lo up
|
||||
cd /
|
||||
EOMS
|
||||
|
||||
# udevd needed by s390x for networking
|
||||
# but for other type of machine, udevd will affect the start of devices which detected
|
||||
# after the chroot, so kill it after the working of network device
|
||||
if ($arch ne "s390x") {
|
||||
print $inifile "killall -9 udevd\n";
|
||||
}
|
||||
|
||||
print $inifile <<EOMS;
|
||||
for i in `cat /proc/cmdline`; do
|
||||
KEY=`echo \$i |awk -F= '{print \$1}'`
|
||||
if [ "\$KEY" == 'imgurl' ]; then
|
||||
@ -1187,9 +1185,22 @@ fi
|
||||
shell
|
||||
done
|
||||
|
||||
# try to configure the local disk
|
||||
echo "Get to enable localdisk"
|
||||
\$NEWROOT/etc/init.d/localdisk
|
||||
|
||||
# do all the mounts:
|
||||
\$NEWROOT/etc/init.d/statelite
|
||||
|
||||
EOMS
|
||||
|
||||
# udevd needed by s390x for networking
|
||||
# but for other type of machine, udevd will affect the start of devices which detected
|
||||
# after the chroot, so kill it before the switching root
|
||||
if ($arch ne "s390x") {
|
||||
print $inifile "\n killall -9 udevd\n";
|
||||
}
|
||||
|
||||
print $inifile <<EOMS;
|
||||
# give the debug shell just before we go if specified!
|
||||
grep '\(shell\)' /proc/cmdline > /dev/null && shell
|
||||
|
||||
@ -1259,6 +1270,14 @@ sleep 5
|
||||
EOMS
|
||||
print $inifile " exit\n";
|
||||
print $inifile "fi\n";
|
||||
|
||||
# udevd needed by s390x for networking
|
||||
# but for other type of machine, udevd will affect the start of devices which detected
|
||||
# after the chroot, so kill it before the switching root
|
||||
if ($arch ne "s390x") {
|
||||
print $inifile "killall -9 udevd\n";
|
||||
}
|
||||
|
||||
print $inifile "cd /\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";
|
||||
@ -1293,7 +1312,7 @@ END
|
||||
}
|
||||
}
|
||||
if($mode eq "statelite") {
|
||||
foreach ("sbin/ifconfig", "usr/bin/clear","usr/bin/touch","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","sbin/udevd", "usr/bin/readlink") {
|
||||
foreach ("sbin/ifconfig", "usr/bin/clear","usr/bin/touch","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","sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc") {
|
||||
getlibs($_);
|
||||
push @filestoadd,$_;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user