Trying to copy some files from my custom CentOS 7 install ISO to the new install in the %post section.

I've tried all of these:

cp /dev/cdrom/scripts/myscript.sh /etc/myscripts/myscript.sh
cp /dev/cdrom:/scripts/myscript.sh /etc/myscripts/myscript.sh
cp /mnt/sysimage/root/scripts/myscript.sh /etc/myscripts/myscript.sh
cp /scripts/myscript.sh /etc/myscripts/myscript.sh

But none of those end up with myscript.sh being in /etc/myscripts

Where does the install mount the cdrom?


I've tried:

%post --nochroot


set -x -v

cp -r /run/install/repo/scripts/myscript.sh /mnt/sysimage/etc/httpd/conf/myscript.sh

which results in the install not booting (just hangs on the splash)


Simply doing:

%post --nochroot

cp -r /run/install/repo/scripts/myscritp.sh /mnt/sysimage/etc/myscritp.sh


Works and the file is copied from the install media isolinux/scripts dir to the /etc directory on the install target filesystem.

  • Unless it changed for EL7, the path for the CD mountpoint is /mnt/source. Also, please reconsider placing scripts under /etc. (Refer to the FHS.) – Aaron Copley Jun 22 '15 at 15:26
  • @AaronCopley, you may be thinking of /mnt/install, which is (at least as of EL7 when I write this) a symlink to /run/install. /run/install/repo is indeed where the installation source ISO is mounted. /mnt/sysimage is the root of the newly-installed system. – Kenyon May 2 '18 at 21:37

The %post section won't do what you need without some extra work - you need to do this copy inside a %post --nochroot section so you have access to the CD. You can probably issue a mount command inside %post, but using %post --nochroot is likely easier. I don't remember the source ISO layout offhand, but it'll be there somewhere.

  • I was pretty sure that media was still available under %post, but it's been a while. If this ends up being the case, @Kiksy, make sure to copy to /mnt/sysimage/etc/myscripts due to using nochroot. – Aaron Copley Jun 22 '15 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.