Uninstalling CentOS

Removing CentOS from 64-bit AMD, Intel, and ARM Systems

The method for removing CentOS from your computer varies, depending on whether CentOS is the only operating system installed on the computer.

Before proceeding be sure you have considered the following information:

  • In certain situations you need the install media for any non-CentOS operating system you are going to be using on the system after you complete this process.

  • If you have multiple operating systems installed, ensure that you can boot each one separately and have all administrator passwords, including any passwords that might have been set automatically by your computer manufacturer or the manufacturer of the operating system.

  • If you want to retain any data from the installation of CentOS that you are going to remove, it will need to be backed up to a different location. If you are deleting an installation that contains sensitive data, ensure that you destroy the data according to your security policy. Ensure that any backup medium is readable on the operating system where you will restore the data. For example, without extra third-party software, Microsoft Windows cannot read an external hard drive that you have formatted with CentOS to use the ext2, ext3, ext4 or XFS file system.

    As a precaution, back up all data from any operating systems, including CentOS, that are installed on the same computer. Unforeseen circumstances can result in loss of all your data.

  • If you are only uninstalling CentOS and not reinstalling the entire computer, you should familiarize yourself with your partition layout. In particular, the output of the mount command can be helpful. It can also be helpful to note which menuitem is used to boot your CentOS installation in grub.cfg.

In general, to uninstall CentOS from your system, you perform two steps:

  1. Remove the CentOS boot loader information from your master boot record (MBR).

  2. Remove any partitions that contain the CentOS operating system.

These instructions cannot cover every possible computer configuration, common configurations are listed here.

If your configuration is not listed or has a highly-customized partition scheme, use the following sections as a general guide. In these situations, you will also need to learn to configure your chosen boot loader. See Red Hat Enterprise Linux 7 System Administrator’s Guide for more information on the GRUB2 boot loader.

To keep neither CentOS nor the other operating system, follow the steps described for a computer with only CentOS installed.

Only CentOS is Installed

The following procedure shows how to remove CentOS on systems where it is the only operating system installed. You will use the installation media for the replacement operating system to remove CentOS. Examples of installation media include the Windows XP installation CD, Windows Vista installation DVD, or the installation CD, CDs, or DVD of another Linux distribution.

Note that some manufacturers of factory-built computers pre-installed with Microsoft Windows do not supply the Windows installation CD or DVD with the computer. In this case the manufacturer usually supplied their own "system restore disc" instead, or have included software with the computer that allowed you to create your own "system restore disc" when you first started the computer. In some cases, the system restore software is stored on a separate partition on the system’s hard drive. If you cannot identify the installation media for an operating system that was pre-installed on your computer, consult the documentation supplied with the machine, or contact the manufacturer.

When you have located the installation media for your chosen operating system:

  1. Back up any data that you want to keep.

  2. Shut down the computer.

  3. Boot your computer with the installation disc for the replacement operating system.

  4. Follow the prompts presented during the installation process. Windows, OS X, and most Linux installation discs allow you to manually partition your hard drive during the installation process, or will offer you the option to remove all partitions and start with a fresh partition scheme. At this point, remove any existing partitions that the installation software detects or allow the installation program to remove the partitions automatically. "System restore" media for computers pre-installed with Microsoft Windows might create a default partition layout automatically without input from you.

    If your computer has system restore software stored on a partition on a hard drive, take care when removing partitions while installing an operating system from other media. Under these circumstances, you could destroy the partition holding the system restore software.

CentOS installed with a Different Linux Distribution

The following procedure shows how to remove CentOS on systems also installed with another Linux distribution. You can use the other Linux distribution to remove the boot loader entry (or entries) and to remove any CentOS partitions.

Because of the differences between the many different Linux distributions, these instructions are a general guide only. Specific details vary according to the configuration of your particular system and the Linux distribution that dual-boots with CentOS.

These instructions assume that your system uses the GRUB2 boot loader. If you use a different boot loader (such as LILO), consult the documentation for that software to identify and remove CentOS entries from its list of boot targets and to ensure that your default operating system is correctly specified.

  1. Remove CentOS Entries from Your Boot Loader

    1. Boot the Linux Distribution you are keeping on your computer, not CentOS.

    2. At the command line, type su - and press Enter. When the system prompts you for the root password, type the password and press Enter.

    3. Use a text editor such as vim to open the /boot/grub2/grub.cfg configuration file. In this file, find the entry of the system you are removing. A typical CentOS entry in the grub.cfg file looks similar to the following example:

      Example 1. A CentOS Entry in grub.cfg
      menuentry 'CentOS (3.10.0-57.el7.x86_64) 7.6.1810 (Maipo)' --class red --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.10.0-53.el7.x86_64-advanced-9eecdce6-58ce-439b-bfa4-76a9ea6b0906' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 0c70bc74-7675-4989-9dc8-bbcf5418ddf1
        else
          search --no-floppy --fs-uuid --set=root 0c70bc74-7675-4989-9dc8-bbcf5418ddf1
        fi
        linux16 /vmlinuz-3.10.0-57.el7.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/swap crashkernel=auto vconsole.keymap=us rhgb quiet LANG=en_US.UTF-8
        initrd16 /initramfs-3.10.0-57.el7.x86_64.img
      }
    4. Delete the entire entry, starting with the menuentry keyword and ending with }.

      Depending on the configuration of your system, there might be multiple CentOS entries in grub.cfg, each corresponding to a different version of the Linux kernel. Delete each of the CentOS entries from the file.

    5. Save the updated grub.cfg file and close vim

  2. Remove CentOS partitions on multi-boot environments:

    Be careful not to remove partitions that are still in use by the other installations.

    1. Boot the Linux Distribution you are keeping on your computer, not CentOS.

    2. Remove any unwanted and unnecessary partitions, for example, using:, for example, with fdisk for standard partitions, or lvremove and vgremove to remove logical volumes and volume groups. Additional information on these utilities can be found in their respective man pages, or the Red Hat Enterprise Linux 7 System Administrator’s Guide.

