LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-01-2010, 04:44 PM   #1
quasi3
Member
 
Registered: Mar 2006
Posts: 41

Rep: Reputation: 16
Using kickstart post install to copy remote files


CentOS 5.3 32bit

I'm having trouble trying to copy files from an nfs mounted remote machine during the the post install with kickstart. First is this possible, and if so can you see what I'm doing wrong? thanks.
My post install:

%post
mkdir /mnt/foo
mkdir /mnt/foo/downloads
mount 206.xx.xx.xxx:/downloads /mnt/foo/downloads
ln -s /mnt/foo/downloads /downloads
sed -i '$ a\foo:/downloads /mnt/foo/downloads nfs exec,dev,suid,rw,bg,soft,rsize=8192,wsize=8192 1 1' /etc/fstab
%end
%post --nochroot
cp -r /downloads/thirdparty/importantFolder /mnt/sysimage/opt
%end
 
Old 02-01-2010, 04:50 PM   #2
Chromezero
Member
 
Registered: Nov 2004
Location: Arizona
Distribution: Slackware, RHEL, others
Posts: 470

Rep: Reputation: 40
Yes, this can certainly be done. Perhaps it's just a typo, but your cp line does not include the full path.
Code:
cp -r /downloads/thirdparty/importantFolder /mnt/sysimage/opt
This should probably be like this.
Code:
cp -r /mnt/foo/downloads/thirdparty/importantFolder /mnt/sysimage/opt
Also, this doesn't need to be in your /etc/fstab to copy files over but it appears your sed line should be ok.

Last edited by Chromezero; 02-01-2010 at 04:52 PM.
 
Old 02-02-2010, 07:59 AM   #3
quasi3
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 16
Actually the nfs mount will be permanent after the install, which is why it's in fstab and it does work.
Also a link '/downloads' is created pointing to the '/mnt/foo/downloads' dir.

My concern is that the mount is not happening during post install.
 
Old 02-02-2010, 08:42 AM   #4
Chromezero
Member
 
Registered: Nov 2004
Location: Arizona
Distribution: Slackware, RHEL, others
Posts: 470

Rep: Reputation: 40
Oops, I overlooked your link for /downloads. In any event, I don't see anything wrong except for maybe the two entries for %post and %end. I'm not sure how this works out, as I've never tried it. I use post install scripts pretty frequently, but have never tried two entries. My concern is that when it hits the first %end, it stops there without actually copying the files over.
 
Old 02-02-2010, 09:09 AM   #5
quasi3
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 16
I had read that a'%post --nochroot' section was needed to copy files to the new filesystem. I had originally just used
'cp -r /downloads/thirdparty/importantFolder /opt' in the initial'%post' section but this was not working. This is very frustrating.
 
Old 02-02-2010, 10:57 AM   #6
Chromezero
Member
 
Registered: Nov 2004
Location: Arizona
Distribution: Slackware, RHEL, others
Posts: 470

Rep: Reputation: 40
After some research I found that the "--nochroot" option would only be used if you wanted to copy something from the installation media(i.e., not in the local structure). However, since you've mounted the nfs directory, it would be handled as if it were a local file. So, you shouldn't need that option. Here's a snipet of a kickstart file I use on a regular basis. I've cut out some things, such as the other 50+ chkconfig entries, to save space here in the thread. But, it includes the pertinent parts.
Code:
%post

# A complete history of the post-install script should be saved
set -x
exec >/var/log/kickstart-post.log 2>&1
#Save a copy of the RPM list as we started
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" > /var/log/kickstart-rpm.init

# Services to start
/sbin/chkconfig amd on                # Automounter
/sbin/chkconfig finger on             # Finger server

# Copy locally customized files
mkdir /tmp/localfiles

# copy generic files
mount 192.XXX.XXX.XXX:/kickstart/RedHat/localfiles /tmp/localfiles
# Set up banners
cp -p /tmp/localfiles/issue /etc
cp -p /tmp/localfiles/issue.net /etc
cp -p /tmp/localfiles/nsswitch.conf /etc
cp -p /tmp/localfiles/resolv.conf /etc
I'm wondering if your issue is related to a change in network config. Perhaps the nfs mount isn't actually happening, causing the copy to fail.
 
Old 02-02-2010, 02:35 PM   #7
quasi3
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 16
Still not working.
Here's what I just tried and /opt is still empty:

%post
mkdir /mnt/foo
mkdir /mnt/foo/downloads
mount 206.xxx.xxx.xxx:/downloads /mnt/foo/downloads
cp -r /mnt/foo/downloads/thirdparty/importantFolder /opt
%end
 
Old 02-02-2010, 04:53 PM   #8
Chromezero
Member
 
Registered: Nov 2004
Location: Arizona
Distribution: Slackware, RHEL, others
Posts: 470

Rep: Reputation: 40
After the kickstart and the machine is ready to go, is the nfs still mounted? It would help to narrow down the problem some. Try to figure out if the problem is with the mounting or the copying. My guess would be the nfs mount. I'm assuming that you have nfs configured on the remote machine, but it wouldn't hurt to double check. Honestly, I'm running out of things to try. Everything in your script should work just fine.
 
Old 02-02-2010, 05:11 PM   #9
quasi3
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 16
I can't figure out how to get any logging to work.
The links to the mounted directory work after reboot. But the mounting there is in the fstab.
So I can't tell if the mount works or not during the post install. I may try to touch a file in the nfs mount dir during the post.
 
Old 02-03-2010, 01:49 PM   #10
quasi3
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 16
Found the problems.

Mounting:
Noticed 'mount.nfs: Input/output error' in kickstart log file.
Apparently in CentOS 5 you have to add '-o nolock,udp' to the mount command when using it in kickstart:
mount 206.xxx.xxx.xxx:/downloads /mnt/foo/downloads -o nolock,udp

Then the copy worked:
cp -r /mnt/foo/downloads/thirdparty/importantFolder /opt

Logging:
I wasn't adding '/mnt/sysimage' to my log path
%post --log=/mnt/sysimage/root/kick.log

A little confused on when to use '/mnt/sysimage' in my paths. In this case I needed it for the logging but not the copy.

Thanks for the help.
 
Old 02-03-2010, 02:09 PM   #11
Chromezero
Member
 
Registered: Nov 2004
Location: Arizona
Distribution: Slackware, RHEL, others
Posts: 470

Rep: Reputation: 40
It's interesting that you had to specify the "udp" option, since that is the default option I believe. In any event, I'm glad to hear that you found the problem.
 
Old 02-03-2010, 02:11 PM   #12
quasi3
Member
 
Registered: Mar 2006
Posts: 41

Original Poster
Rep: Reputation: 16
Actually I'm not sure if I needed to add the udp. Used an example.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
RHEL5 - copy files from DVD during %post in kickstart jnojr Red Hat 2 12-13-2010 06:03 PM
Copy files from kickstart nfs mount to new system... custangro Linux - General 2 10-07-2008 09:55 AM
FC6 kickstart doesn't post install pete@cosc. Fedora - Installation 2 01-15-2007 08:54 PM
copy files of cd post-install? tuppe Red Hat 2 12-05-2003 11:27 AM
Kickstart Post-install tasks TheRealDeal Linux - General 0 09-03-2003 01:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:14 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