Re: Custom ISO with Kickstart and Local Repos

Andrew Simpson <[email protected]> Fri, 23 Feb 2018 09:14:02 -0500
Newsgroups gmane.linux.redhat.kickstart.general
Message-ID <CAFzrdOz9VL8==h_e-1emsgJ8QY2MFK5gW=goBrmS4bg_EuA_Nw@mail.gmail.com>
--===============4812224750649090430==
Content-Type: multipart/alternative; boundary="94eb2c035484c1f4b40565e1c587"

--94eb2c035484c1f4b40565e1c587
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

so all you're trying to do is add some packages and a kickstart file?

I don't use any external tools.  I add in the new packages into a directory
at the top level of the disc image and modify the Packages directory if I
need to.  then I run createrepo on each "package" directory

createrepo --update -d -g comps.xml ${repo}  trying to remember this, so
verify it's correct.  if you want to use the comps/groups file, use the -g
option, otherwise ignore it.

In my kickstart, I add in the additional package directories as new repos
for yum to find the packages.  after adding ANY rpms, you will need to
re-run createrepo on each folder and add them as repos in the ks file IF
you want anaconda to be able to install them.  otherwise, you can mount in
the post and run rpm commands directly on each command.

to get additional data off of the disc, you will also need to ensure you
"mount" the disc/source somewhere the kickstart can access the data and
your anaconda/isolinux options must be set correctly, so you have to get
inst.ks and inst.stage2 setup properly.

inst.stage2=3Dhd:LABEL=3D${DRIVELABEL} inst.loglevel=3Ddebug lang=3Den_US.U=
TF-8
keymap=3Dus inst.ks=3Dcdrom:/dev/cdrom:/ks/${ksname}.ks

NOTE:  inst.stage2 uses a label designation.  this LABEL value MUST be
exact.  When you generate your iso, usb drive, whatever, it MUST have the
label exactly matching the DRIVELABEL value or it won't install.  Also, you
can use inst.upgrade to point to an upgraded anaconda Product.img file
which can contain rebrading/anaconda customizations.



Here's a kickstart snippet that covers a lot of ground:

"""""""

#PRE Section

  ksDeviceSource=3D$(sed 's/ /\n/g' /proc/cmdline | grep '^inst.ks=3D'|cut
-f1 -d:|cut -f2 -d'=3D')
  if (grep -q "ks=3Dhd:LABEL" /proc/cmdline)
  then
    ksDeviceName=3D$(sed 's/ /\n/g' /proc/cmdline | grep '^inst.ks=3D'|cut
-f2 -d":" | cut -f2 -d"=3D")
    ksDeviceBaseName=3D`blkid -L $ksDeviceName`
    ksDeviceBaseName=3D`basename $ksDeviceBaseName`
  else
    #using a normal dev name, not a LABEL
    ksDeviceName=3D$(sed 's/ /\n/g' /proc/cmdline | grep '^inst.ks=3D'|cut
-f2 -d":")
    ksDeviceBaseName=3D`basename $ksDeviceName`
  fi

  if [[ -z "${repo}" ]]; then
    #Are we using a usb drive?
    if [[ "${ksDeviceName}" =3D=3D "hd" ]]; then
       repo=3D"hd"
    else
      # If no repo was specified, then we must be installing from disc
      repo=3D"cdrom"
    fi
  fi

  # Variable for the repo line:
  srcLoc=3D"/tmp"
  # Mount the source repo
  mkdir -p /tmp/source
  repotype=3D$(echo "${repo}" | cut -d: -f1)
  if [[ "${repotype}" =3D=3D "nfs" ]]; then
    source=3D$(echo "${repo}" | cut -d: -f2-)
    mount -t nfs -o nolock "${source}" /tmp/source
  elif [[ "${repotype}" =3D=3D "cdrom" ]]; then
    echo "cdrom" >> /tmp/pre.ks
    # Re-bind the existing mount otherwise we'll get errors with some devic=
es
    ### WARNING:  RHEL 7 anaconda now mounts to /run/install/repo.
/mnt/stage2 is gone.
    ###  it's possible that we no longer need to do this mount, but
hey, then we'd have to change A LOT!
    mount --bind /run/install/repo /tmp/source
  elif [[ "${repotype}" =3D=3D "hd" ]]; then
   echo "harddrive --partition=3D$ksDeviceBaseName --dir=3D/" >> /tmp/pre.k=
s
    # Re-bind the existing mount otherwise we'll get errors with some devic=
es
    # I am not sure if we need to do the next mount with USB/HD.
    # NOTE:  the next line will not work if we expand to multiple iso(s).
    tmpDIR=3D$(mktemp -d)
    mount -L $ksDeviceName $tmpDIR
    mount -o loop $tmpDIR/imagename*.iso /tmp/source
    srcLoc=3D"/tmp"
    #mount --bind /tmp/source /mnt/source
  fi


  #set the repos here.
