Using Gparted to Completely Clear A Drive

17,140

Solution 1

If you want to have a really blank disk just do

dd if=/dev/zero of=$YOUR_DEV bs=1M

Under normal conditions this is not necessary but it may be necessary to swipe out the beginning and the end of the disk, because there may be data of a secondary GPT at the end of the disk.

So what I do to clean a disk is:

YOUR_DEV=/dev/sdX
dd if=/dev/zero of=$YOUR_DEV bs=512 count=100
dd if=/dev/zero of=$YOUR_DEV bs=512 seek=$(( $(blockdev --getsz $YOUR_DEV) - 100 )) count=100

Now, no OS installer of my knowledge finds any old partitions nor any old installed OS and will setup the disk right correct to the BIOS- and OS-settings (MBR or GPT).

Solution 2

Don't do the operation from a running system.
Boot from the Ubuntu installation media.

Open GParted and delete all partitions.
Click on Apply ... then click on Device.
Select Create a new partition table.

Select gpt when you have an EFI based BIOS.
Select msdos when you have a legacy BIOS.
Now the whole disk is completely blank.

Solution 3

You can delete all partitions of a disk instead of just formatting them using Gnome Disks as well.
Of course this can only work on a disk that is not currently in use, i.e. all partitions have to be in an unmounted state and no swap may be used on this disk. In case you want to perform this on a disk that contains mount points needed by the running Ubuntu system, you can't proceed and have to boot from a live medium instead.

Launch gnome-disks, select the device to clear from the list on the left, then click the hamburger button in the top right corner of the window. From the appearing menu, chose Format disk....

A small dialog window will appear. You have two settings:

  • Erase: Decide between "overwrite existing data with zeroes (slow)" and "don't overwrite data (fast)". If its for personal use only and you don't have to make sure that there's no chance of restoring pieces of data, it's okay to chose the fast method. Overwrite the data if you want it irreversibly gone. To install a new OS or create new partitions and format them, this doesn't make a difference.

  • Partitioning: Decide between "Compatible with modern systems and hard disks > 2TB (GPT)", "Compatible with all systems and devices (MBR/DOS)" and "No partitioning (empty)". Here you select the kind of partition table you want to create. I would recommend you to use MBR unless you have a reason to select a different one.

Then click on Format..., enter your admin password and watch the progress bar.

Share:
17,140

Related videos on Youtube

David
Author by

David

Computer Engineering Tech Major Fluent in .NET, bash, and TypeScript AU User since mid-2015 Using ubuntu since 9.04

Updated on September 18, 2022

Comments

  • David
    David over 1 year

    What I need is to 100% clear and un-format a 3TB drive. Nothing more. It seems doing this from GParted, however when I try to put information onto the drive after formatting with another source, it says the drive is full. This is not a problem with the other source because it was able to copy to my 2nd 3TB drive very well and quickly. Can anyone help me to reset this drive? I am currently away from home, but I am using the Ubuntu "Disks" app to format it, and I have it set to overwrite existing data. Will edit if that changed it.

  • Byte Commander
    Byte Commander about 8 years
    6 seconds faster than me! :D
  • David
    David about 8 years
    @ByteCommander Don't know which answer to accept. Both of you have really good answers Lol
  • David
    David about 8 years
    How would I format the drive to be compatible for Windows installation?
  • cl-netbox
    cl-netbox about 8 years
    @DavidCole-GrammarPolice : Maybe this can help you -> askubuntu.com/questions/743095/… - you can find some useful information on how to prepare the disk for new installations. :)
  • Byte Commander
    Byte Commander about 8 years
    It's irrelevant whether you overwrite all data or not as you don't give the drive away and don't have to shred sensible data. Regarding the partition table, I would go for MBR/DOS as that's compatible with all systems unless your device is larger than 2 TB. But the Windows installer can also create its preferred partition table itself I assume, so you could also try and select EMPTY.
  • cl-netbox
    cl-netbox about 8 years
    @DavidCole-GrammarPolice : When you have an UEFI BIOS you should select a GPT partition table when you want to install Windows 8 or 10 - in case you have a legacy BIOS, you should select msdos (MBR).
  • David
    David about 8 years
    @cl-netbox Windows 7 :(
  • cl-netbox
    cl-netbox about 8 years
    @DavidCole-GrammarPolice : Windows 7 will be automatically upgraded to Windows 10 - important is the BIOS mode. :)
  • Patrick M
    Patrick M about 8 years
    +1 This is usually what I do when some utility or OS installer is so smart that it won't let me wipe the disk. I usually take the lazy method though of doing the first command, counting to 5, and then doing a Ctrl-C.