Kickstart installation from USB -- Kickstart location

After managing to get a Fedora ISO to rebuild successfully (for a USB stick) after adding a kickstart file (https://serverfault.com/questions/548405/), I now have an issue with locating the kickstart file on the USB media.

When this is done from a CDROM you can simply kickckstart by adding this parameter to boot:

linux ks=cdrom

This will kickstart (providing the kickstart file is named ks.cfg and is in the root of the disk).

Now, obviously this will be different for the USB drive, so from my research, I assumed that this line would do the job:

linux ks=hd:sdb1:/ks.cfg

Evidently this does not work. I get an error informing me this drive is already mounted and cannot be remounted.

EDIT: Actual error message:

mount: /dev/sdb1 is already mounted or /run/install/tmpmnt0 busy
Warning: Can't get kickstart from /dev/sdb1:/ks.cfg

To test that the syntax was correct I placed the kickstart file on another USB stick and loaded the same command to grab ks.cfg from the new location:

linux ks=hd:sdc1:/ks.cfg

This does work (providing USB sticks are mounted in order, boot -> sdb1, kickstart -> sdc1). The install will kickstart and complete the install with no issue. Obviously having to use 2 pen drives is somewhat frustrating and unreliable.

Is there a way around this?


I've tried everything, but only this seems to work: put the ks.cfg inside the initrd. So the steps below extract initrd, add the ks.cfg in there, and recreate it. Tested with CentOS7

First mount the original .iso image on your pc, and copy its contents under tmp/

Then,

#Keep the original file
cp -ai tmp/isolinux/initrd.img initrd.img.orig
mkdir irmod
cd irmod

#Extract initrd in irmod/
xz -d < ../tmp/isolinux/initrd.img | cpio --extract --make-directories --no-absolute-filenames

#Add the ks.cfg in there
cp ../tmp/ks.cfg .

# Recreate the initrd.img inside isolinux/
find . | cpio -H newc --create | xz --format=lzma --compress --stdout > ../tmp/isolinux/initrd.img

#cleanup
cd ..
rm -r irmod

# Add  ks=file:/ks.cfg to the boot parameters in isolinux.cfg. you can do it by hand, this is an example for our own isolinux.cfg
sed -s -i 's|ks=.*ks\.cfg ksdevice=link|ks=file:/k1.cfg|' ../tmp/isolinux/isolinux.cfg ../isolinux.cfg

Then proceed with creating the image as usual:

cd tmp/

imgname="inaccess-centos7-ks1-v1.iso"
xorriso -as mkisofs -R -J -V "CentOS 7 x86_64" -o "../${imgname}" \
        -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4  \
        -boot-info-table -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin .
cd ..

I was able to solve this by doing the following:

  • Place the kickstart file at the top of the isolinux directory and make sure it is named ks.cfg
  • my isolinux.cfg file looks like this:

    label linux
      menu label ^Install CentOS 7
      kernel vmlinuz
      append initrd=initrd.img inst.ks=hd:LABEL=CentOS\x207\x20x86_64:/isolinux/ks.cfg inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet
    

Using the drive label when referencing ks.cfg makes the resulting iso image more portable. (it can turned into a bootable USB drive)


My favourite method is to use UUID, because it is stable.

I use two pendrive, first with the CentOS, second with kickstart. After save a kickstart on second pendrive I check its UUID in linux with blkid command: /dev/sdg1: UUID="885E:0BD1" TYPE="vfat"

And after that I use it in installation page: ks=hd:UUID=885E:0BD1:/ks.cfg

It really works!