You might be worried about deleting the Linux partition from your system, and you might be doing it wrong because you don’t know the proper methods to do that. Don’t worry; in this article, we will teach you this in detail.
A Linux partition is a particular type of directory under the Linux file system. It can be created using two basic commands: ‘part and ‘makes. However, for various reasons, it may become necessary to delete or remove a partition occasionally. This article explains how to do that easily without harming your data. Please note that deleting a primary Linux partition will render all data contained on that partition inaccessible. Proceed at your own risk.
How to Delete a Linux Partition?
There are two different procedures for deleting a Linux partition: use the ‘rm’ command or use GParted. We recommend using GParted because it’s easier to do and safer for your data since it does not write actual delete commands but only changes the partition table information. This means there is no chance of harming any data on the hard drive.
Delete A Linux Partition Using The ‘rm’ Command
- First, boot into a live Linux distribution (Knoppix) and start Konsole, GParted, or any other console-based partitioning tool. As an example, we will use ‘GParted.’
- Once loaded, right-click on the partition you wish to delete and select “Unmount.” Then go to the menu and click on ‘Partition’ -> ‘[Delete]’.
- GParted will now ask whether you want to perform this action – answer yes and wait until it finishes doing its job. Do not try deleting a primary Linux partition with just your file browser. This may cause harm!
Delete A Linux Partition Using GParted
- First, boot into a live Linux distribution (Knoppix) and start Konsole, GParted, or any other console-based partitioning tool.
- For example, we will use ‘GParted.’ Once loaded, right-click on the partition you wish to delete and select “Resize/Move.”
- Now simply drag the slider underneath the diagram to the left until your partition is gone.
- Then go to the menu and click on ‘Partition’ -> ‘[Delete]’.
- GParted will now ask whether you want to perform this action – answer yes and wait until it finishes doing its job.
- Do not try deleting a primary Linux partition with just your file browser. This may cause harm!
Some Other Ways Of Deleting Disk Partition
Boot your system with either Knoppix Live CD or SystemRescueCd.
This will load the kernel image on RAM, eliminating writing to the hard disk and its potential for data loss. I highly recommend this for inexperienced users.
Fdisk is a helpful tool built into Linux-based operating systems such as Ubuntu (the de-facto standard), Fedora Core, Suse Linux, etc. It lets you view and creates disk partitions and file systems on the hard drive(s).
To list all current partitions along with their size and location, run sudo fdisk -l.
If the partition you want to delete has ‘Linux’ in its name (or type hex code LABEL= in fdisk), you can delete it using the del (delete) command: sudo fdisk /dev/sda.
GParted is a GUI-based program designed to perform disk partitioning tasks such as creating, deleting, resizing, and moving partitions without data loss. You can download and install GParted in Linux-based operating systems such as Ubuntu, Fedora Core, Suse Linux, etc. However, this tool does not always work with Ext2 or Ext3 file systems.
Booting From Ubuntu
You could boot from an installation CD/DVD/USB stick and delete the hard partitions there (MBR disks only). Another solution would be to use GParted LiveCD or equivalent, but these are specific tools designed to run from a live environment and not recommended to be used otherwise. The safest way is to boot from an Ubuntu Install disk or SystemRescueCD if you do not have one available.
The steps necessary are simple:
- Boot into your LiveCD/USB environment;
- Find the device name of your problematic partition using “sudo fdisk -l” in a terminal (use “sudo parted /dev/sda print” instead of in case your devices don’t use sda for their naming scheme);
- Delete it using “sudo parted /dev/sda rm NUMBER,” obviously replacing NUMBER with the number found before;
- Recreate it using, for example, “sudo mkfs.ext3 /dev/sda5”, depending on the type of file system used by the partition;
- Mount it to a temporary location, for example, “sudo mount /dev/sda5 /mnt/test”, this is necessary if you need to save any data in the partition. Then unmount it and reboot. You can now delete your old installation directory or just leave it there if something goes wrong and you need to recover anything from it (back up important data first!).
Execute The Following Commands If You Choose Ubuntu
sudo fdisk -l sudo parted /dev/sda rm 7 sudo parted /dev/sda mkpart primary fat32 1MiB 100% sudo mkfs.vfat -F 32 /dev/sda1 sudo mount /dev/sda1 /mnt/test sudo mkdir /mnt/recovery sudo mount –bind /dev /mnt/recovery/dev sudo cp -aRf /* ./ /mnt/recovery/* sync umount /*
sync cd ~ ls -a cat .disk.log
We have now successfully deleted the Linux partition, and to confirm that you can run the following command in the terminal:
sudo fdisk -l
If you have followed all the steps correctly, there should not be any partitions with the same name as the deleted partition.
You can now reboot your system and boot into Ubuntu normally from the Grub menu.
We hope you will find the information in this article regarding the deletion of the Linux partition helpful. We have explained every method to do the deletion process thoroughly, and you won’t indeed be left with any confusion. Good luck.