diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 3d4225a06..9f584ab9f 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -370,10 +370,9 @@ sub subvars { #for redhat/sl/centos/kvm/fedora if ($inc =~ /#XCAT_PARTITION_START#/) { - my $tempstr = "%include /tmp/partitionfile\n"; - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/; # Put the base64 coded partitionfile into %pre part $partcontent = "cat > /tmp/partscript.enc << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + $partcontent .= "rm -rf /tmp/partitionfile\n"; # Put the code to decode the partitionfile $partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partscript.enc\",\"rb\").read())' >/tmp/partscript\n"; $partcontent .= "chmod 755 /tmp/partscript\n"; @@ -416,7 +415,17 @@ sub subvars { else{ $partcontent =~ s/\s$//; if ($inc =~ /#XCAT_PARTITION_START#/){ - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$partcontent/; + # %pre and decode it out during the running time. + use MIME::Base64; + $partcontent = encode_base64($partcontent); + $partcontent =~ s/\n//g; + # Put the base64 coded partitionfile into %pre part + $partcontent = "cat > /tmp/partitionfile.enc << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + $partcontent .= "rm -rf /tmp/partitionfile\n"; + # Put the code to decode the partitionfile + $partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partitionfile.enc\",\"rb\").read())' >/tmp/partitionfile\n"; + #replace the #XCA_PARTITION_SCRIPT# + $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; } elsif ($inc =~ //){ $inc =~ s/[\s\S]*/$partcontent/; diff --git a/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl b/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl index 12b3e64f4..ae594f700 100644 --- a/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl +++ b/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl @@ -33,7 +33,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl b/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl index 04240e78e..d48755fe0 100644 --- a/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl +++ b/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# @@ -79,7 +79,7 @@ clearpart --all --initlabel #The bootloader config here is commented out #For user customized partition file or partition script, #the bootloader configuration should be specified in the user customized partition file/script -#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitioning +#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitionfile #which is generated in %pre section ##KICKSTARTBOOTLOADER# diff --git a/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl b/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl index 72e8f16c9..bba1f46b0 100644 --- a/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl +++ b/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl @@ -31,7 +31,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl b/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl index c7dbef826..d023171a4 100644 --- a/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl +++ b/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl b/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl index c7dbef826..d023171a4 100644 --- a/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl +++ b/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl b/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl index f3b3d2416..5462e1304 100644 --- a/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl +++ b/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl b/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl index ca50f7631..b6e72556d 100644 --- a/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl +++ b/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl @@ -31,7 +31,7 @@ rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password# #XCAT_PARTITION_START# -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# %pre diff --git a/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl index 5e550a79c..8d2ab086d 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl @@ -33,7 +33,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl index 3d9ec8f2a..a466a2cc3 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl @@ -34,7 +34,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl index f0934b98c..32f356a45 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl @@ -37,7 +37,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl index c049da798..1c346428d 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl @@ -34,7 +34,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# @@ -78,7 +78,7 @@ clearpart --all --initlabel #The bootloader config here is commented out #For user customized partition file or partition script, #the bootloader configuration should be specified in the user customized partition file/script -#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitioning +#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitionfile #which is generated in %pre section ##KICKSTARTBOOTLOADER# diff --git a/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl index d44bf0d8e..4b89b4c77 100644 --- a/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl @@ -33,7 +33,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl index 5e550a79c..8d2ab086d 100644 --- a/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl @@ -33,7 +33,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl index ad0e932f9..cdf799122 100644 --- a/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl @@ -35,7 +35,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl b/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl index 302bf8cc5..338cdc5da 100644 --- a/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl +++ b/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl @@ -34,7 +34,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl b/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl index 4ccebc3f4..5b8b12d25 100644 --- a/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl +++ b/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl @@ -35,7 +35,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl b/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl index c7977d4ec..37a5ee1b2 100644 --- a/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl +++ b/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl @@ -34,7 +34,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# @@ -78,7 +78,7 @@ clearpart --all --initlabel #The bootloader config here is commented out #For user customized partition file or partition script, #the bootloader configuration should be specified in the user customized partition file/script -#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitioning +#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitionfile #which is generated in %pre section ##KICKSTARTBOOTLOADER# diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index 266a19a75..1b5ccd45c 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -21,8 +21,8 @@ if [ -e "/tmp/xcat.install_disk" ]; then instdisk=`cat /tmp/xcat.install_disk` fi -echo "part PV.01 --ondisk=$instdisk" >> /tmp/partitioning -echo "volgroup ibmpkvm_rootvg PV.01" >> /tmp/partitioning +echo "part PV.01 --ondisk=$instdisk" >> /tmp/partitionfile +echo "volgroup ibmpkvm_rootvg PV.01" >> /tmp/partitionfile if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then set +x diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index 79b28a57d..65f66380d 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -207,19 +207,19 @@ BOOTFSTYPE=ext3 EFIFSTYPE=vfat if [ `uname -m` = "ppc64" ]; then - echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning + echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitionfile fi if [ -d /sys/firmware/efi ]; then - echo 'bootloader --driveorder='$instdisk >> /tmp/partitioning - echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitioning + echo 'bootloader --driveorder='$instdisk >> /tmp/partitionfile + echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitionfile else - echo 'bootloader' >> /tmp/partitioning + echo 'bootloader' >> /tmp/partitionfile fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... -echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning -echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning -echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitioning +echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitionfile +echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitionfile +echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitionfile #XCA_PARTITION_SCRIPT# diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 index 9864063fa..f9125de9d 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 +++ b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 @@ -176,33 +176,41 @@ if uname -r|grep -q '^3.*el7'; then fi if [ `uname -m` = "ppc64" -o `uname -m` = "ppc64le" ]; then - echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning + echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitionfile fi if [ -d /sys/firmware/efi ]; then - echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitioning + echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitionfile fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... -echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning -echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning -echo "part pv.01 --size 1 --grow --ondisk $instdisk" >> /tmp/partitioning -echo "volgroup system pv.01" >> /tmp/partitioning -echo "logvol / --vgname=system --name=root --size 1 --grow --fstype $FSTYPE" >> /tmp/partitioning +echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitionfile +echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitionfile +echo "part pv.01 --size 1 --grow --ondisk $instdisk" >> /tmp/partitionfile +echo "volgroup system pv.01" >> /tmp/partitionfile +echo "logvol / --vgname=system --name=root --size 1 --grow --fstype $FSTYPE" >> /tmp/partitionfile -#specify "bootloader" configuration in "/tmp/partitioning" if there is no user customized partition file +#specify "bootloader" configuration in "/tmp/partitionfile" if there is no user customized partition file BOOTLOADER="bootloader " -#specify the kernel options which will be persistent after installation -[ -n "#ENV:PERSKCMDLINE#" ] && BOOTLOADER=$BOOTLOADER" --append=#ENV:PERSKCMDLINE#" - #Specifies which drive the boot loader should be written to #and therefore which drive the computer will boot from. [ -n "$instdisk" ] && BOOTLOADER=$BOOTLOADER" --boot-drive=$(basename $instdisk)" -echo "$BOOTLOADER" >> /tmp/partitioning +echo "$BOOTLOADER" >> /tmp/partitionfile #XCA_PARTITION_SCRIPT# +#specify the kernel options which will be persistent after installation +if [ -n "#ENV:PERSKCMDLINE#" ];then + #append the persistent kernel options to the lines including "bootloader --append" + sed -i -e /bootloader/s#\'#\"#g -e '/bootloader/s/--append=\([^"]\S*[^"]\)/--append="\1"/g' -e '/bootloader/s/--append="\(.*\)"/--append="\1 #ENV:PERSKCMDLINE#"/g' /tmp/partitionfile + #append the persistent kernel options to the lines including "bootloader" without "--append" + sed -i -e '/bootloader/{/append=/!s/$/& --append="#ENV:PERSKCMDLINE#" /}' /tmp/partitionfile + #append the persistent kernel options to /tmp/partitionfile if it does not include "bootloader" + grep bootloader /tmp/partitionfile >/dev/null 2>&1|| echo -e "bootloader --append=\"#ENV:PERSKCMDLINE#\"" >>/tmp/partitionfile +fi + + # The following code is to generate the repository for the installation cat /proc/cmdline