Mount cdrom in %post on 2.6 kernel

Robert Wehner rwehner at gmail.com
Fri Sep 16 15:10:30 UTC 2005


On 9/13/05, Michael Boman <michael.boman at gmail.com> wrote:
> On 9/13/05, Panu Matilainen <pmatilai at laiskiainen.org> wrote:
> > On Mon, 12 Sep 2005, Robert Wehner wrote:
> >
> > > Anyone have any ideas on how to get the CD mounted during %post in RHEL 4
> > > kickstarts?
> >
> > Run '/sbin/udevstart' at beginning of %post which will create the
> > necessary devices, worked for me at least.
> 
> I was having the same problem, and this thread helped me resolve it.
> What I did was:
> 
> --8<--
> %post
> {
> /sbin/start_udev
> mkdir -p /media/cdrom
> mount /dev/cdrom /media/cdrom
> --8<--

Thanks for everyone's comments on this. I finally got back to it last
night and used a combination of these suggestions to solve the
problem. I essentially used the above, but since I wanted to be able
to handle more than one cdrom device per machine I didn't feel
comfortable using /dev/cdrom and instead made haldaemon update
/etc/fstab so I could grep out all the cdrom devices and mount them in
turn.

find_cd_mounts ()
{
/sbin/udevstart 
/sbin/service messagebus start
/sbin/service haldaemon start
# wait a few seconds for the above to finish
sleep 10
# now figure out what to mount.
if [ -e /proc/sys/dev/cdrom/info ]; then
   cd_devices="$(egrep '^drive name:' /proc/sys/dev/cdrom/info | awk
-F: '{print $2}')"
else
   echo "ERROR: File /proc/sys/dev/cdrom/info does not exist. Cannot mount DVD!"
   return 1
fi

if [ "X${cd_devices}" = "X" ]; then
   echo "ERROR: No CD devices found in /proc/sys/dev/cdrom/info!"
   return 1
else
   for device in ${cd_devices}
   do
      mount_pnt="$(egrep "/dev/${device}[^aA-zZ]" /etc/fstab | awk '{
print $2 }')"
                        if (mount ${mount_pnt}  >> ${LOGFILE} 2>&1); then
                                # run scripts found on CD with run-parts
                                   return
                        else
                                non_mounted="${non_mounted} ${device}"
                        fi
        done
        echo "ERROR: Unable to mount any devices: ${non_mounted}"
        return 1
fi
}

May be a little overkill, but there are a few odd multi-CD boxes out
there that I wanted to be sure I'd eventually find the CD.

thanks again for all the help.

-- 
----
Robert Wehner
rwehner at gmail.com




More information about the Kickstart-list mailing list