diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 9df0807fe..c8b17d9b8 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -101,6 +101,8 @@ sub mknetboot my $provmethod; my $rootimgdir; my $nodebootif; # nodebootif will be used if noderes.installnic is not set + my $dump; #for kdump + my $crashkernelsize; my $rootfstype; my $ent= $ntents->{$node}->[0]; @@ -121,12 +123,18 @@ sub mknetboot if (!$linuximagetab) { $linuximagetab=xCAT::Table->new('linuximage', -create=>1); } - (my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif'); + (my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif', 'dump', 'crashkernelsize'); 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'})) { + $img_hash{$imagename}->{crashkernelsize} = $ref1->{'crashkernelsize'}; } } else { $callback->( @@ -142,6 +150,8 @@ sub mknetboot $rootfstype = $ph->{rootfstype}; $nodebootif = $ph->{nodebootif}; $provmethod = $ph->{provmethod}; + $dump = $ph->{dump}; + $crashkernelsize = $ph->{crashkernelsize}; $rootimgdir = $ph->{rootimgdir}; unless ($rootimgdir) { @@ -176,6 +186,26 @@ 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 osimage=" command to set the boot state}], + errorcode => [1] } + ); + } + $rootimgdir="$installroot/netboot/$osver/$arch/$profile"; } @@ -489,6 +519,22 @@ 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 "; + } + } + } + my $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz" if ($statelite); diff --git a/xCAT/postscripts/enablekdump b/xCAT/postscripts/enablekdump index 9d8c35fac..966332200 100755 --- a/xCAT/postscripts/enablekdump +++ b/xCAT/postscripts/enablekdump @@ -4,6 +4,15 @@ # # create /etc/sysconfig/network-scripts/ +pmatch () +{ + case $1 in + $2) return 0;; # zero return code means string matched by pattern + esac + + return 1 # non-zero return code means string not matched by pattern +} + for i in `/bin/cat /proc/cmdline`; do KEY=`/bin/echo $i | /bin/awk -F= '{print $1}'` if [ "$KEY" = "ifname" ]; then @@ -13,7 +22,7 @@ for i in `/bin/cat /proc/cmdline`; do break elif [ "$KEY" = "netdev" ]; then ETHX=`/bin/echo $i | /bin/awk -F= '{print $2}'` - MACX=`/sbin/ip link show $netdev | /bin/grep ether | /bin/awk '{print $2}'` + MACX=`/sbin/ip link show $ETHX | /bin/grep ether | /bin/awk '{print $2}'` break elif [ "$KEY" = "BOOTIF" ]; then MACX=`/bin/echo $i | /bin/awk -F= '{print $2}'` @@ -23,13 +32,19 @@ for i in `/bin/cat /proc/cmdline`; do done if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then - if [ ! -e $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then - /bin/touch $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX + if (pmatch $OSVER "sles*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then + CONFFILE=$MNTDIR/etc/sysconfig/network/ifcfg-$ETHX + fi + if (pmatch $OSVER "fedora*") || (pmatch $OSVER "rhel6*") || (pmatch $OSVER "rhels6*") || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ];then + CONFFILE=$MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX + fi + if [ ! -e $CONFFILE ]; then + /bin/touch $CONFFILE fi - echo "DEVICE=$ETHX" > $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX - echo "BOOTPROTO=dhcp" >> $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX - echo "HWADDR=$MACX" >> $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX - echo "ONBOOT=yes" >> $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "DEVICE=$ETHX" > $CONFFILE + echo "BOOTPROTO=dhcp" >> $CONFFILE + echo "HWADDR=$MACX" >> $CONFFILE + echo "ONBOOT=yes" >> $CONFFILE fi @@ -62,17 +77,39 @@ if [ ! -z "$DUMP" ]; then KDIP=${XCAT%:*} fi - if [ "$KDPROTO" = "nfs" ]; then - echo "net $KDIP:$KDPATH" > /etc/kdump.conf - fi - # workaround for RHEL6 # the $KDIP:$KDPATH directory will be used to generate the initrd for kdump service - /bin/mount $KDIP:$KDPATH /var/tmp + MOUNTPATH="" + if (pmatch $OSVER "*6\.*" ); then + MOUNTPATH="/tmp" + else + MOUNTPATH="/var/tmp" + fi + /bin/mount $KDIP:$KDPATH $MOUNTPATH - /etc/init.d/kdump restart + if [ "$KDPROTO" = "nfs" ]; then + if (pmatch $OSVER "sles*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then + KDPATH=${KDPATH//\//\\\/} + KDPATH="nfs:\/\/${KDIP}${KDPATH}" + sed -i "s/^KDUMP_SAVEDIR=.*$/KDUMP_SAVEDIR=\"${KDPATH}\"/" /etc/sysconfig/kdump + sed -i "s/^KDUMP_COPY_KERNEL=.*$/KDUMP_COPY_KERNEL=no/" /etc/sysconfig/kdump + #change the mount and remount shell scripts' name, workaround for kdump on stateless node + oldmount=`ls /lib/mkinitrd/boot/*-mount.sh` + oldremount=`ls /lib/mkinitrd/boot/*-remount.sh` + mv $oldmount ${oldmount}.bak + mv $oldremount ${oldremount}.bak + /etc/init.d/boot.kdump restart + mv ${oldmount}.bak $oldmount + mv ${oldremount}.bak $oldremount + else + if (pmatch $OSVER "fedora*") || (pmatch $OSVER "rhel6*") || (pmatch $OSVER "rhels6*") || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ];then + echo "net $KDIP:$KDPATH" > /etc/kdump.conf + /etc/init.d/kdump restart + fi + fi + fi - /bin/umount /var/tmp + /bin/umount $MOUNTPATH else /bin/echo "The kdump server is not configured" fi