diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 02af3abc3..f93823588 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -366,17 +366,27 @@ sub process_request { $callback->({data=>["$verb contents of $rootimg_dir"]}); unlink("$destdir/rootimg.gz"); unlink("$destdir/rootimg.sfs"); + + my $compress="gzip"; + #use "pigz" as the compress tool instead of gzip if "pigz" exist + my $ispigz=system("bash -c 'type -p pigz'"); + if($ispigz == 0){ + $compress="pigz"; + } + + $callback->({info=>["compress method:$compress"]}); + if ($method =~ /cpio/) { if ( ! $exlistloc ) { - $excludestr = "find . -xdev |cpio -H newc -o | gzip -c - > ../rootimg.gz"; + $excludestr = "find . -xdev |cpio -H newc -o | $compress -c - > ../rootimg.gz"; }else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { system("$includestr >> $xcat_packimg_tmpfile"); } - #$excludestr =~ s!-a \z!|cpio -H newc -o | gzip -c - > ../rootimg.gz!; - $excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | gzip -c - > ../rootimg.gz"; + #$excludestr =~ s!-a \z!|cpio -H newc -o | $compress -c - > ../rootimg.gz!; + $excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > ../rootimg.gz"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 76b49dcb3..e7076f58c 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -955,6 +955,16 @@ sub mkinitrd_dracut { if ($dracutver > "033") { $additional_options .= " -N"; } + + + #if "pigz" is available in the rootimg, use "pigz" instead of "gzip" + my $compress=qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n"); + if ($compress){ + #take the online cpu numerber as the pigz processes number + my $processnum=qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n"); + $additional_options .= " --compress \"$compress -p $processnum \""; + } + print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n"; !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver") or die("Error: failed to generate the initial ramdisk for $mode.\n"); print "the initial ramdisk for $mode is generated successfully.\n"; diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index a05fc8c99..1bb216ef4 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1088,6 +1088,16 @@ sub mkinitrd_dracut { $additional_options .= " -N"; } + + #if "pigz" is available in the rootimg, use "pigz" instead of "gzip" + my $compress=qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n"); + if ($compress){ + #take the online cpu numerber as the pigz processes number + my $processnum=qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n"); + $additional_options .= " --compress \"$compress -p $processnum \""; + } + print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n"; + !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver") or die("Error: failed to generate the initial ramdisk for $mode.\n"); print "the initial ramdisk for $mode is generated successfully.\n"; diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index 36fe9bcb3..7ab1679d0 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -1629,39 +1629,50 @@ EOMS # } system("chroot /tmp/xcatinitrd.$$/ depmod $kernelver"); - # 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("echo $kernelver\n"); - #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"); - symlink("busybox","/tmp/xcatinitrd.$$/bin/pivot_root"); - symlink("busybox", "/tmp/xcatinitrd.$$/bin/udhcpc"); - symlink("busybox", "/tmp/xcatinitrd.$$/sbin/ifconfig"); - symlink("busybox", "/tmp/xcatinitrd.$$/bin/hostname"); - symlink("busybox", "/tmp/xcatinitrd.$$/bin/route"); - symlink("busybox", "/tmp/xcatinitrd.$$/bin/nc"); - symlink("bash", "/tmp/xcatinitrd.$$/bin/sh"); - symlink("bash", "/tmp/xcatinitrd.$$/sbin/sh"); + # 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("echo $kernelver\n"); + #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"); + symlink("busybox","/tmp/xcatinitrd.$$/bin/pivot_root"); + symlink("busybox", "/tmp/xcatinitrd.$$/bin/udhcpc"); + symlink("busybox", "/tmp/xcatinitrd.$$/sbin/ifconfig"); + symlink("busybox", "/tmp/xcatinitrd.$$/bin/hostname"); + symlink("busybox", "/tmp/xcatinitrd.$$/bin/route"); + symlink("busybox", "/tmp/xcatinitrd.$$/bin/nc"); + symlink("bash", "/tmp/xcatinitrd.$$/bin/sh"); + symlink("bash", "/tmp/xcatinitrd.$$/sbin/sh"); - - #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); - system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-$mode.gz"); - system("rm -rf /tmp/xcatinitrd.$$"); + + my $compress="gzip"; + #if pigz is available,use pigz instead of gzip + my $ispigz=system("bash -c 'type -p pigz' >/dev/null 2>&1"); + if($ispigz == 0){ + $compress="pigz"; + }else{ + $compress="gzip"; + } + + + #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); + print "\ncd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|$compress -9 -c - > $destdir/initrd-$mode.gz \n"; + system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|$compress -9 -c - > $destdir/initrd-$mode.gz"); + system("rm -rf /tmp/xcatinitrd.$$"); }