cat << EOF > /tmp/repos.ks
repo --name=3D"ELRepo" --baseurl=3Dfile://$srcLoc/source/ELRepo --cost=3D41=
0000
repo --name=3D"EPEL" --baseurl=3Dfile://$srcLoc/source/EPEL --cost=3D400000
repo --name=3D"Extras" --baseurl=3Dfile://$srcLoc/source/Extras  --cost=3D5=
00000

repo --name=3D"Custom" --baseurl=3Dfile://$srcLoc/source/Custom --cost=3D50=
0000


repo --name=3D"Optional" --baseurl=3Dfile://$srcLoc/source/Optional --cost=
=3D350000
repo --name=3D"Supplementary"
--baseurl=3Dfile://$srcLoc/source/Supplementary --cost=3D360000
repo --name=3D"Workstation" --baseurl=3Dfile://$srcLoc/source/Workstation
--cost=3D330000
repo --name=3D"Packages" --baseurl=3Dfile://$srcLoc/source/Packages --cost=
=3D300000
EOF

########## End Pre Section ############

####Post section######

# This is the First Post script,
  # copy things that are needed in chrooted Posts to where they can be foun=
d.
  source /tmp/cmdline  #you won't use these three lines probably
  cp -p /tmp/cmdline /mnt/sysimage/tmp/cmdline
  cp -p /tmp/cmdline /mnt/sysimage/root/cmdline


  # Re-mount the source for the post-scripting
  {{ m.export_cmdline() }}  #This is a JINJA operator, you would need
to add in the mount command here if not using JINJA

  ksDeviceSource=3D$(sed 's/ /\n/g' /proc/cmdline | grep '^ks=3D'|cut -f1
-d:|cut -f2 -d'=3D')

  if (grep -q "ks=3Dhd:LABEL" /proc/cmdline)
  then
    ksDeviceName=3D$(sed 's/ /\n/g' /proc/cmdline | grep '^ks=3D'|cut -f2
-d":" | cut -f2 -d"=3D")
    ksDeviceBaseName=3D`blkid -L $ksDeviceName`
    ksDeviceBaseName=3D`basename $ksDeviceBaseName`
  else
    #using a normal dev name, not a LABEL
    ksDeviceName=3D$(sed 's/ /\n/g' /proc/cmdline | grep '^ks=3D'|cut -f2 -=
d":")
    ksDeviceBaseName=3D`basename $ksDeviceName`
  fi

  if [[ -z "${repo}" ]]; then
    #Are we using a usb drive?
    if [[ "${ksDeviceName}" =3D=3D "hd" ]]; then
       repo=3D"hd"
    else
      # If no repo was specified, then we must be installing from disc
      repo=3D"cdrom"
    fi
  fi


  # Mount the source repo
  mkdir -p /tmp/source
  repotype=3D$(echo "${repo}" | cut -d: -f1)
  if [[ "${repotype}" =3D=3D "nfs" ]]; then
    source=3D$(echo "${repo}" | cut -d: -f2-)
    mount -t nfs -o nolock "${source}" /tmp/source
  elif [[ "${repotype}" =3D=3D "cdrom" ]]; then
    echo ""
    #TODO: this is a legacy item that needs removed.... later
    #mount $(cat /tmp/source) /tmp/source
  elif [[ "${repotype}" =3D=3D "hd" ]]; then
    tmpDIR=3D$(mktemp -d)
    mount -L $ksDeviceName $tmpDIR
    #at this point, /tmp/isodir is the device that is mounted.  useit!
    mount -o loop $tmpDIR/imagename*.iso /tmp/source
  fi



  # Make the source repo available in the chroot
  mkdir -p /mnt/sysimage/tmp/source
  mount --bind /tmp/source /mnt/sysimage/tmp/source

"""""""""""""##### End Post Section ##########


here's the genisoimage command:
genisoimage -r -v \
     -V "LABELNAME.x86_64" -A "${label}" -cache-inodes -J -l \
     -b isolinux/isolinux.bin -c isolinux/boot.cat \
     -no-emul-boot -boot-load-size 4 -boot-info-table \
     -o "${isoLocation}${filename}" disc


  pushd ${isoLocation} >> /dev/null
  # if you want to use a usb drive, then next part is mandatory:
  #make sure the iso is bootable on USB devices
  isohybrid ${filename}
  implantisomd5 ${filename}


Apparently, you can use xorriso, which contains an argument for running
isohybrid.

hope that helps.  All of this stuff for building your own respun disc is
available online.
Such as:
https://devopsmates.com/make-custom-centos-7-rhel-7-cd-kicktart-file/
http://www.smorgasbork.com/2014/07/16/building-a-custom-centos-7-kickstart-=
disc-part-1/

use livecd tools or dd to make a custom bootable disc/usb drive.


Andrew Simpson

On Thu, Feb 22, 2018 at 11:07 PM, Vin=C3=ADcius Ferr=C3=A3o <ferrao@versatu=
shpc.com.br
> wrote:

