selectively delete partitions

Matt Sturtz rh-kickstart at matthouse.com
Tue Jan 31 18:08:06 UTC 2006


Hi Steve, et al--

> Is there a way to tell anaconda to remove all partitions except for the
> first partition? Or does anyone have a %pre script that can kill all the
> partitions except for a partition of a certain type?

I have a Kickstart that is used for brand new Dell systems -- based on
your issue, I suspect you're doing something similar.  The issue I have is
that Dell servers come with a Dell Utility partition (shows in fdisk as
partition type DE, but it's really just a FAT16) that is set as bootable
from the factory.  Part of the "un-seal" process when the machine is first
booted is to change the bootable flag to the _next_ partition, which would
fail on servers ordered without an OS if there wasn't a second tiny FAT16
partition  immediatly following.  When this second partition is booted, it
shows the "NO OS INSTALLED -- please use the Dell CD's to install Linux
the way Dell wants it installed" (who does that?!?!?).  You can find more
information on this process (as well as the new "Dell PC Restore" stuff)
at this site:  <http://www.goodells.net/dellutility> ...  I wanted to keep
only the DE partition, and delete the FAT16 partition.

if [ "`fdisk -l /dev/sda |grep FAT16`" ]
then
     partid=`fdisk -l /dev/sda |grep FAT16 |cut -f1 -d' ' |cut -f2 -da`
     echo -n "d
$partid
w" |fdisk /dev/sda
fi

This assumes you have a SCSI hard disk, use /dev/hda instead if IDE... 
This checks to see if there is a FAT16 partition, and if so it gets the
partition ID (1-4) and pipes commands through the fdisk program to delete
it.  This leaves the Dell Utility partition intact.

There may be other ways to do the same thing, but this is what I use...

Note that, for this to work, you must be careful using the "clearpart"
command in your KS.CFG.  The "--initlabel" switch creates a brand new
partition table (for brand new hard disks), and the "--all" switch will
clear all partitions (both do the same thing -- remove the partition you
don't want removed)..  On my system, I use the "--linux" switch, which
will delete only the Linux partitions, leaving my Dell Utility partition
alone.

Hope this helps,

-Matt-




More information about the Kickstart-list mailing list