1

I want to write a bash script that creates a Scientific Linux 7.2 iso with a custom kickstart file, creates a new VirtualBox VM, and installs the iso onto that VM.

I have two scripts, installBaseOS.sh and createKSISO.sh. Here are both:

installBaseOS.sh:

#!/bin/sh
set -e

../src/sh/createKSISO.sh
VM='testVM'
ISO=test/boot.iso

VBoxManage createhd --filename=test/$VM.vdi --size=16000 >> test/install.log 2>&1
VBoxManage createvm --name=$VM --ostype="Linux_64" --register >> test/install.log 2>&1

VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium test/$VM.vdi

VBoxManage storagectl $VM --name "IDE Controller" --add ide
VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium $ISO

VBoxManage modifyvm $VM --ioapic on
VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
VBoxManage modifyvm $VM --memory 1024 --vram 128
VBoxManage modifyvm $VM --nic1 bridged --bridgeadapter1 wlo1

VBoxHeadless -s $VM >> test/install.log 2>&1 

and createKSISO.sh:

#!/bin/sh
mkdir test/bootiso
sudo mount -o loop ../bin/SL-72.iso test/bootiso

mkdir test/bootisoks
cp -r test/bootiso/* test/bootisoks/

sudo umount test/bootiso && rmdir test/bootiso

chmod -R u+w test/bootisoks
cp ../src/cfg/ks.cfg test/bootisoks/isolinux

sed -i 's/append\ initrd\=initrd0.img/append initrd=initrd0.img\ ks\=cdrom:\/ks.cfg/' test/bootisoks/isolinux/isolinux.cfg

cd test/bootisoks && mkisofs -o ../boot.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -r -J -v -T isolinux/. .
cd ../..
rm -r test/bootisoks

And finally my kickstart file ks.cfg:

auth --enableshadow --enablemd5
install
reboot --eject
eula --agreed
cmdline
ignoredisk --only-use=sda
keyboard --vckeymap=us --xlayouts='us'
lang en_US.UTF-8

logging --level=debug
rootpw testpass
timezone US/New_York
bootloader --location=mbr --boot-drive=sda
clearpart --all --initlabel
part pv.0 --size=1 --grow
volgroup rootvg01 pv.0
logvol / --fstype=ext4 --name=lv01 --vgname=rootvg01 --size=1 --grow

services --enable=NetworkManager,sshd

%packages
@base
@core
%end

If I comment out the sed command in createKSISO.cfg so that the boot process isn't looking for a kickstart file, the VM boots up into the live CD without issue, so I am fairly certain that I am creating the ISO correctly (mostly).

What happens if I add the ks=/ks.cfg to the boot is I get 3 lines on the boot log:

[ OK ] Started Show Plymouth Boot Screen.
[ OK ] Reached target Paths.
[ OK ] Reached target Basic System.

Then it hangs for a couple minutes before I start getting dracut-initqueue timeout warnings. After those I get to a dracut console and it tells me to look at /run/initramfs/rdsosreport.txt. I don't have any way to get that file off the VM, and it is several hundred lines long, but I have copied the few lines directly before the start of the dracut-initqueue warnings appear:

localhost kernel: sda: unknown partition table
localhost kernel: sd 0:0:0:0: [sda] Attached SCSI disk
localhost systemd[1]: Received SIGRTMIN+20 from PID 357 (plymouthd)

That last SIGRTMIN appears 4 times over about 3 seconds, then the timeout warnings appear about 1.5 minutes later.

I think my problem is caused by either a bad kickstart file, or the file isn't being found properly. I have tried a number of example RHEL 7 kickstart files from the web to try to figure out if it is the first issue, but haven't had any luck. What I would like to know is either the next step to debug why the kickstart of the VM fails, or what my issue is. Once I have something working I plan on editing the kickstart file to end up with the system I actually want, but I have to get something working first.

0

It turned out to be a rather simple (stupid) mistake. Inside the isolinux.cfg file, on the same line modified by the sed command in createKSISO.sh, there is a key/value pair root=live:CDLABEL=SL-72-x86_64-LiveCD. In about half of the tutorials I found online on creating a kickstarted ISO, the mkisofs command included the options -V "Your CD Name Here" or something similar, with no explanation as to the importance of this option. I didn't care what my CD was called since it was temporary, so I ignored this.

However, for the created ISO to be bootable, the root label and the CD name must match. If not the isolinux boot cannot find the OS to boot from the live CD. The quick fix for this was I simply provided the name already in the isolinux.cfg to the -V option in my createKSISO script. A more appropriate answer would be to make a custom name, then use sed to replace it in the isolinux.cfg.

Changing this, the newly created ISO boots, and the modifications made elsewhere in the scripts are seen in the file system.

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.