February 25, 2011

Uninstalling a Linux OS from your Hard Drive

We have been getting questions from users about how to delete a linux OS from their hard drive. Well, lets oblige them. Uninstalling an OS is not like uninstalling a program with the simple "click to uninstall". It's a little trickier than that, however not that difficult. I will show a comprehensive method of removing a Linux OS, which is the correct term than uninstalling. These procedures will work on dual boot or single OS systems.

First you can not delete any partition on a drive if it is mounted. You will have to unmount the drive first to proceed. To umount a drive that has the linuxOS on it:

  1. insert a liveCD, and boot to the desktop. I recommend using the live ubuntu CD

You are now using your system via the liveCD, no drive on your system is mounted. From the live desktop, you  have two options to delete the partition. You can either use a gui tool like gparted, which is located in systems>administration or fdisk from the command line. From the gparted window, there is a drop-down menu arrow that allows you to select any drive that is located on the system.

In you the drop-down menu, select your require drive. You will get a listing of all the partitions on your hard drive. Select the required partition, and in the action menu, select delete. Then select aply changes. That's all it is too it. This works if you have only one OS on the hard drive.

Another method, which I like, is to use the fdisk command. To access the fdisk command:

  1. open a terminal
  2. type fdisk /dev/<drive>

The fdisk program has a lot of advanced features that come in handy when you need to make special changes to your hard drive. When you type the fdisk command you must specify the drive you want  it to access.  The drive specified by the drive files located in the folder /dev/. If your drive is a sata drive, you will specify /dev/sdax, or if it is an ide drive, you specify it with /dev/hdax. The variable x represents ths partition number.

Once you are in fdisk, you are given the option to list all the commands used with fdisk which is accessed by pressing the m key. Press the p key, and you will get the information pertaining to your hard drive.

Reading the information from your hard drive, you will notice a partition table. If you have only linux installed, you will see two partitions, a swap partition and an ext partition. If you have two OSs, windows and linux, you will in addition see an ntfs partition. Each partition will have a number after the sdax syntax telling you what number partition it is.What you are going to do is delete the ext partition by pressing the d key and selecting the partition's number. The fdisk program will help in the operations, all you have to do is follow what is says.

Keep in mind, nothing is changed unless you press the w key that force fdisk to write the changes to the drive. This is very useful if you accidentally select the wrong changes.

Notice, while reading the partition table, their is a boot column. The row of the ext partition has a "*" under the boot column heading. This means that this partition is the partition your system will boot from. You want to move the "*" to the ntfs partition, so your system will boot from that partition. You first remove the "*" from the ext partition by pressing the a key and select the partition number that you want to remove the "*" from. Then you must add the boot flag "*" to the ntfs partition. Press the a key and select the ntfs partition. Confirm you have made the right changes by pressing the p key to view the partition table. Once confirmed, press the w key to apply the changes.

Remove the liveCD once you reboot the system. You should see your windows OS loading, or start a fresh OS installation. Happy operating.


Click Here!