1

New(ish) to Linux, not new to hardware.

Got a new NAS which is to be hosted via linux. Before that I'm faffing about with the hardware, and things I will never get to do otherwise. Live distros are so lovely. I've tried around 4 so far.

Anyway, I'm also playing around with the storage drives. There's a bunch of file systems and partition types to explore - swap partitions are a puzzling idea to me, but whatever.

I can play around with those easy enough. However I could not find a way to actually delete the partition TABLE, just change it. I tried both fdisk and gparted.

How do you delete the partition table?

5
  • Try dd. Here's a similar question superuser.com/questions/1152069/… Commented May 1, 2023 at 6:03
  • Beware, that link only zeroes block 0, the legacy MBR. You may need to also zero the GPT, starting at block 1. Commented May 1, 2023 at 7:00
  • 2
    wipefs Commented May 1, 2023 at 8:35
  • fdisk has the m command to get help. you should see d delete a partition ... that's how you can delete partitions ... or even g to create an empty GPT table, or o to create an empty DOS (mbr?) partition table - after any of those, w to write the new partition table and exit Commented May 1, 2023 at 9:05
  • wipefs would be the correct tool here. It even helpfully said what it did - erasing the protective MBR and GPT at the start and the secondary GPT header at the end. @meuh yea, that's a good point, but also you skipped the secondary GPT, which wipefs did not. Commented May 2, 2023 at 0:32

2 Answers 2

0

I'm not sure to understand what you want to do erasing a partition table.
As you said in your question, erasing a partition table is generally for using an other instead (change, but not delete).

You cannot remove a partition table: you can just change it, or completely clean your drive.

Here is an example using parted, just in case:

$ parted /dev/sdx
(parted) mklabel gpt

The other case is generally for removing data on the disk. For this purpose, you have a lot of simple tools to do that securely.

Here is an example using scrub, a Red Hat utility:

If you want more informations about erasing disks securely, I would recommend to have a look at the Archlinux Wiki. There is a complete documentation about that, with performance comparison.

Just for give you some tools you could use (I'm sure there are many others):

  • dd
  • GNU shred *
  • scrub *
  • wipe
  • badblocks
  • cat
  • xz

* Made especially for that, with the highest level of security (several passes, random data, etc.)

2
  • It's a learning experience. As I said, I'm newish to linux and starting from some fundamentals. dd is obviously something to get intimately familiar with. Commented May 2, 2023 at 0:38
  • Yes, no worries, Linux has a lot of tools for drives management, so it could be a bit hard at begining ! Commented May 2, 2023 at 6:14
0

How do you delete the partition table?

if the partition table is the old MBR (master boot record) then that is simply nukuing the first 512 bytes of the disk as that's where that partition table resides, and it was fixed in size. You can look all that detail up on the web easy enough about that partition table.

so for an MBR partition table to delete it that is done quite easily via dd

# if the disk whose partition table you want to erase shows up as /dev/sdb then...

dd if=/dev/zero of=/dev/sdb bs=512 count=1

The GPT (GUID partition table) on the other hand is much larger, and there is also a backup GPT partition table at the end of the disk.

https://uefi.org/specs/UEFI/2.10/05_GUID_Partition_Table_Format.html

I believe that if the disk is using 512-byte sectors then it is 512 x 32 = 16,382 bytes is how much space the GPT takes up. But disks now typically use 4096 byte sectors so 4096 x 32 = 131,072 bytes or 128kb. So change bs= accordingly to get the GPT at the beginning of the disk.

If it is of no consequence, you can simply wipe the first 1MB of the disk to be sure to get the whole table.

And then for the backup GPT at the end of the disk : Wipe last 1MB of a Hard drive

And this is assuming your partition table is one of those two which are by far the most common. But there are other partition types in existence, so it would be a matter of overwriting the disk in the proper location and to the extend needed via dd as described.

What are the differences between the various partition tables?

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.