> Firas, thank you.
>
> That=E2=80=99s appears to be exactly what I need.
>
> I=E2=80=99ll be doing some test tomorrow and report back.
>
> V.
>
> > On 22 Feb 2018, at 22:40, Firas Alshafei <[email protected]>
> wrote:
> >
> > V,
> >
> > If you're adding rpms then you'll need to update the repo to actually
> include them. I'm not familiar with Lorax so I can't really help there, b=
ut
> if your end goal is  a standard RHEL dvd with extra packages that you wan=
t
> to define in your kickstart configuration then it should just require
> createrepo and genisoimage.
> >
> > My use case is fairly vanilla kickstart you might have to modify to sui=
t
> your workflow.
> > - isolinux and efi use the inst.ks and inst.stage2 to point to kickstar=
t
> file and installation source respectively.
> > - kickstart file and pre/post/conf scripts in DVD/kickstart directory
> structure
> > - Packages in the default DVD/Packages and additional packages in
> /DVD/Packages-Extra
> > - I delete all uneeded packages to reduce DVD size, just feed the rpm
> -qa output on an installed system to yumdownloader
> >
> > Here's a script stub - I do something similar in-house to get our DVDs
> created for air-gapped environments (it's a pain).
> > Hope this helps =F0=9F=98=8A
> >
> > #!/bin/bash
> > #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > # Title        : create-iso
> > #
> > # Description  : Generate kickstart dvd
> > #
> > # Author       : Firas AlShafei
> > #
> > # Last Revised : 11/04/2015
> > #
> > #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >
> > # Assume following path structure
> > #
> > # working-directory
> > # |
> > # ---> creat-iso.sh
> > # |
> > # ---> media (DVD media + kickstart + additional packages)
> >
> > # Path variables
> > scriptPath=3D$(dirname "$(readlink -f "$0")")
> > isoPath=3D${scriptPath}
> > releaseName=3D"my-awesome-dvd.iso"
> >
> > # Move repo group info
> > mv ${scriptPath}/media/repodata/*-comps-Server.x86_64.xml
> ${scriptPath}/media/repodata/comps-Server.x86_64.xml
> >
> > # Create repo
> > cd ${scriptPath}/media
> > createrepo --quiet --pretty --update --groupfile
> repodata/comps-Server.x86_64.xml .
> >
> > # Make ISO file
> > echo "=3D=3D Generate DVD Image"
> > echo "=3D ${isoPath}/${releaseName}.iso"
> > genisoimage -r -T -J -V ${releaseName} \
> > -quiet                                \
> > -o ${isoPath}/${releaseName}.iso      \
> > -no-emul-boot                         \
> > -boot-load-size 4                     \
> > -boot-info-table                      \
> > -b isolinux/isolinux.bin              \
> > -c isolinux/boot.cat                  \
> > -eltorito-alt-boot                    \
> > -no-emul-boot                         \
> > -b images/efiboot.img                 \
> > ${scriptPath}/media/
> >
> >
> >
> >
> > Firas AlShafei
> > Senior Lead Engineer
> > Enterprise Software
> > ABB
> >
> > -----Original Message-----
> > From: [email protected] [mailto:kickstart-list-
> [email protected]] On Behalf Of Vin=C3=ADcius Ferr=C3=A3o
> > Sent: Thursday, February 22, 2018 3:47 PM
> > To: [email protected]
> > Subject: Custom ISO with Kickstart and Local Repos
> >
> > CAUTION: This email originated from outside of the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
> >
> >
> > Hello,
> >
> > I=E2=80=99m trying to create a custom ISO with a Kickstart file to achi=
eve a
> complete offline installation.
> >
> > I was able to create the Kickstart file as usual, since I use it for PX=
E
> installs for at least 10 years, but the major problem now is building the
> ISO with the necessary files.
> >
> > I=E2=80=99ve came across a tool named Lorax, but I was not able to crea=
te a
> custom ISO from DVD=E2=80=99s. It only works when point to mirrors, and t=
his is a
> time consuming task. Another problem is that Lorax does not seems to care
> about the /usr/share/lorax/product folder to create a custom Anaconda wit=
h
> the embedded kickstart file on /usr/share/anaconda/
> interactive-defaults.ks.
> >
> > The small ISO generated by Lorax lacks local repositories and I was
> unable to find the appropriate documentation on how to build this scenari=
o.
> So it generates a boot only install that must be done over the Internet.
> >
> > At this moment I=E2=80=99m running Lorax on a CentOS install, I=E2=80=
=99ve got RHEL
> licenses too, but to keep it simple I just went with CentOS. I think this
> is irrelevant information but it=E2=80=99s just for the sake of completio=
n.
> >
> > With genisoimage I was able to add the custom product.img file, that
> I=E2=80=99ve generated by hand with cpio, on the ISO but I was not able t=
o solve
> the local repos problem. There are packages that I would like to add to t=
he
> install media, like Ansible, but they are available only on the Extras
> repository and I=E2=80=99m unsure on how to do this. Just wondering if cr=
eaterepo
> and yumdownloader are necessary...
> >
> > Any help is greatly appreciated.
> >
> > Thanks,
> > V.
> >
> >
> > _______________________________________________
> > Kickstart-list mailing list
> > [email protected]
> > https://emea01.safelinks.protection.outlook.com/?url=3D
> https%3A%2F%2Fwww.redhat.com%2Fmailman%2Flistinfo%
> 2Fkickstart-list&data=3D02%7C01%7Cfiras.alshafei%40us.abb.com%
> 7C61f459f9ce2a4501b84d08d57a3dede1%7C372ee9e09ce04033a64ac07073a9
> 1ecd%7C0%7C0%7C636549328763319165&sdata=3Dryv0YW%2FzOdUplRFSLABdNkRZN%
> 2BZKBJwKVw5CaSDJfRk%3D&reserved=3D0
> >
> > _______________________________________________
> > Kickstart-list mailing list
> > [email protected]
> > https://www.redhat.com/mailman/listinfo/kickstart-list
>
>
> _______________________________________________
> Kickstart-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/kickstart-list
>

--94eb2c035484c1f4b40565e1c587
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">so all you&#39;re trying to do is add some packages and a =
kickstart file?<div><br></div><div>I don&#39;t use any external tools.=C2=
=A0 I add in the new packages into a directory at the top level of the disc=
 image and modify the Packages directory if I need to.=C2=A0 then I run cre=
aterepo on each &quot;package&quot; directory</div><div><br></div><div>crea=
terepo --update -d -g comps.xml ${repo}=C2=A0 trying to remember this, so v=
erify it&#39;s correct.=C2=A0 if you want to use the comps/groups file, use=
 the -g option, otherwise ignore it.</div><div><br></div><div>In my kicksta=
rt, I add in the additional package directories as new repos for yum to fin=
d the packages.=C2=A0 after adding ANY rpms, you will need to re-run create=
repo on each folder and add them as repos in the ks file IF you want anacon=
da to be able to install them.=C2=A0 otherwise, you can mount in the post a=
nd run rpm commands directly on each command.</div><div><br></div><div>to g=
et additional data off of the disc, you will also need to ensure you &quot;=
mount&quot; the disc/source somewhere the kickstart can access the data and=
 your anaconda/isolinux options must be set correctly, so you have to get i=
nst.ks and inst.stage2 setup properly.</div><div><br></div><div>inst.stage2=
=3Dhd:LABEL=3D${DRIVELABEL} inst.loglevel=3Ddebug lang=3Den_US.UTF-8 keymap=
=3Dus inst.ks=3Dcdrom:/dev/cdrom:/ks/${ksname}.ks=C2=A0=C2=A0</div><div><br=
></div><div>NOTE:=C2=A0 inst.stage2 uses a label designation.=C2=A0 this LA=
BEL value MUST be exact.=C2=A0 When you generate your iso, usb drive, whate=
ver, it MUST have the label exactly matching the DRIVELABEL value or it won=
&#39;t install.=C2=A0 Also, you can use inst.upgrade to point to an upgrade=
d anaconda Product.img file which can contain rebrading/anaconda customizat=
ions.<br></div><div><br></div><div><br></div><div><br></div><div>Here&#39;s=
 a kickstart snippet that covers a lot of ground:</div><div><br></div><div>=
&quot;&quot;&quot;&quot;&quot;&quot;&quot;</div><div>

<pre style=3D"color:rgb(0,0,0);font-style:normal;font-variant-ligatures:nor=
mal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-ali=
gn:start;text-indent:0px;text-transform:none;word-spacing:0px;text-decorati=
on-style:initial;text-decoration-color:initial;word-wrap:break-word;white-s=
pace:pre-wrap">#PRE Section</pre><pre style=3D"color:rgb(0,0,0);font-style:=
normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:4=
00;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:no=
ne;word-spacing:0px;text-decoration-style:initial;text-decoration-color:ini=
tial;word-wrap:break-word;white-space:pre-wrap">  ksDeviceSource=3D$(sed &#=
39;s/ /\n/g&#39; /proc/cmdline | grep &#39;^inst.ks=3D&#39;|cut -f1 -d:|cut=
 -f2 -d&#39;=3D&#39;)
  if (grep -q &quot;ks=3Dhd:LABEL&quot; /proc/cmdline)
  then
    ksDeviceName=3D$(sed &#39;s/ /\n/g&#39; /proc/cmdline | grep &#39;^inst=
.ks=3D&#39;|cut -f2 -d&quot;:&quot; | cut -f2 -d&quot;=3D&quot;)
    ksDeviceBaseName=3D`blkid -L $ksDeviceName`
    ksDeviceBaseName=3D`basename $ksDeviceBaseName`
  else
    #using a normal dev name, not a LABEL=20
    ksDeviceName=3D$(sed &#39;s/ /\n/g&#39; /proc/cmdline | grep &#39;^inst=
.ks=3D&#39;|cut -f2 -d&quot;:&quot;)
    ksDeviceBaseName=3D`basename $ksDeviceName`
  fi

  if [[ -z &quot;${repo}&quot; ]]; then
    #Are we using a usb drive?
    if [[ &quot;${ksDeviceName}&quot; =3D=3D &quot;hd&quot; ]]; then
       repo=3D&quot;hd&quot;
    else
      # If no repo was specified, then we must be installing from disc
      repo=3D&quot;cdrom&quot;
    fi
  fi

  # Variable for the repo line:
  srcLoc=3D&quot;/tmp&quot;
  # Mount the source repo
  mkdir -p /tmp/source
  repotype=3D$(echo &quot;${repo}&quot; | cut -d: -f1)
  if [[ &quot;${repotype}&quot; =3D=3D &quot;nfs&quot; ]]; then
    source=3D$(echo &quot;${repo}&quot; | cut -d: -f2-)
    mount -t nfs -o nolock &quot;${source}&quot; /tmp/source
  elif [[ &quot;${repotype}&quot; =3D=3D &quot;cdrom&quot; ]]; then
    echo &quot;cdrom&quot; &gt;&gt; /tmp/pre.ks
    # Re-bind the existing mount otherwise we&#39;ll get errors with some d=
evices
    ### WARNING:  RHEL 7 anaconda now mounts to /run/install/repo.  /mnt/st=
age2 is gone.
    ###  it&#39;s possible that we no longer need to do this mount, but hey=
, then we&#39;d have to change A LOT!
    mount --bind /run/install/repo /tmp/source
  elif [[ &quot;${repotype}&quot; =3D=3D &quot;hd&quot; ]]; then
   echo &quot;harddrive --partition=3D$ksDeviceBaseName --dir=3D/&quot; &gt=
;&gt; /tmp/pre.ks
    # Re-bind the existing mount otherwise we&#39;ll get errors with some d=
evices
    # I am not sure if we need to do the next mount with USB/HD.
    # NOTE:  the next line will not work if we expand to multiple iso(s).
    tmpDIR=3D$(mktemp -d)
    mount -L $ksDeviceName $tmpDIR
    mount -o loop $tmpDIR/imagename*.iso /tmp/source
    srcLoc=3D&quot;/tmp&quot;
    #mount --bind /tmp/source /mnt/source
  fi


  #set the repos here.
cat &lt;&lt; EOF &gt; /tmp/repos.ks
repo --name=3D&quot;ELRepo&quot; --baseurl=3Dfile://$srcLoc/source/ELRepo -=
-cost=3D410000
repo --name=3D&quot;EPEL&quot; --baseurl=3Dfile://$srcLoc/source/EPEL --cos=
t=3D400000
repo --name=3D&quot;Extras&quot; --baseurl=3Dfile://$srcLoc/source/Extras  =
--cost=3D500000</pre><pre style=3D"color:rgb(0,0,0);font-style:normal;font-=
variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-sp=
acing:normal;text-align:start;text-indent:0px;text-transform:none;word-spac=
ing:0px;text-decoration-style:initial;text-decoration-color:initial;word-wr=
ap:break-word;white-space:pre-wrap"><pre style=3D"font-style:normal;font-va=
riant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spac=
ing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacin=
g:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-=
decoration-color:initial;color:rgb(0,0,0);word-wrap:break-word;white-space:=
pre-wrap">repo --name=3D&quot;Custom&quot; --baseurl=3Dfile://$srcLoc/sourc=
e/Custom --cost=3D500000</pre>

<br></pre><pre style=3D"color:rgb(0,0,0);font-style:normal;font-variant-lig=
atures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:norma=
l;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;tex=
t-decoration-style:initial;text-decoration-color:initial;word-wrap:break-wo=
rd;white-space:pre-wrap">repo --name=3D&quot;Optional&quot; --baseurl=3Dfil=
e://$srcLoc/source/Optional --cost=3D350000
repo --name=3D&quot;Supplementary&quot; --baseurl=3Dfile://$srcLoc/source/S=
upplementary --cost=3D360000
repo --name=3D&quot;Workstation&quot; --baseurl=3Dfile://$srcLoc/source/Wor=
kstation --cost=3D330000
repo --name=3D&quot;Packages&quot; --baseurl=3Dfile://$srcLoc/source/Packag=
es --cost=3D300000
EOF

########## End Pre Section ############</pre><pre style=3D"color:rgb(0,0,0)=
;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;f=
ont-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-=
transform:none;word-spacing:0px;text-decoration-style:initial;text-decorati=
on-color:initial;word-wrap:break-word;white-space:pre-wrap">####Post sectio=
n######

# This is the First Post script,
  # copy things that are needed in chrooted Posts to where they can be foun=
d.
  source /tmp/cmdline  #you won&#39;t use these three lines probably
  cp -p /tmp/cmdline /mnt/sysimage/tmp/cmdline
  cp -p /tmp/cmdline /mnt/sysimage/root/cmdline


  # Re-mount the source for the post-scripting
  {{ m.export_cmdline() }}  #This is a JINJA operator, you would need to ad=
d in the mount command here if not using JINJA

  ksDeviceSource=3D$(sed &#39;s/ /\n/g&#39; /proc/cmdline | grep &#39;^ks=
=3D&#39;|cut -f1 -d:|cut -f2 -d&#39;=3D&#39;)

  if (grep -q &quot;ks=3Dhd:LABEL&quot; /proc/cmdline)
  then
    ksDeviceName=3D$(sed &#39;s/ /\n/g&#39; /proc/cmdline | grep &#39;^ks=
=3D&#39;|cut -f2 -d&quot;:&quot; | cut -f2 -d&quot;=3D&quot;)
    ksDeviceBaseName=3D`blkid -L $ksDeviceName`
    ksDeviceBaseName=3D`basename $ksDeviceBaseName`
  else
    #using a normal dev name, not a LABEL
    ksDeviceName=3D$(sed &#39;s/ /\n/g&#39; /proc/cmdline | grep &#39;^ks=
=3D&#39;|cut -f2 -d&quot;:&quot;)
    ksDeviceBaseName=3D`basename $ksDeviceName`
  fi

  if [[ -z &quot;${repo}&quot; ]]; then
    #Are we using a usb drive?
    if [[ &quot;${ksDeviceName}&quot; =3D=3D &quot;hd&quot; ]]; then
       repo=3D&quot;hd&quot;
    else
      # If no repo was specified, then we must be installing from disc
      repo=3D&quot;cdrom&quot;
    fi
  fi


  # Mount the source repo
  mkdir -p /tmp/source
  repotype=3D$(echo &quot;${repo}&quot; | cut -d: -f1)
  if [[ &quot;${repotype}&quot; =3D=3D &quot;nfs&quot; ]]; then
    source=3D$(echo &quot;${repo}&quot; | cut -d: -f2-)
    mount -t nfs -o nolock &quot;${source}&quot; /tmp/source
  elif [[ &quot;${repotype}&quot; =3D=3D &quot;cdrom&quot; ]]; then
    echo &quot;&quot;
    #TODO: this is a legacy item that needs removed.... later
    #mount $(cat /tmp/source) /tmp/source
  elif [[ &quot;${repotype}&quot; =3D=3D &quot;hd&quot; ]]; then
    tmpDIR=3D$(mktemp -d)
    mount -L $ksDeviceName $tmpDIR
    #at this point, /tmp/isodir is the device that is mounted.  useit!
    mount -o loop $tmpDIR/imagename*.iso /tmp/source
  fi



  # Make the source repo available in the chroot
  mkdir -p /mnt/sysimage/tmp/source
  mount --bind /tmp/source /mnt/sysimage/tmp/source</pre>

&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&qu=
ot;##### End Post Section ##########</div><div><br></div><div><br></div><di=
v>here&#39;s the genisoimage command:</div><div><div>genisoimage -r -v \</d=
iv><div>=C2=A0 =C2=A0 =C2=A0-V &quot;LABELNAME.x86_64&quot; -A &quot;${labe=
l}&quot; -cache-inodes -J -l \</div><div>=C2=A0 =C2=A0 =C2=A0-b isolinux/is=
olinux.bin -c isolinux/<a href=3D"http://boot.cat">boot.cat</a> \</div><div=
>=C2=A0 =C2=A0 =C2=A0-no-emul-boot -boot-load-size 4 -boot-info-table \</di=
v><div>=C2=A0 =C2=A0 =C2=A0-o &quot;${isoLocation}${filename}&quot; disc</d=
iv><div><br></div><div><br></div><div>=C2=A0 pushd ${isoLocation} &gt;&gt; =
/dev/null</div><div>=C2=A0 # if you want to use a usb drive, then next part=
 is mandatory:</div><div>=C2=A0 #make sure the iso is bootable on USB devic=
es</div><div>=C2=A0 isohybrid ${filename}</div><div>=C2=A0 implantisomd5 ${=
filename}</div></div><div><br></div><div><br></div><div>Apparently, you can=
 use xorriso, which contains an argument for running isohybrid.</div><div><=
br></div><div>hope that helps.=C2=A0 All of this stuff for building your ow=
n respun disc is available online.=C2=A0=C2=A0</div><div>Such as:</div><div=
><a href=3D"https://devopsmates.com/make-custom-centos-7-rhel-7-cd-kicktart=
-file/">https://devopsmates.com/make-custom-centos-7-rhel-7-cd-kicktart-fil=
e/</a><br></div><div><a href=3D"http://www.smorgasbork.com/2014/07/16/build=
ing-a-custom-centos-7-kickstart-disc-part-1/">http://www.smorgasbork.com/20=
14/07/16/building-a-custom-centos-7-kickstart-disc-part-1/</a><br></div><di=
v><br></div><div>use livecd tools or dd to make a custom bootable disc/usb =
drive.</div><div><br></div></div><div class=3D"gmail_extra"><br clear=3D"al=
l"><div><div class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><=
div dir=3D"ltr">Andrew Simpson</div></div></div>
<br><div class=3D"gmail_quote">On Thu, Feb 22, 2018 at 11:07 PM, Vin=C3=ADc=
ius Ferr=C3=A3o <span dir=3D"ltr">&lt;<a href=3D"mailto:ferrao@versatushpc.=
com.br" target=3D"_blank">[email protected]</a>&gt;</span> wrote:<b=
r><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex">Firas, thank you.<br>
<br>
That=E2=80=99s appears to be exactly what I need.<br>
<br>
I=E2=80=99ll be doing some test tomorrow and report back.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
V.<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
&gt; On 22 Feb 2018, at 22:40, Firas Alshafei &lt;<a href=3D"mailto:Firas.A=
[email protected]">[email protected]</a>&gt; wrote:<br>
&gt;<br>
&gt; V,<br>
&gt;<br>
&gt; If you&#39;re adding rpms then you&#39;ll need to update the repo to a=
ctually include them. I&#39;m not familiar with Lorax so I can&#39;t really=
 help there, but if your end goal is=C2=A0 a standard RHEL dvd with extra p=
ackages that you want to define in your kickstart configuration then it sho=
uld just require createrepo and genisoimage.<br>
&gt;<br>
&gt; My use case is fairly vanilla kickstart you might have to modify to su=
it your workflow.<br>
&gt; - isolinux and efi use the inst.ks and inst.stage2 to point to kicksta=
rt file and installation source respectively.<br>
&gt; - kickstart file and pre/post/conf scripts in DVD/kickstart directory =
structure<br>
&gt; - Packages in the default DVD/Packages and additional packages in /DVD=
/Packages-Extra<br>
&gt; - I delete all uneeded packages to reduce DVD size, just feed the rpm =
-qa output on an installed system to yumdownloader<br>
&gt;<br>
&gt; Here&#39;s a script stub - I do something similar in-house to get our =
DVDs created for air-gapped environments (it&#39;s a pain).<br>
&gt; Hope this helps =F0=9F=98=8A<br>
&gt;<br>
&gt; #!/bin/bash<br>
&gt; #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>
&gt; # Title=C2=A0 =C2=A0 =C2=A0 =C2=A0 : create-iso<br>
&gt; #<br>
&gt; # Description=C2=A0 : Generate kickstart dvd<br>
&gt; #<br>
&gt; # Author=C2=A0 =C2=A0 =C2=A0 =C2=A0: Firas AlShafei<br>
&gt; #<br>
&gt; # Last Revised : 11/04/2015<br>
&gt; #<br>
&gt; #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>
&gt;<br>
&gt; # Assume following path structure<br>
&gt; #<br>
&gt; # working-directory<br>
&gt; # |<br>
&gt; # ---&gt; creat-iso.sh<br>
&gt; # |<br>
&gt; # ---&gt; media (DVD media + kickstart + additional packages)<br>
&gt;<br>
&gt; # Path variables<br>
&gt; scriptPath=3D$(dirname &quot;$(readlink -f &quot;$0&quot;)&quot;)<br>
&gt; isoPath=3D${scriptPath}<br>
&gt; releaseName=3D&quot;my-awesome-dvd.<wbr>iso&quot;<br>
&gt;<br>
&gt; # Move repo group info<br>
&gt; mv ${scriptPath}/media/repodata/*<wbr>-comps-Server.x86_64.xml ${scrip=
tPath}/media/repodata/<wbr>comps-Server.x86_64.xml<br>
&gt;<br>
&gt; # Create repo<br>
&gt; cd ${scriptPath}/media<br>
&gt; createrepo --quiet --pretty --update --groupfile repodata/comps-Server=
.x86_64.<wbr>xml .<br>
&gt;<br>
&gt; # Make ISO file<br>
&gt; echo &quot;=3D=3D Generate DVD Image&quot;<br>
&gt; echo &quot;=3D ${isoPath}/${releaseName}.iso&quot;<br>
&gt; genisoimage -r -T -J -V ${releaseName} \<br>
&gt; -quiet=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \<br>
&gt; -o ${isoPath}/${releaseName}.iso=C2=A0 =C2=A0 =C2=A0 \<br>
&gt; -no-emul-boot=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\<br>
&gt; -boot-load-size 4=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0\<br>
&gt; -boot-info-table=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 \<br>
&gt; -b isolinux/isolinux.bin=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 \<br>
&gt; -c isolinux/<a href=3D"http://boot.cat" rel=3D"noreferrer" target=3D"_=
blank">boot.cat</a>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 \<br>
&gt; -eltorito-alt-boot=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 \<br>
&gt; -no-emul-boot=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\<br>
&gt; -b images/efiboot.img=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0\<br>
&gt; ${scriptPath}/media/<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Firas AlShafei<br>
&gt; Senior Lead Engineer<br>
&gt; Enterprise Software<br>
&gt; ABB<br>
&gt;<br>
&gt; -----Original Message-----<br>
&gt; From: <a href=3D"mailto:[email protected]">kickstart-l=
ist-bounces@redhat.<wbr>com</a> [mailto:<a href=3D"mailto:kickstart-list-bo=
[email protected]">kickstart-list-<wbr>[email protected]</a>] On Behalf Of =
Vin=C3=ADcius Ferr=C3=A3o<br>
&gt; Sent: Thursday, February 22, 2018 3:47 PM<br>
&gt; To: <a href=3D"mailto:[email protected]">kickstart-list@redhat=
.com</a><br>
&gt; Subject: Custom ISO with Kickstart and Local Repos<br>
&gt;<br>
&gt; CAUTION: This email originated from outside of the organization. Do no=
t click links or open attachments unless you recognize the sender and know =
the content is safe.<br>
&gt;<br>
&gt;<br>
&gt; Hello,<br>
&gt;<br>
&gt; I=E2=80=99m trying to create a custom ISO with a Kickstart file to ach=
ieve a complete offline installation.<br>
&gt;<br>
&gt; I was able to create the Kickstart file as usual, since I use it for P=
XE installs for at least 10 years, but the major problem now is building th=
e ISO with the necessary files.<br>
&gt;<br>
&gt; I=E2=80=99ve came across a tool named Lorax, but I was not able to cre=
ate a custom ISO from DVD=E2=80=99s. It only works when point to mirrors, a=
nd this is a time consuming task. Another problem is that Lorax does not se=
ems to care about the /usr/share/lorax/product folder to create a custom An=
aconda with the embedded kickstart file on /usr/share/anaconda/<wbr>interac=
tive-defaults.ks.<br>
&gt;<br>
&gt; The small ISO generated by Lorax lacks local repositories and I was un=
able to find the appropriate documentation on how to build this scenario. S=
o it generates a boot only install that must be done over the Internet.<br>
&gt;<br>
&gt; At this moment I=E2=80=99m running Lorax on a CentOS install, I=E2=80=
=99ve got RHEL licenses too, but to keep it simple I just went with CentOS.=
 I think this is irrelevant information but it=E2=80=99s just for the sake =
of completion.<br>
&gt;<br>
&gt; With genisoimage I was able to add the custom product.img file, that I=
=E2=80=99ve generated by hand with cpio, on the ISO but I was not able to s=
olve the local repos problem. There are packages that I would like to add t=
o the install media, like Ansible, but they are available only on the Extra=
s repository and I=E2=80=99m unsure on how to do this. Just wondering if cr=
eaterepo and yumdownloader are necessary...<br>
&gt;<br>
&gt; Any help is greatly appreciated.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; V.<br>
&gt;<br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; Kickstart-list mailing list<br>
&gt; <a href=3D"mailto:[email protected]">[email protected]=
</a><br>
&gt; <a href=3D"https://emea01.safelinks.protection.outlook.com/?url=3Dhttp=
s%3A%2F%2Fwww.redhat.com%2Fmailman%2Flistinfo%2Fkickstart-list&amp;data=3D0=
2%7C01%7Cfiras.alshafei%40us.abb.com%7C61f459f9ce2a4501b84d08d57a3dede1%7C3=
72ee9e09ce04033a64ac07073a91ecd%7C0%7C0%7C636549328763319165&amp;sdata=3Dry=
v0YW%2FzOdUplRFSLABdNkRZN%2BZKBJwKVw5CaSDJfRk%3D&amp;reserved=3D0" rel=3D"n=
oreferrer" target=3D"_blank">https://emea01.safelinks.<wbr>protection.outlo=
ok.com/?url=3D<wbr>https%3A%2F%2Fwww.redhat.com%<wbr>2Fmailman%2Flistinfo%<=
wbr>2Fkickstart-list&amp;data=3D02%7C01%<wbr>7Cfiras.alshafei%40us.abb.com%=
<wbr>7C61f459f9ce2a4501b84d08d57a3d<wbr>ede1%<wbr>7C372ee9e09ce04033a64ac07=
073a9<wbr>1ecd%7C0%7C0%<wbr>7C636549328763319165&amp;sdata=3D<wbr>ryv0YW%2F=
zOdUplRFSLABdNkRZN%<wbr>2BZKBJwKVw5CaSDJfRk%3D&amp;<wbr>reserved=3D0</a><br=
>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; Kickstart-list mailing list<br>
&gt; <a href=3D"mailto:[email protected]">[email protected]=
</a><br>
&gt; <a href=3D"https://www.redhat.com/mailman/listinfo/kickstart-list" rel=
=3D"noreferrer" target=3D"_blank">https://www.redhat.com/<wbr>mailman/listi=
nfo/kickstart-<wbr>list</a><br>
<br>
<br>
______________________________<wbr>_________________<br>
Kickstart-list mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]</a><=
br>
<a href=3D"https://www.redhat.com/mailman/listinfo/kickstart-list" rel=3D"n=
oreferrer" target=3D"_blank">https://www.redhat.com/<wbr>mailman/listinfo/k=
ickstart-<wbr>list</a></div></div></blockquote></div><br></div>

--94eb2c035484c1f4b40565e1c587--


--===============4812224750649090430==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Kickstart-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/kickstart-list
--===============4812224750649090430==--