Skip to content

How to Delete a Partition with parted or fdisk in Linux

Updated 5 min read

Updated: 12 October 2026 · Applies to: parted 3.6 and util-linux 2.41 (fdisk, sfdisk, wipefs) on Debian 13 and Ubuntu 26.04, parted 3.6 and util-linux 2.40 on AlmaLinux 10.2 (same commands on Rocky Linux, RHEL and Ubuntu 24.04)

To delete a partition with parted, unmount it and run parted /dev/sdb rm 2, where /dev/sdb is the disk and 2 the partition number from parted /dev/sdb print. With fdisk, run fdisk /dev/sdb, type d, the partition number, then w to write the change. Both only remove the entry from the partition table: double-check the disk name first, because everything on that partition becomes unreachable.

lsblk                      # find the disk and partition
umount /dev/sdb2           # stop using it
parted /dev/sdb rm 2       # delete partition 2
parted /dev/sdb print      # check

1. Find the right partition

  1. List disks and partitions with lsblk (more options in how to list all disks, volumes and unmounted partitions).
  2. Show the partition table of the disk:
    $ parted /dev/sdb print
    Number  Start   End     Size   File system  Name   Flags
     1      1049kB  316MB   315MB               data1
     2      316MB   630MB   315MB               data2
     3      630MB   1073MB  442MB               data3
    (Lab output from a 1 GB test disk, header lines left out.)
  3. Optional but cheap: save the table, so you can undo a mistake:
    sfdisk -d /dev/sdb > /root/sdb-table.txt
    In our test, sfdisk /dev/sdb < /root/sdb-table.txt brought all deleted partitions back.

2. Stop using the partition

  1. Check whether it is mounted: findmnt /dev/sdb2. Unmount it with umount /dev/sdb2; for a swap partition use swapoff /dev/sdb2.
  2. Remove its line from /etc/fstab. A line for a partition that no longer exists can stop the server from booting normally.
  3. If the partition is an LVM physical volume (pvs lists it), move or remove the volume group first, see how to resize LVM volumes.
  4. Optional: remove the file system signature, so tools no longer detect it if a new partition is created in the same place:
    $ wipefs -a /dev/sdb2
    /dev/sdb2: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef

3. Delete the partition with parted

One command, for scripts and quick work:

parted /dev/sdb rm 2

Or interactively, where parted asks for the number (lab session, shortened):

$ parted /dev/sdb
(parted) print
...
(parted) rm
Partition number? 3
(parted) print
Number  Start   End    Size   File system  Name   Flags
 1      1049kB  316MB  315MB               data1
(parted) quit

parted writes the change at once: there is no separate save step. A wrong number gives Error: Partition doesn't exist.

If the partition is still mounted, parted warns and asks:

Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?

Answer No, unmount it, and run the command again. With parted -s (script mode) it stopped at this warning with exit code 1 and left the partition alone in our test.

4. Delete the partition with fdisk

$ fdisk /dev/sdb
Command (m for help): d
Partition number (1-3, default 3): 2

Partition 2 has been deleted.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Nothing changes on disk until you type w; q quits without saving. If the disk has only one partition, fdisk does not ask for the number: it prints Selected partition 1 and deletes it. The same works without the menu: sfdisk --delete /dev/sdb 2.

fdisk does not refuse a mounted partition. It warns This disk is currently in use - repartitioning is probably a bad idea., writes the new table anyway and then reports:

Failed to remove partition 1 from system: Device or resource busy
The kernel still uses the old partitions. The new table will be used at the next reboot.

The table on disk is already changed at that point. Unmount the partition and run partprobe /dev/sdb; in our test the kernel then dropped the partition without a reboot.

Partition numbers after a delete

  • GPT disks keep the other numbers: after deleting 2, partitions 1 and 3 stay 1 and 3.
  • MBR (msdos) disks renumber logical partitions. In our test, after rm 5 the old partitions 6 and 7 became 5 and 6, so /dev/sdb6 in /etc/fstab would point to the wrong partition. Mount by UUID (blkid shows it) to avoid this.
  • Deleting an extended partition deletes all logical partitions inside it. Both parted -s and fdisk did this without an extra question.

Delete all partitions on a disk

Write a new, empty partition table with parted -s /dev/sdb mklabel gpt (or msdos), or remove the table completely:

$ wipefs -a /dev/sdb
/dev/sdb: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sdb: 8 bytes were erased at offset 0x3ffffe00 (gpt): 45 46 49 20 50 41 52 54
/dev/sdb: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
/dev/sdb: calling ioctl to re-read partition table: Success

Afterwards parted /dev/sdb print reports unrecognised disk label, and the disk is ready for a new table: see how to create disk partitions with parted and fdisk.

Deleted the wrong partition?

Stop writing to the disk. Deleting a partition does not erase its data. In our test we deleted an ext4 partition, created a new one with exactly the same start and end, and it mounted with the file still readable. Restore the saved table with sfdisk /dev/sdb < /root/sdb-table.txt, or, without a saved table, let parted search for it with rescue, as shown in the Linux parted command guide. If you ran wipefs on the partition first, the file system is no longer detected that way.

Lab notes: all output comes from 1 GB test disk images on Debian 13; the commands that need a running kernel (mounted partition, partprobe, wipefs) ran on a real Linux 6.12 kernel. Device names in the output are shown as /dev/sdb.

Official documentation: parted manual, fdisk manual and wipefs manual.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket