detection and use of multiple CD/DVDs
Dale Einarson
dale at bic.mni.mcgill.ca
Wed Aug 4 20:42:36 CEST 2004
Allo,
I was wondering if any one had come up with a better idea for
distinguishing more then one IDE CDROM, DVD, DVDR, DVDR at a time then;
Adding ide-scsi to boot switches
Linking appropriate device names
Adding mount points to autofs?
If there is a better way( I am sure, or at least I hope) I would be
greatful for some pointers. Sorry for the long read, thanks for any help.
Disclaimers:
I am new to linux so hardware detection utilities are not something
I am greatly familiar with. I realize this is prone to break(and
messy), but it works :}
##############################################################
# Once completed a user with more than one cd/dvd burning device
# * should have a link from scd to the apropriate name(cdr/dvdr etc)
# * should have autofs handling the mounting
# * should have grub (in this case) providing the ide-scsi argument
##############################################################
CDLOG=/tmp/cdrom.log
# +------------------------------------------------------
# | Define devs for DVD through CD
# | -- Any line starting with hd containing a 'CD word'
# | add to $CDLOG
# +------------------------------------------------------
DVDR=`dmesg | grep "DVD.RW"|cut -d: -f1|grep ^hd.|sort -u|tee $CDLOG`
CDR=` dmesg|grep "RW"|fgrep -v -f $CDLOG|cut -d: -f1|grep ^hd.|sort
-u|tee -a $CDLOG`
DVD=` dmesg|grep "DVD.ROM"|fgrep -v -f $CDLOG|cut -d: -f1|grep
^hd.|sort -u|tee -a $CDLOG`
CD=` dmesg|grep "CD"|fgrep -v -f $CDLOG|cut -d: -f1|grep ^hd.|sort
-u|tee -a $CDLOG`
# +------------------------------------------------------
# | make organized list of 'writer' devs ( aka scd?)
# | - aiding the numbering scheme
# +------------------------------------------------------
SCD=`echo -e "$DVDR $CDR" |tr " " '\012' |sort -u`
# +------------------------------------------------------
# | initialize device numbers for dvdr, cdr and scd
# +------------------------------------------------------
DNO=0
CNO=0
CDNO=0
CDOPTS="-fstype=iso9660,ro,sync,nodev,nosuid"
# +------------------------------------------------------
# |
# | link hd? to $NAME, add point to autofs
# |
# | if NAME=writer add bootargs hd?=ide-scsi
# | +-> if DVDR use dvdr, else use cdr
# +------------------------------------------------------
addpoint(){
if [ "$NAME" == "writer" ] ; then
if ( echo $DVDR | grep -q $DEV ) ;then
NAME=dvdr
NO=$DNO
DNO=`expr 1 + $DNO`
else
NAME=cdr
NO=$CNO
CNO=`expr 1 + $CNO`
fi
export BOOTARGS=" $BOOTARGS $DEV=ide-scsi"
#### IF ide-scsi then scd should be used not $DEV
DEV=scd
ln -s /dev/$DEV$CDNO $target/dev/$NAME$NO
echo $NAME$NO $CDOPS :/dev/scd$CDNO >> $target/etc/AutoFS/auto.mnt
CDNO=`expr 1 + $CDNO`
else
ln -s /dev/$DEV $target/dev/$NAME$NO
echo $NAME$NO $CDOPS :/dev/$DEV$NO >> $target/etc/AutoFS/auto.mnt
fi
NO=`expr 1 + $NO`
}
# +------------------------------------------------------
# +------------------------------------------------------
# For each DEV call addpoint with NAME=`device type`
# and increment the device number ( eg dvd0, dvd1 )
# where "device type" is either writer, DVD or CD
# +------------------------------------------------------
for DEV in $SCD ;do
NAME=writer
addpoint
done
# reset dev number
NO="0"
for DEV in $CD ;do
NAME=cdrom
addpoint
NO=`expr 1 + $NO`
done
# reset dev number
NO="0"
for DEV in $DVD ;do
NAME=cdrom
addpoint
NO=`expr 1 + $NO`
done
# +------------------------------------------------------
# | add $BOOTARGS to the kernel boot args
# +------------------------------------------------------
>>>>SNIP<<<<
cat > $gmenu <<-EOF
# created by FAI
timeout 10
default 0
color cyan/blue white/blue
title Debian GNU/Linux, $kernelversion $BOOTARGS
root $broot
kernel $gpath root=$ROOT_PARTITION $BOOTARGS
$initrdopt
EOF
##############################################################
'Zugemessen ward dem Lichte seine Zeit ; aber zeitlos und
raumlos ist der Nacht Herrschaft.'
Cheers!
dale
More information about the linux-fai
mailing list