-1

I have created bootable USB with custom folder in it, After installation i want to copy files from USB to local directory, Following is kickstart file %post section

%post --nochroot --erroronfail --log=/mnt/sysimage/root/ks-post.log
cp -af /run/install/repo/custom/Router_CFG.ini /var/lib/tftpboot
%end

Above code throws error that /var/lib/tftpboot directory doesnt exist, i removed --nochroot

%post --erroronfail --log=/mnt/sysimage/root/ks-post.log
cp -af /run/install/repo/custom/Router_CFG.ini /var/lib/tftpboot
%end

and now it complain that USB mount point (/run/install/repo) is not available.

Then i tried to mount USB drive

%post --erroronfail --log=/mnt/sysimage/root/ks-post.log
mkdir /mnt/myusb
usbblkid=$(blkid -L "CentOS 7 x86_64")
mount $usbblkid /mnt/myusb
cp -af /mnt/myusb/custom/Router_CFG.ini /var/lib/tftpboot
%end

Now its throwing error

mount: Special device /dev/sdc1 doese not exist
0

Your first attempt was almost correct. Try it this way:

%post --nochroot --erroronfail --log=/mnt/sysimage/root/ks-post.log
cp -af /run/install/repo/custom/Router_CFG.ini /mnt/sysimage/var/lib/tftpboot
%end

When using %post --nochroot, the root of the new system will be at /mnt/sysimage so you'll need to prefix it to all the paths referring to the new system you're installing. The installation media will be at /run/install/repo.

If you remove the --nochroot, then the root of the new system will be at /, but the installation media will be inaccessible without extra steps. Your second attempt might have worked if done like this (adapted from a working RHEL7.2 postinstall configuration I made and tested earlier):

%post --erroronfail --log=/root/ks-post.log
mkdir /mnt/myusb
mount /dev/disk/by-label/CentOS*7*x86_64 /mnt/myusb
cp -af /mnt/myusb/custom/Router_CFG.ini /var/lib/tftpboot
umount /mnt/myusb
rmdir /mnt/myusb
%end

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.