LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Copying files to the system from USB Bootable Drive using postinstallation script in RHEL7.2 kickstart file (https://www.linuxquestions.org/questions/linux-newbie-8/copying-files-to-the-system-from-usb-bootable-drive-using-postinstallation-script-in-rhel7-2-kickstart-file-4175616861/)

dachakku 11-02-2017 06:47 PM

Copying files to the system from USB Bootable Drive using postinstallation script in RHEL7.2 kickstart file
 
Hi,
I'm trying to install RHEL7.2 OS from a USB drive (Linux bootable)
I have kickstart file at the root of the pendrive and configured in grub.cfg. I am able to install Linux without any user interaction.

Problem I am facing is, I need to run a startup script when Linux boots after installation is complete. I have the startup script in the root of the USB drive. And I want to copy this file to /etc/init.d folder at the end of installation.
But I am not sure in which path the source USB drive is mounted. I tried below post installation script, but I keep getting error. Can someone help to point out in which path the source USB drive will be mounted, or how to copy the file from source USB drive to /etc/init.d ?

Code:

%post --nochroot --log=/mnt/sysimage/root/ks-post.log
cp -af /mnt/source/testscript /mnt/sysimage/etc/init.d/testscript
chkconfig --add testscript
%end

error received:
cp: cannot stat `/mnt/source/testscript': No such file or directory

Thanks,
Arun D

TB0ne 11-02-2017 07:33 PM

Quote:

Originally Posted by dachakku (Post 5776386)
Hi,
I'm trying to install RHEL7.2 OS from a USB drive (Linux bootable) I have kickstart file at the root of the pendrive and configured in grub.cfg. I am able to install Linux without any user interaction.

Problem I am facing is, I need to run a startup script when Linux boots after installation is complete. I have the startup script in the root of the USB drive. And I want to copy this file to /etc/init.d folder at the end of installation.
But I am not sure in which path the source USB drive is mounted. I tried below post installation script, but I keep getting error. Can someone help to point out in which path the source USB drive will be mounted, or how to copy the file from source USB drive to /etc/init.d ?
Code:

%post --nochroot --log=/mnt/sysimage/root/ks-post.log
cp -af /mnt/source/testscript /mnt/sysimage/etc/init.d/testscript
chkconfig --add testscript
%end

error received:
cp: cannot stat `/mnt/source/testscript': No such file or directory

Did you look at the Red Hat documentation, or call Red Hat support? You are PAYING FOR RHEL, RIGHT????
https://access.redhat.com/documentat...2-options.html
https://access.redhat.com/documentat...allconfig.html

Since the thumbdrive can't be mounted reliably from one system to another, that rules that out. But this is confusing at the root...since you've built a kickstart server and image already, why don't you incorporate what you want into that image? Or as an RPM to get installed after installation, as part of your first-boot? Red Hat support would probably be able to answer easily. You are limited as to what you can do in this scenario.

dachakku 11-08-2017 06:14 AM

Hi TB0ne,
Thanks for your update. Sorry for the delay in reply.
I went through the MAN pages, but couldn't find any help related to USB Mount path during installation. Will check with Redhat support.

Also, I'm trying to include the files in the init.rd Image and copy the files after installation is complete. Will see if it helps.

Thanks,
Arun D

dachakku 11-09-2017 10:48 AM

Hi,

Below post installation script works for me. I'm able to identify the blkid of pendrive using Volume name and mount it to a path, and from there copy the files needed. So for now I'm going with this.

Code:

%post --log=/root/ks-post.log
mkdir /mnt/tmp
usbblkid=$(blkid -L "%VOLNAME%")
mount $usbblkid /mnt/tmp
cp -af /mnt/tmp/testscript /etc/init.d/testscript
chkconfig --add testscript
umount /mnt/tmp
%end

Thanks,
Arun D


All times are GMT -5. The time now is 09:52 AM.