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 e355c3c33..217b5544d 100644 --- a/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl +++ b/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl @@ -25,14 +25,25 @@ timezone --utc "#TABLE:site:key=timezone:value#" # rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password# -#partition / --ondisk=/dev/mapper/ibmpkvm_vg_root-ibmpkvm_lv_root -part PV.01 --ondisk=/dev/sda -volgroup ibmpkvm_rootvg PV.01 -#logvol / --vgname=VOLGROUP_NAME --noformat -#partition / --ondisk=/dev/sda #the --devicename must specify right now, but without network command, it can also work, so we delete it. #network --bootproto dhcp + + +#XCAT_PARTITION_START# +%include /tmp/partitioning +#XCAT_PARTITION_END# + +%pre +{ +set -x +touch "/startpre" +#add the code to determine the disk to partition here +#default is /dev/sda +#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.pkvm3# +} >>/tmp/prelog 2>&1 +%end + %post touch "/startpost" diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 new file mode 100755 index 000000000..7ddca1fa2 --- /dev/null +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -0,0 +1,58 @@ +#find first available block device (sda or vda likely) +#TODO: pick a likely non-SAN target if possible + +shopt -s nullglob + +#first take the disk with the MAX WWN numer to be the installdisk +if [ -z "$instdisk" ]; then + disks=$(awk -F' ' '{print $4 }' /proc/partitions |grep -e "sd[a-z]\+$") + for disk in $disks; do + diskinfo=$(udevadm info --name $disk) + diskname=$(IFS= ;echo $diskinfo|grep '\'|cut -d "=" -f2|tr A-Z a-z) + devtype=$(IFS= ;echo $diskinfo|grep '\'|cut -d "=" -f2|tr A-Z a-z) + devwwn=$(IFS= ;echo $diskinfo|grep '\'|cut -d "=" -f2|tr A-Z a-z) + [ "$devtype" != "disk" ] && continue + diskentry=$diskentry"$diskname $devwwn\n" + done + instdisk=$(echo -e $diskentry|grep -v "^$"|sort -k 2 -b -r|cut -d" " -f1|head -n 1) +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... +if [ -z "$instdisk" ]; then + for disk in /dev/sd*[^0-9]; do + currdriver=`udevadm info --attribute-walk --name $disk |grep DRIVERS|grep -v '""'|grep -v '"sd"'|head -n 1|sed -e 's/[^"]*"//' -e 's/"//'` + case "$currdriver" in + "ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct + if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort + ;; + "mptsas"|"mpt2sas"|"mpt3sas") #*PROBABLY* not SAN, but SAS SAN is possible + if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort + ;; + *) + if [ -z "$firstdisk" ]; then firstdisk=$disk; fi #remember first disk as a guess of medium resort + ;; + esac + done +fi + +if [ -z "$instdisk" ]; then + if [ ! -z "$firstdirectdisk" ]; then + instdisk=$firstdirectdisk + elif [ ! -z "$probablyfirstdirectdisk" ]; then + instdisk=$probablyfirstdirectdisk + elif [ ! -z "$firstdisk" ]; then + instdisk=$firstdisk + fi +fi +# Could not determine the install disk for whatever reason, +# try the default /dev/sda +if [ -z "$instdisk" ]; then + instdisk="/dev/sda" +fi + + + +echo "part PV.01 --ondisk=$instdisk" >> /tmp/partitioning +echo "volgroup ibmpkvm_rootvg PV.01" >> /tmp/partitioning + +