How to Format Disk in Linux or Partition Drive in Ubuntu OS?

Last updated on September 19th, 2022

A Linux operating system is a system for running programs. It is similar to Windows and IOS. Web Developers use it. The process itself provides security for the user. It works on the command given in the terminal by the user itself to complete different tasks Like linux format disk or Format Disk in Linux.

Check several components before format disk in Linux

Bootloader:-  This software is responsible for starting your computer.

Kernel:-The kernel is the heart of the system. It manages the CPU’s memory. Operating systems are based on it. 

Init system:- This is the system responsible for managing the boot process once the bootloader has been used.

Daemons:- These are the services that run in the background when a machine starts up or when a user logs into the computer.

Graphical Server:- It is a subsystem that displays the graphics on the monitor.

Desktop Environment:– It is the piece that the user interacts with. Cinnamon & Mate are two examples of desktop environments. 

Prior To Beginning of Linux format disk

Linux Types 

DEBIAN:- It is referred to as Debian GNU/Linux. Developed by the community-supported Debian project, it is composed of free and open-source software.  

Ubuntu:- It draws on the infrastructure of Debian. These operating systems run on Linux servers, desktops, phones, and tablets.

LINUX MINT:- It is a community-driven Linux distribution based on ubuntu, a package with various free applications. 

FEDORA:- It is sponsored by RED HAT, with additional support and sponsorship from other organizations and companies. In addition to distributing free software, it aims to stay on the leading edge of technology.

Kali Linux- a software distribution based on Debian designed for use in digital forensics and penetration testing. Hackers also use it in different fields, and offensive security maintains it.

How To install Linus/Ubuntu OS?

Learn in the below steps how to use:

  • First, you have to be familiar with the software by installing it in your system.
  • The next step is to test your hardware with a Live CD.
  • Then do the task you usually use your computer for.
  • Try to learn the distributions of Linux.
  • Please consider booting.
  • Install all the software.
  • Learn how to use the command line.

What Do You Do If You Need A Linux/Ubuntu Format disk?

It is essential to ubuntu format disk because for using Linux, it is usually required to format the drive when a new OS is going to be used by the user. It must be formatted before use.

It can also be done for many other reasons, i.e., changing the file system, fixing errors, or deleting all files/data. There can be many different reasons for formatting the drive i.e.

  • The system has low or free space. 
  • The system is getting slow due to the low free space.
  • If the system is corrupted by malware.
  • If the user is selling their system
  • Due to an issue in system storage. 


No dedicated disk management tool can help the user to perform linux format disk. User needs to take the assistance of some command to format the drive in Linux.

The following steps will explain how you can format a disk on Linux :-

  • Create a partition of the linux format disk
  • Enter the following command after connecting the disk to your Linux system

sudo fdisk 

  • to create a partition, enter command fdisk i.e.

sudo fdisk /dev/sdb

  • You can type if you want
  • The supported parameters are listed by ‘m’.
  • The ‘n’ key creates a new partition
  • Delete a partition by typing ‘d’
  • The partition table can be checked with ‘p’
  • Format the disk
  • You can format a partition on your system after creating it by running the following command:

sudo mkfs.ext4 /dev/sdb.

  • this makes the design look for available partitions in the format drive linux
  • by pressing ‘y’, you can confirm your choice 
  • then wait for a moment while the selected section is formatting.
  • NTFS format for Linux
  • To format a disk using the NTFS file system, run the mkfs command

sudo mkfs -t NTFS /dev/sdb1

  • Use this method to verify the file system 

lsblk -f

  • locate the partition and confirm that it uses the NTFS file system.

STEPS TO WIPE A HARDWARE UNIT before linux format disk


If you plan to resell your system or if you care about your privacy, format disk in Linux. Like formatting, wiping a drive can also erase all the files or data of the drive.

STEPS are as follows:-


You can use the apt install command first if a command is not readily available on the Linux system. i.e.

#apt install wipe

once done, just use the command ‘wipe’ to wipe a partition 

# wipe /dev/sda2

enter ‘yes’ for confirming your choice and wait while the partition Linux Disk is wiped.

Note : Wipe command is only supported in Ubuntu.


It is the best way to protect your private data.

It works as an ideal shredder. It will overwrite your data with something else.

a command is:-

shred [option] target

In “target”, you can specify a file name, folder, or partition to shred. 

Among its options are:

-n: Adding “n” times to a data set

-f: Changes the permissions and allows writing to occur

-u: Truncates the files after they have been shredded

-s: To specify the size of the shred

-u: Removing files after shredding

-v: Enable verbosity

-z: Overwrite the final data with zeros

The Linux disk can be wiped by entering the following command 

#shred -vfz -n 10/dev/sda2.


You can use the ‘dd’ command to erase the disk if you have less time.

The entire disk will be overwritten with strings of zeros. 

it has certain options to customize the process i.e. 

dd if=source of=target[options]

The command prompt must be run as a professional user.

#dd if=/dev/zero of=/dev/sda2 bs=512 count=1.

Overwriting the data with zeros will overwrite it.


The scrub command overwrites the disk with a specific pattern.

A few times, the patterns can be generated by the system too.

if the command is not present in the Linux system, you must install the apt install command.

The command must be entered 

scrub[option] target.

If you choose to erase the disk, you will be prompted to confirm your decision. For instance,

#scrub /dev/sda5

TIPS FOR ubuntu format disk

Here are some tips for Linux Disk Format or wiping the Linux disk successfully.

  • If you logged in as an administrator while wiping the disk, it would make the process easier.
  • You do not need to install every command.
  • It is recommended to use reliable commands when shredding or wiping a disk because there are a lot of third-party applications on the market.
  • When using a readily available tool, only use a trusted source.
  • Always check the command before entering it. A small error might end up causing irreversible damage to the system.
  • The most important tip is that you should always take a backup of your data before wiping the Linux disk so that in case of any error, or any other issue, you have a second copy of your data in your hand. So that you can revive your data, and if you buy a new system, you have the data of your old system that will help you.
  • These are some of the tips recommended to you before Format Disk in Linux.  

Conclusion on partition disk in linux :-

That is a wrap, folks! You can quickly meet your requirements when you know how to Format Disk in Linux. Use a reliable data recovery solution like Server Wala if you accidentally deleted or wiped your data or formatted your drive.  By attaching your Linux device to a PC, you will be able to recover lost or inaccessible content. Feel free to try out some of these methods and please let me know what shortcuts or tips you found in the comments below.

Also Read: Check list of Users in Linux

Get in Touch

Arpit Saini

He is the Director of Cloud Operations at Serverwala Cloud Data Centers Pvt Ltd and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Related Articles

Adblock Detected

Please consider supporting us by disabling your ad blocker