-   Red Hat (
-   -   RHEL5 - copy files from DVD during %post in kickstart (

jnojr 01-14-2009 11:32 AM

RHEL5 - copy files from DVD during %post in kickstart
I want to put various files on a DVD along with a kickstart file, and have those files copied during the %post section. Googling led me top several mentions of how Red Hat broke anaconda and made it eject the CD/DVD too early. I also found a post which supposedly described how to fix this (create a new stage2.img that has two lines in swapped). I followed that process (mounted the original stage2.img, copied the contents to a new directory, made the change to, and used mksquashfs to create a new stage2.img) However, after copying my new stage2.img into my DVD and creating an ISO, it doesn't work... after loading drivers for SCSI, I get a message:

The Red Hat Enterprise Linux Server CD was not found in any of your CDROM drives. Please insert the Red Hat Enterprise Linux Server CD and press OK to retry.

Alt-F3 shows the last line as "ejecting /tmp/cdrom..."

So, the "fix" I found actually made things worse!

What is the real answer here? What do I need to do to keep the DVD mounted during %post?

rayfordj 01-17-2009 09:51 AM

I do not believe that they actually eject it (or at least has been my experience) but rather umount it and remove the device node. I'm not sure if this is still a problem with newer media releases of RHEL5...

You may try something like this to recreate the device node for the optical drive and mount the media for access again:


ls -l /tmp/cdrom > /tmp/


%post --nochroot


#make sure we have access to media before continuing
if [ ! -b /tmp/cdrom ]
  #get the major number
  major=$(cat /tmp/ | cut -d" " -f5)
  #strip of the trailing comma
  #get the minor number
  minor=$(cat /tmp/ | cut -d" " -f6)
  #make sure we have what we need; create device node if so
  [ -n "$major" -a -n "$minor" ] && mknod /tmp/cdrom b $major $minor

#make sure mount directory exists
if [ ! -d /mnt/source ]
  mkdir -p /mnt/source
#should be ready to mount the optical media
mount -t iso9660 -o ro /tmp/cdrom /mnt/source


Goll 12-13-2010 06:03 PM

How to do it on CentOS 5.2
This is how I did it on CentOS 5.2:

in my ks.cfg:

%post --nochroot


mkdir /tmp/c
mount -t iso9660 /tmp/cdrom /tmp/c
mkdir -p /mnt/sysimage/mnt/readme
cp /tmp/c/RELEASE-NOTES-es /mnt/sysimage/mnt/readme
umount /tmp/c

All times are GMT -5. The time now is 03:02 AM.