From 785e2f7c6c5eaf6f7943a4ecceb5dd30f950ff92 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 23 Nov 2015 03:49:48 -0500 Subject: [PATCH 1/5] add disc selecting logic for powerkvm3.1.0 --- .../install/pkvm/compute.pkvm3.ppc64le.tmpl | 21 +++++-- .../share/xcat/install/scripts/pre.pkvm3 | 58 +++++++++++++++++++ 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100755 xCAT-server/share/xcat/install/scripts/pre.pkvm3 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..5ebe36886 --- /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 $devtype $devwwn\n" + done + instdisk=$(echo -e $diskentry|grep -v "^$"|sort -k 3 -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 + + From f53f3854e380670f77ed042cb23d533577351796 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 23 Nov 2015 07:44:52 -0500 Subject: [PATCH 2/5] devtype is useless,remove it --- xCAT-server/share/xcat/install/scripts/pre.pkvm3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index 5ebe36886..c365451b4 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -12,9 +12,9 @@ if [ -z "$instdisk" ]; then 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 $devtype $devwwn\n" + diskentry=$diskentry"$diskname $devwwn\n" done - instdisk=$(echo -e $diskentry|grep -v "^$"|sort -k 3 -b -r|cut -d" " -f1|head -n 1) + 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... From 340516c2c34984e9e82c4238ef919b67d86c7c03 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 23 Nov 2015 08:50:34 -0500 Subject: [PATCH 3/5] disk names might be sd[a-z]+ --- xCAT-server/share/xcat/install/scripts/pre.pkvm3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index c365451b4..cce542a81 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -5,7 +5,7 @@ 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]$") + 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) From dc9017ddd59cb947337fda7f637e405eaebd37d0 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 23 Nov 2015 08:57:32 -0500 Subject: [PATCH 4/5] disk names might be sdaa,sdab.... --- xCAT-server/share/xcat/install/scripts/pre.pkvm3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index cce542a81..3d0775f9e 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -5,7 +5,7 @@ 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]+$") + disks=$(awk -F' ' '{print $4 }' /proc/partitions |grep -e "sd[a-z]\{1,\}$") for disk in $disks; do diskinfo=$(udevadm info --name $disk) diskname=$(IFS= ;echo $diskinfo|grep '\'|cut -d "=" -f2|tr A-Z a-z) From 72cb00d6a47d035e13fc4e330b392cf90b3f0b72 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 23 Nov 2015 09:03:21 -0500 Subject: [PATCH 5/5] disk names might be sdaa,sdab.... --- xCAT-server/share/xcat/install/scripts/pre.pkvm3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index 3d0775f9e..7ddca1fa2 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -5,7 +5,7 @@ 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]\{1,\}$") + 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)