LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Using kickstart post install to copy remote files (https://www.linuxquestions.org/questions/linux-general-1/using-kickstart-post-install-to-copy-remote-files-786293/)

quasi3 02-01-2010 04:44 PM

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

Chromezero 02-01-2010 04:50 PM

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.

quasi3 02-02-2010 07:59 AM

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.

Chromezero 02-02-2010 08:42 AM

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.

quasi3 02-02-2010 09:09 AM

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.

Chromezero 02-02-2010 10:57 AM

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.

quasi3 02-02-2010 02:35 PM

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

Chromezero 02-02-2010 04:53 PM

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.

quasi3 02-02-2010 05:11 PM

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.

quasi3 02-03-2010 01:49 PM

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.

Chromezero 02-03-2010 02:09 PM

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.

quasi3 02-03-2010 02:11 PM

Actually I'm not sure if I needed to add the udp. Used an example.


All times are GMT -5. The time now is 10:36 AM.