diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 28816857d..9b81b0d80 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -593,7 +593,7 @@ osimage => { }, }, linuximage => { - cols => [qw(imagename template pkglist pkgdir otherpkglist otherpkgdir exlist postinstall rootimgdir nodebootif otherifce netdrivers kernelver permission comments disable)], + cols => [qw(imagename template pkglist pkgdir otherpkglist otherpkgdir exlist postinstall rootimgdir nodebootif otherifce netdrivers kernelver permission dump comments disable)], keys => [qw(imagename)], table_desc => 'Information about a Linux operating system image that can be used to deploy cluster nodes.', descriptions => { @@ -611,6 +611,7 @@ linuximage => { netdrivers => 'the ethernet device drivers of the nodes which will use this linux image, at least the device driver for the nodes\' installnic should be included', kernelver => 'the version of linux kernel used in the linux image. If the kernel version is not set, the default kernel in rootimgdir will be used', permission => 'the mount permission of /.statelite directory is used, its default value is 755', + dump => qq{The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs:///". If you want to use the node's "xcatmaster" (its SN or MN), can be left blank. For example, "nfs:///" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN.}, comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", }, @@ -1886,6 +1887,11 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs); tabentry => 'linuximage.permission', access_tabentry => 'linuximage.imagename=attr:imagename', }, + {attr_name => 'dump', + only_if => 'imagetype=linux', + tabentry => 'linuximage.dump', + access_tabentry => 'linuximage.imagename=attr:imagename', + }, #################### # nimimage table# #################### diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 32c631513..5922c26a0 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -223,7 +223,7 @@ sub mknetboot my $machash = $mactab->getNodesAttribs(\@nodes, ['interface','mac']); - my $reshash = $restab->getNodesAttribs(\@nodes, ['primarynic','tftpserver','xcatmaster','nfsserver','nfsdir', 'installnic']); + my $reshash = $restab->getNodesAttribs(\@nodes, ['primarynic','tftpserver','xcatmaster','nfsserver','nfsdir', 'installnic', 'dump']); my $hmhash = $hmtab->getNodesAttribs(\@nodes, ['serialport', 'serialspeed', 'serialflow']); @@ -243,6 +243,7 @@ sub mknetboot my $platform; my $rootimgdir; my $nodebootif; # nodebootif will be used if noderes.installnic is not set + my $dump; # for kdump, its format is "nfs:///" 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')) { @@ -261,13 +262,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'); if (($ref1) && ($ref1->{'rootimgdir'})) { $img_hash{$imagename}->{rootimgdir}=$ref1->{'rootimgdir'}; } if (($ref1) && ($ref1->{'nodebootif'})) { $img_hash{$imagename}->{nodebootif} = $ref1->{'nodebootif'}; } + if ( $ref1 ) { + if ($ref1->{'dump'}) { + $img_hash{$imagename}->{dump} = $ref1->{'dump'}; + } + } } else { $callback->( {error => ["The os image $imagename does not exists on the osimage table for $node"], @@ -276,16 +282,19 @@ sub mknetboot } } my $ph=$img_hash{$imagename}; + $osver = $ph->{osver}; $arch = $ph->{osarch}; $profile = $ph->{profile}; - + $rootimgdir=$ph->{rootimgdir}; unless ($rootimgdir) { $rootimgdir="$installroot/netboot/$osver/$arch/$profile"; } $nodebootif = $ph->{nodebootif}; + + $dump = $ph->{dump}; } else { $osver = $ent->{os}; @@ -620,7 +629,12 @@ sub mknetboot # turn off the selinux if ($osver =~ m/fedora12/ || $osver =~ m/fedora13/) { - $kcmdline .= " selinux=0"; + $kcmdline .= " selinux=0 "; + } + + # if kdump service is enbaled, add "crashkernel=" and "kdtarget=" + if ($dump) { + $kcmdline .= " crashkernel=256M\@32M dump=$dump "; } # add the addkcmdline attribute to the end diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 35f7f1a72..0cc6fca45 100644 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -199,8 +199,8 @@ sub process_request { } } - # TODO: following the old genimage code, to update the stateles-only files/directories - # another file should be /opt/xcat/xcatdsklspost, but it seems not necessary + # TODO: following the old genimage code, to update the stateles-only files/directories + # # another file should be /opt/xcat/xcatdsklspost, but it seems not necessary xCAT::Utils->runcmd("mv $rootimg_dir/etc/init.d/statelite $rootimg_dir/.statebackup/statelite ", 0, 1) if ( -e "$rootimg_dir/etc/init.d/statelite"); if ( -e "$rootimg_dir/usr/share/dracut" ) { # currently only used for redhat families, not available for SuSE families diff --git a/xCAT-server/lib/xcat/plugins/statelite.pm b/xCAT-server/lib/xcat/plugins/statelite.pm index 88d9ef80d..a751f2c8e 100644 --- a/xCAT-server/lib/xcat/plugins/statelite.pm +++ b/xCAT-server/lib/xcat/plugins/statelite.pm @@ -109,7 +109,6 @@ sub process_request { $callback->({error=>["The linuximage table cannot be opened."],errorcode=>[1]}); return; } - # get the os, arch, and profile from the image name table. (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile'); if (!$ref) { diff --git a/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite b/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite index f83d28741..5423ab814 100755 --- a/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite +++ b/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite @@ -518,6 +518,38 @@ ResolveLinks # make sure mtab points to the right place: /bin/ln -sf /proc/mounts ${TMPFS}/etc/mtab +# create /etc/sysconfig/network-scripts/ +for i in `/bin/cat /proc/cmdline`; do + KEY=`/bin/echo $i | /bin/awk -F= '{print $1}'` + if [ "$KEY" = "ifname" ]; then + ifname=`/bin/echo $i | /bin/awk -F= '{print $2}'` + MACX=${ifname#*:} + ETHX=${ifname%:$MACX*} + break + elif [ "$KEY" = "netdev" ]; then + ETHX=$netdev + MACX=`/sbin/ip link show $netdev | /bin/grep ether | /bin/awk '{print $2}'` + break + elif [ "$KEY" = "BOOTIF" ]; then + MACX=$BOOTIF + ETHX=`/sbin/ifconfig | /bin/grep -i $BOOTIF | /bin/awk '{print $1}'` + break + fi +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 + 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 +fi + +/bin/cat /etc/resolv.conf > $MNTDIR/etc/resolv.conf + # catch all hack for debugging: #cp -r -a ${DEFAULT}/* /.snapshot/tmpfs/ # foo + diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot index 2206e0b4e..57808f1d3 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot @@ -1,6 +1,7 @@ #!/bin/sh echo $drivers -dracut_install wget cpio gzip dash modprobe touch +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 inst "$moddir/xcatroot" "/sbin/xcatroot" inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite b/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite index 3115fb447..4e5b33975 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite @@ -1,5 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget cpio gzip dash modprobe wc touch +dracut_install wget cpio gzip dash modprobe wc touch echo cut dracut_install grep ifconfig hostname awk egrep grep dirname expr +dracut_install fsck.ext3 fsck.ext4 inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh" diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index edec3ff89..0c7ad1c2f 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -72,7 +72,7 @@ GetOptions( 'l=s' => \$rootlimit, 't=s' => \$tmplimit, 'k=s' => \$kernelver, - 'permission=s' => \$permission + 'permission=s' => \$permission, ); # if "Table.pm" can be found here, the attributes in linuximage and osimage will be updated @@ -247,7 +247,7 @@ unless ($osver and $profile) { print ' genimage [ -i ] [ -n ] [-r ] -k '."\n"; print " --permission only works with statelite mode\n"; print "Examples:\n"; - print " genimage -i eth0 -n tg3 -o centos5.1 -p compute\n"; + print " genimage -i eth0 -n tg3 -o centos5.1 -p compute \n"; print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o centos5.1 -p compute\n"; print " genimage -i eth0 -n igb,e1000e,e1000,bnx2,tg3 -o centos5.4 -p nfsroot\n"; print " genimage -i eth0 -n igb,e1000e,e1000,bnx2,tg3 -o centos5.4 -p nfsroot --permission 777\n"; @@ -1354,9 +1354,16 @@ sub isnetdriver { -sub postscripts { # TODO: customized postscripts +sub postscripts { generic_post(); + # TODO: workaround for kdump on RHEL6 + # add one fake command: fsck.nfs + unless ( -x "$rootimg_dir/sbin/fsck.nfs" ) { + system("echo true > $rootimg_dir/sbin/fsck.nfs; chmod a+x $rootimg_dir/sbin/fsck.nfs"); + } + + if( ! -d "$rootimg_dir/opt/xcat/") { mkdir "$rootimg_dir/opt/xcat/"; } diff --git a/xCAT/postscripts/enablekdump b/xCAT/postscripts/enablekdump new file mode 100755 index 000000000..1445a2c47 --- /dev/null +++ b/xCAT/postscripts/enablekdump @@ -0,0 +1,50 @@ +#!/bin/bash +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#(C)IBM Corp +# + +for i in `cat /proc/cmdline`; do + KEY=`echo $i | awk -F= '{print $1}'` + if [ "$KEY" = "dump" ]; then + DUMP=`echo $i |awk -F= '{print $2}'` + if [ ! -z "$XCAT" ]; then + break + fi + elif [ "$KEY" = "XCAT" ]; then + XCAT=`echo $i |awk -F= '{print $2}'` + if [ ! -z "$DUMP" ]; then + break + fi + fi +done + +if [ ! -z "$DUMP" ]; then + # parse "dump=:///" + KDPATH=${DUMP#*:} + KDPROTO=${DUMP%:$KDPATH*} + + KDPATH=${KDPATH/\/\//} + KDIP=`echo $KDPATH | cut -d'/' -f1` + KDPATH=${KDPATH/$KDIP/} + + # if "dump=:///", use $xcatmaster as the default NFS server + if [ -z $KDIP ]; then + KDIP=${XCAT%:*} + fi + + if [ "$KDPROTO" = "nfs" ]; then + echo "net $KDIP:$KDPATH" > /etc/kdump.conf + fi + + # workaround for RHEL6 + KDTMPSERVER=${XCAT%:*} + /bin/mount $KDTMPSERVER:/install/kdump/tmp /var/tmp + + /etc/init.d/kdump restart + + /bin/umount /var/tmp +else + /bin/echo "The kdump server is not configured" +fi + +exit 0 diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index f5667718d..959b7f8f5 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -69,6 +69,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d mkdir -p $RPM_BUILD_ROOT/install/postscripts mkdir -p $RPM_BUILD_ROOT/install/prescripts +mkdir -p $RPM_BUILD_ROOT/install/kdump/tmp # workaround for RHEL6 mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/ cd $RPM_BUILD_ROOT/%{prefix}/share/xcat/