Link to home
Start Free TrialLog in
Avatar of Anonymouslemming

asked on

How do I erase all partitions on a specific disk ?

Hi all,

How would I go about removing all partitions on a specific device, even without knowing what partitions are on there ? I need to not touch other devices.

Basically, I need a command using either fdisk or parted that will remove all partitions on a specific device as part of a %pre script in Red Hat's kickstart tool.

I was originally going to use clearpart --drives cciss/c0d0 in the kickstart script, but we have identified a bug where clearpart does not work for specific devices on machines where the device naming uses the cciss/cxdx (controller x, device x) notation. This applies to all of our HP DL380 and DL585 equipment.
Avatar of blkline

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adrian Sluijters
I ditto that :-) Good one.. :-)
Avatar of neushoorn

fdisk should do the trick.
for exaple if it is the hdc disk you do
fdisk /dev/hdc
now it will ask for a command
do "p" to make it give a list of all partitions
or "m" for a help
"d" to remove a partition
and don't forget "w" at the end to write the partition table

also check "man fdisk"
Avatar of Anonymouslemming


I have accepted blkline's solution as this one works from a script. The other solution offered with fdisk could not be used in a red hat kickstart script.