clearpart

The clearpart Kickstart command is optional. It removes partitions from the system, before creating new partitions. By default, no partitions are removed. Use this command only once.

Syntax

              clearpart OPTIONS
            
Options
  • --all - Erases all partitions from the system.

    This option will erase all disks which can be reached by the installation program, including any attached network storage. Use this option with caution.

    You can prevent clearpart from wiping storage you want to preserve by using the --drives= option and specifying only the drives to clear. You can also attach network storage later, for example in the %post section of the Kickstart file. Another option is to blocklist the kernel modules used to access network storage.

  • --drives= - Specifies which drives to clear partitions from. For example, the following clears all the partitions on the first two drives on the primary IDE controller:
    clearpart --drives=hda,hdb --all

    To clear a multipath device, use the format disk/by-id/scsi-WWID, where WWID is the world-wide identifier for the device. For example, to clear a disk with WWID 58095BEC5510947BE8C0360F604351918, use:

    clearpart --drives=disk/by-id/scsi-58095BEC5510947BE8C0360F604351918

    This format is preferable for all multipath devices. If errors occur, multipath devices that do not use LVM can also use the format disk/by-id/dm-uuid-mpath-WWID, where WWID is the world-wide identifier for the device. For example, to clear a disk with WWID 2416CD96995134CA5D787F00A5AA11017, use:

    clearpart --drives=disk/by-id/dm-uuid-mpath-2416CD96995134CA5D787F00A5AA11017

    Never specify multipath devices by device names like mpatha. Device names such as this are not specific to a particular disk. The disk named /dev/mpatha during installation might not be the one that you expect it to be. Therefore, the clearpart command could target the wrong disk.

  • --initlabel - Initializes a disk (or disks) by creating a default disk label for all disks in their respective architecture that have been designated for formatting (for example, gpt for x86). Because --initlabel can see all disks, it is important to ensure only those drives that are to be formatted are connected. Disks cleared by clearpart will have the label created even in case the --initlabel is not used.
    clearpart --initlabel --drives=names_of_disks

    For example:

    clearpart --initlabel --drives=dasda,dasdb,dasdc
  • --list= - Specifies which partitions to clear. This option overrides the --all and --linux options if used. Can be used across different drives. For example:
    clearpart --list=sda2,sda3,sdb1
  • --disklabel=LABEL - Set the default disklabel to use. Only disklabels supported for the platform will be accepted. For example, on the 64-bit Intel and AMD architectures, the msdos and gpt disklabels are accepted, but dasd is not accepted.
  • --linux - Erases all Linux partitions.
  • --none (default) - Do not remove any partitions.
  • --cdl - Reformat any LDL DASDs to CDL format.
Notes
  • On the x86_64 systems running in Legacy BIOS mode, the GPT disklabel is the default. To ensure these systems can boot properly with GPT, add a dedicated BIOS boot partition. For automated installations, consider using the reqpart kickstart command to create this BIOS boot partition when required automatically. Optionally, use the part kickstart command, for example: part biosboot --size=1. If you prefer to stick with the older MBR partitioning scheme instead of GPT, you have two options:
    • During a kickstart installation, use the --disklabel msdos option with the clearpart command.
    • Alternatively, add the inst.disklabel=mbr boot option at the installer’s boot prompt.
  • To specify a multipath device, use the format disk/by-id/scsi-WWID, where WWID is the world-wide identifier for the device. For example, to specify a disk with WWID 58095BEC5510947BE8C0360F604351918, use:
    ignoredisk --only-use=disk/by-id/scsi-58095BEC5510947BE8C0360F604351918

    This format is preferable for all multipath devices. If errors occur, multipath devices that do not use LVM can also use the disk/by-id/dm-uuid-mpath-WWID format, where WWID is the device world-wide identifier. For example, to specify a disk with WWID 2416CD96995134CA5D787F00A5AA11017, use:

    ignoredisk --only-use=disk/by-id/dm-uuid-mpath-2416CD96995134CA5D787F00A5AA11017

    Never specify multipath devices by device names like mpatha. Device names such as this are not specific to a particular disk. The disk named /dev/mpatha during installation might not be the one that you expect it to be. Therefore, the ignoredisk command could target the wrong disk.

  • The sdX (or /dev/sdX) format does not guarantee consistent device names across reboots, which can complicate the usage of some Kickstart commands. When a command requires a device node name, you can use any item from /dev/disk as an alternative. For example, instead of using the following device name:
    clearpart --drives=sda

    You can use an entry similar to one of the following:

    clearpart --drives=/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0
    clearpart --drives=/dev/disk/by-id/ata-ST3160815AS_6RA0C882

    By using this approach, the command always targets the same storage device. This is especially useful in large storage environments. To explore the available device names on the system, you can use the ls -lR /dev/disk command during the interactive installation. For more information about different ways to consistently refer to storage devices, see Persistent naming attributes.

  • If the clearpart command is used, then the part --onpart command cannot be used on a logical partition.