How to remove a partition on a hard disk?

When I was basically new to Linux (and I still quite am), I got a nice computer from my university, featuring a SSD (250 Gb) and a 2Tb hard disk.

I decided to use only Ubuntu, but I made the installation being distracted and I did it on the 2Tb hard disk, while I wanted it on the SSD. So now I have two partitions, one on the SSD and the other one on this 2Tb hard disk.

I need to free the 2Tb hard disk; I tried with GParted, but I don't get how to use it, plus it seems like this partition is locked.

How do I get rid of this useless partition? Do I just need to delete the linux-swap in order to be able to use the hard disk?

here what I see in Gparted

here what I see in Gparted


You can try to use fdisk from the command line. In your case, if you want to delete partition on /dev/sdb just type:

fdisk /dev/sdb

Then once fdisk is opened you can type "d" to delete and then select the partition(s) you want to delete. After you removed the partition(s) don't forget to write the changes.

One advice, do not do that if you didn't reinstalled your OS on /dev/sda (your SSD) or you won't be able to boot the computer then.


You must unmount a partition before you can delete it.

Currently /dev/sdb1 is mounted at /media/elisa/d91c....

If you right-click on the partition's entry in GParted, there should be an option "Unmount" in the context menu. Click it.

After that, you can modify or delete the partition as you wish.


First Let's remove some confusions

Every hard drive needs one or more partitions to be useful. Partitions are created when you create a filesystem on it. Most used partitions scheme is MBR. In MBR, you can have only 4 partitions in a disk. These are called Primary partition. If you need more than 4 partitions, You can make one of the 4 as Extended partition. This extended partition works as a container and it turn can hold more than 1 partitions. These partitions are called Logical partitions

In your GParted image, the first partition (bigger one) is a primary partition. And the Swap partition is a logical partition inside an Extended partition


Answer

If I understood your question correctly, You later installed Ubuntu on SSD, but you still have that 2TB disk with two partitions. 1 with 30 GB of Data and another is a swap (inside an Extended partition).

If you're trying to free the space of linux-swap thinking It's useless, Then I'd say not to delete that partition. Because Linux Swap is helpful for hibernating and 31 GB won't hurt much considering your disk size.

If you really want to remove the swap

If you really want to remove this swap, click on the swap partition, right click, select Swapoff. Then again select it, right click and use Delete to remove the partition.

You can then see that there is still a partition (extended partition) with empty space. Select that space, right click and select Delete again. This will clear the Extended partition

Now, select the partition with Data (bigger one), right click -> Resize/Move and in the new Resize Window, move the right slider to far right to fill the partition. Finally click Resize/Move button.

This will give you 2TB disk with only the single partition with Data.