LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-02-2017, 06:47 PM   #1
dachakku
LQ Newbie
 
Registered: Nov 2017
Posts: 3

Rep: Reputation: Disabled
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
 
Old 11-02-2017, 07:33 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by dachakku View Post
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.

Last edited by TB0ne; 11-02-2017 at 07:35 PM.
 
1 members found this post helpful.
Old 11-08-2017, 06:14 AM   #3
dachakku
LQ Newbie
 
Registered: Nov 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
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
 
Old 11-09-2017, 10:48 AM   #4
dachakku
LQ Newbie
 
Registered: Nov 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
why copying files to usb drive is slow? seighalani Linux - Software 8 11-18-2015 02:17 AM
Making Kickstart file available on USB drive? nidhi.dube1 Linux - Newbie 2 01-21-2015 03:14 AM
Copying files to USB Thumb Drive Ian D Linux - General 5 02-17-2014 03:27 AM
Copying files to USB Flash Drive Mr. Alex Ubuntu 2 11-10-2010 11:29 PM
Changeing File Names when copying files from system to usb nareshkumar_p Linux - Software 1 02-27-2007 12:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration