Table of Contents

Ubuntu - Disk - Delete a partition

Before deleting a partition, run the following command to list the partitions:

sudo fdisk -l

returns:

Disk /dev/sda: 1.84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: CT2000MX500SSD1 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 2300B8B9-F7DD-4E5C-B2EF-84A5EC8D5D66
 
Device          Start        End    Sectors  Size Type
/dev/sda1        2048    1050623    1048576  512M EFI System
/dev/sda2     1050624 2098202623 2097152000 1000G Linux LVM
/dev/sda3  3727806464 3728855039    1048576  512M EFI System
/dev/sda4  3728855040 3907028991  178173952   85G Linux filesystem
 
 
Disk /dev/sdb: 14.57 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: ST16000NM001G-2K
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
 
Disk /dev/sdc: 14.57 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: ST16000NM001G-2K
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

NOTE: The /dev/sda or /dev/sda represent physical disks.

Common disk names on Linux include:

Type of diskDisk namesCommonly used disk names
IDE/dev/hd[a-h]/dev/hda, /dev/hdb
SCSI/dev/sd[a-p]/dev/sda, /dev/sdb
ESDI/dev/ed[a-d]/dev/eda
XT/dev/xd[ab]/dev/xda

The number 1 in /dev/sda1 indicates the partition number.

Make a note of the number of the partition you intend to delete.


Select the Disk

Select the disk that contains the partition you intend to delete.

sudo fdisk /dev/sdb

returns:

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
The old ext4 signature will be removed by a write command.
 
Device does not contain a recognised partition table.
The size of this disk is 14.6 TiB (16000900661248 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
 
Created a new DOS disklabel with disk identifier 0xe8d6d674.
 
Command (m for help): 

Delete Partitions

ALERT: Before deleting a partition, back up your data. All data is automatically deleted when a partition is deleted.

To delete partition, run the d command in the fdisk command-line utility.

The partition is automatically selected if there are no other partitions on the disk. If the disk contains multiple partitions, select a partition by typing its number.

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Verify Partition Deletion

Print the partition table to verify that the partition has been deleted.

Command (m for help): p

Save Changes and Quit

Run the w command to write and save changes made to the disk.

Command (m for help): w