CentOS installed with a Microsoft Windows Operating System

The following procedure shows how to remove CentOS on systems also installed with Windows 2000, Windows Server 2000, Windows XP, Windows Server 2003, Windows Vista or Windows Server 2008. You can use the Microsoft Windows installation and its installation media to remove the boot loader and to remove any CentOS partitions.

The removal of CentOS on systems also installed with MS-DOS or versions of Microsoft Windows prior to Windows XP (except Windows 2000) is not covered in this document. These operating systems do not have robust partition management and cannot remove Linux partitions.

Because of the differences between each version of Microsoft Windows, these instructions need to be reviewed completely before being followed. It can be helpful to consult the documentation for your Microsoft Windows operating system as only utilities from that operating system are used in this procedure.

This procedure relies on the Windows Recovery Console or the Windows Recovery Environment that loads from the Windows installation disk, therefore, you will not be able to complete the procedure without access to this disk. If you start this procedure and do not complete it, you could leave your computer in a condition where you cannot boot it. The "system restore disk" supplied with some factory-built computers that are sold with Windows pre-installed on them might not include the Windows Recovery Console or Windows Recovery Environment.

Users of Windows 2000, Windows Server 2000, Windows XP, and Windows Server 2003 following this procedure will be prompted for the Administrator password for their Windows system. Do not follow these instructions unless you know the Administrator password for your system or are certain that an Administrator password has never been created, even by the computer manufacturer.

  1. Remove the CentOS partitions

    1. Boot your computer into your Microsoft Windows environment.

    2. Click Start>Run, type diskmgmt.msc and press Enter. The Disk Management tool opens.

      The tool displays a graphical representation of your disk, with bars representing each partition. The first partition is usually labeled NTFS and corresponds to your C: drive. At least two CentOS partitions will be visible. Windows will not display a file system type for these partitions, but can allocate drive letters to some of them.

    3. Right-click on one of the CentOS partitions, then click Delete Partition and click Yes to confirm the deletion. Repeat this process for the other CentOS partitions on your system. As you delete partitions, Windows labels the space on the hard drive previously occupied by those partitions as unallocated.

      You can add this unallocated space to an existing Windows partition or to use this space in some other way. Directions for doing this can be found in the manuals for your non-CentOS operating system.

  2. Restore the Windows boot loader

    1. On Windows 2000, Windows Server 2000, Windows XP, and Windows Server 2003:

      1. Insert the Windows installation disk and restart your computer. As your computer starts, the following message will appear on the screen for a few seconds:

        Press any key to boot from CD

        Press any key while the message is still showing and the Windows installation software will load.

      2. When the Welcome to Setup screen appears, you can start the Windows Recovery Console. The procedure is slightly different on different versions of Windows:

        1. On Windows 2000 and Windows Server 2000, press the R key, then the C key.

        2. On Windows XP and Windows Server 2003, press the R key.

      3. The Windows Recovery Console scans your hard drives for Windows installations, and assigns a number to each one. It displays a list of Windows installations and prompts you to select one. Type the number corresponding to the Windows installation that you want to restore.

      4. The Windows Recovery Console prompts you for the Administrator password for your Windows installation. Type the Administrator password and press the Enter key. If there is no administrator password for this system, press only the Enter key.

      5. At the prompt, type the command fixmbr and press the Enter. The fixmbr tool now restores the Master Boot Record for the system.

      6. When the prompt reappears, type exit and press the Enter key.

      7. Your computer will restart and boot your Windows operating system.

    2. On Windows Vista and Windows Server 2008:

      1. Insert the Windows installation disk and restart your computer. As your computer starts, the following message will appear on the screen for a few seconds:

        Press any key to boot from CD or DVD

        Press any key while the message is still showing and the Windows installation software will load.

      2. In the Install Windows dialog, select a language, time and currency format, and keyboard type. Click Next

      3. Click Repair your computer.

      4. The Windows Recovery Environment (WRE) shows you the Windows installations that it can detect on your system. Select the installation that you want to restore, then click Next.

      5. Click Command prompt. A command window will open.

      6. Type bootrec /fixmbr and press Enter.

      7. When the prompt reappears, close the command window, then click Restart.

      8. Your computer will restart and boot your Windows operating system.