Using %pre scripts for partitioning - RHEL-ES-4

Oliver Hookins ohookins at gmail.com
Thu Apr 7 00:33:41 UTC 2005


On Apr 6, 2005 2:56 AM, Rick Stevens <rstevens at vitalstream.com> wrote:
> Oliver Hookins wrote:
> > In order to accommodate various partitioning layouts in the most
> > automated fashion possible, I want to use a %pre script to set the
> > layout of the the partitioning based on a kernel parameter that I am
> > setting.
> >
> > For example, in my main kickstart script:
> >
> > %pre
> > #!/bin/sh
> > # Check to see which type of partitioning was specified
> > PART=`cat /proc/cmdline | tr ' ' '\n' | grep '^part=' | cut -d= -f2`
> >
> > if [ "$PART" = "ide-hda-hdb-srv" ]; then
> >   %include /mnt/source/kickstart/ide-hda-hdb-srv.ks
> > elif [ "$PART" = "ide-hda-hdc-srv" ]; then
> >   %include /mnt/source/kickstart/ide-hda-hdc-srv.ks
> > elif [ "$PART" = "ide-hda-srv" ]; then
> >   %include /mnt/source/kickstart/ide-hda-srv.ks
> > elif [ "$PART" = "ide-freedom" ]; then
> >   %include /mnt/source/kickstart/ide-freedom.ks
> > elif [ "$PART" = "ide-ws" ]; then
> >   %include /mnt/source/kickstart/ide-ws.ks
> > elif [ "$PART" = "scsi-raid1" ]; then
> >   %include /mnt/source/kickstart/scsi-raid1.ks
> > elif [ "$PART" = "scsi-raid5" ]; then
> >   %include /mnt/source/kickstart/scsi-raid5.ks
> > else
> >   echo "No partitioning option specified - will prompt for partitioning."
> > fi
> >
> > I'm not sure that this is correct (and it certainly is not working).
> > The administrator guide hasn't made it abundantly clear as to how to
> > do this sort of thing. Each of these files to be included has a bunch
> > of part commands, for example:
> >
> > ide-freedom.ks:
> > # Single disk partitioning.
> > part /boot --fstype ext3 --badblocks --size 500        --asprimary
> > part swap                --badblocks --size 2048       --asprimary
> > part /     --fstype ext3 --badblocks --size 1   --grow --asprimary
> >
> > Can someone steer me in the right direction?
> 
> You've invoked /bin/sh to do this bit of the script and sh doesn't
> understand the "%include" directive (that's a python construct, not
> a shell construct).
> 
> What I'd recommend is that you change:
> 
>         %include /mnt/source/kickstart/name-of-file.ks
> 
> To:
> 
>         cp /mnt/source/name-of-file.ks /tmp/partitions.ks
> 
> Then immediately following your "%pre" section, do an
> 
>         %include /tmp/partitions.ks
> 
> to read in the appropriate partitioning scheme.

Thanks Rick, I think I've got my head around this concept. So it
parses the kickstart file a couple of times... copies the appropriate
files to /tmp in the %pre section and then on the actual installation
%includes the file that was previously copied.

I've tried it and it works well, thanks for your help. Now I just have
to sort out a number of other funny things happening in my %post
script.

Thanks,
Oliver




More information about the Redhat-install-list mailing list