I've done some scripts to remove and reassign CD or DVD to lpars.
On each partition i use this script to remove the dvd drive:
CD=`odmget -q name=cd0 CuDv | grep parent`
echo Le lecteur CD est branche sur: $CD
CD=`echo $CD | cut -d '"' -f2`
lsslot -c slot | grep $CD
SLOT=`lsslot -c slot | grep $CD | tr -s ' ' | cut -d' ' -f5`
echo DVD connected to SLOT=$SLOT
#DVD remove
rmdev -l $SLOT -R
echo The DVD was removed
--------------------------------------------------------
I also put this scrit on the HMC and i execute it with putty and ssh key authentification:
# qui detient le lecteur CD
owner=`lshwres -r io --rsubtype slot -m phoenix -F unit_phys_loc,phys_loc,lpar_name | grep U7879.001.DQD0GJA | grep T15 | cut -d ',' -f3`
drc_index=`lshwres -r io --rsubtype slot -m phoenix -F drc_index,unit_phys_loc,phys_loc | grep U7879.001.DQD0GJA | grep T15 | cut -d ',' -f1`
echo DVD is on partition $owner
echo "#########################################"
echo
# Listing OF partitions
echo "Available partitions:"
echo
lssyscfg -m phoenix -r lpar -F name
echo "#########################################"
echo
# Target definition
echo "Target partition ?"
read target
echo
# DVD move
chhwres -r io -m XXXXXXXX -o m -p $owner -t $target -l $drc_index
Note XXXXXXX is your system name