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

Rick Stevens rstevens at vitalstream.com
Tue Apr 5 16:56:06 UTC 2005


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.

Sorry it took so long to get to your question.
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-        Brain:  The organ with which we think that we think.        -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list