I would like to know if there is any command in Linux (Ubuntu, Linux Mint, etc) that is equivalent to the Windows full format option.
-
1gnome-disks -> click gear icon -> format partition -> toggle "Erase" to on – Alvin Liang Nov 06 '18 at 04:04
-
Possible duplicate of Format and partition second hard drive using terminal? (Ubuntu Server 14.04) and How to resize partitions?. – karel Nov 06 '18 at 06:32
-
It's not just about duplicate questions. I had to pin it anyway because everything else who already posted on this page thinks that you can format the same partition that your OS is currently running from while that OS is still running, and it's time for someone to do a reality check. – karel Nov 06 '18 at 06:42
3 Answers
Linux has various terminal tools such as fdisk, parted. GParted is a graphical interface for parted.
Type fdisk /dev/sdx (replacing x with your drive letter) Type d to proceed to delete a partition. Type 1 to select the 1st partition and press enter.
By "fully format" a partition, are you trying to write over the data? Eg a 'secure erase?' Gparted and other formatting utilities wont overwrite the data. They just define the filesystem. The bit representation of the data is still retained until its needed and then overwritten by the OS/filesystem. I'm guessing you want to write zero's across the entire disk, and then create the filesystem?
To overwrite a drive or partition:
# List disks
fdisk -l
# Look for 2 lines like the following
Disk /dev/sda: 477 GiB, 512110190592 bytes, 1000215216 sectors
Sector size (logical/physical): 512 bytes / 4096 bytes
# Calculate optimal sector size (Using physical sectors)
let "count = 512110190592 / 4096"
block=4096
# Wipe disk
dd if=/dev/zero of=/dev/sda bs=$block count=$count seek=0 status=progress
Replace /dev/sda
with the drive you want to wipe. sda
is generally the first drive on the system. A USB or other external device will start from sdb
onward. The let count
command is taking the size of the disk and dividing it by the physical sectors and creating a variable named count
. The count and block variables are then used to start from point zero and write 0's until the end of the disk. dd
reads 0's from /dev/zero
and outputs them to /dev/sda
.

- 101
-
I see, then maybe you are looking for something along the lines of bad blocks. This command will try to read/write to the drive to determine the sectors status:
sudo badblocks -nvs /dev/sdx
– Rex Linder Nov 06 '18 at 06:09 -
The archlinux wiki has a great section on badblocks and how to do this before creating the filesystem. https://wiki.archlinux.org/index.php/badblocks#Before_filesystem_creation – Rex Linder Nov 06 '18 at 06:43
-
See that link I posted. It covers how to create a list of the badblocks and then include this information when creating the filesystem. Which, if I understand you correctly, is exactly what you want. – Rex Linder Nov 06 '18 at 06:56