Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Facebook Twitter Instagram
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Tech News Today
Home»Linux»How To Format Hard Drive On Linux?

How To Format Hard Drive On Linux?

Anup ThapaBy Anup ThapaDecember 18, 2022
format hard drive linux

When you think Linux, you think code. And while it’s true that the command-line is primarily used for most tasks, including disk management, its not the only option. Most Linux distros offer both easy-to-use GUI based methods, as well as, countless CLI-based methods for advanced users.

Before you start, remember to backup any important files elsewhere if you haven’t already done so. When using the command-line methods, make sure you get the syntax and capitalization correct to avoid common errors. Finally, also make sure that you choose the correct device to format as it’s very easy to mess this up.

Table of Contents

  • Using GParted
  • GNOME Disks
  • Make File System (mkfs)
  • Using Shred
  • Using dd

Using GParted

GNOME Partition Editor or GParted is likely the most popular GUI-based partition manager. It owes its popularity to its simple and intuitive interface. Here’s how you can format your hard drive using GParted:

  1. First, you’ll want to install the GParted package if you don’t already have it.
    • On Debian-based distros, use the sudo apt-get install gparted command.
    • On Fedora-based distros, use the su -c "yum install gparted" command.
      sudo-apt-get-install-gparted
  2. After installing it, search and open GParted and input your password for authentication.
  3. Right-click the hard drive and Unmount it first.
  4. Select Format to and pick the partitioning style of your choice.
    gparted-format-to
  5. After you check the pending operations, press Apply All Operations.
  6. Press Apply to confirm.

GNOME Disks

GNOME Disks is a partition manager that serves as a graphical front-end for udisks. This utility comes preinstalled with various distros, including Ubuntu. Here’s how you can format your hard drive using GNOME Disks:

  1. Open the File Browser, right-click the HDD and select Format.
  2. Alternatively, search disks and open the Disks utility.
  3. Select your HDD from the left pane and click on the Drive Options button.
    gnome-disks-format-disk
  4. Select Format Disk, specify the Erase Method and Partitioning Style, and click on Format.
    overwrite-existing-data-with-zeroes
  5. Check the affected devices list and click on Format.
  6. Input your account password to confirm and proceed.

Make File System (mkfs)

The mkfs utility comes baked in with most Linux distros. It’s used to format block storage devices with a specific file system. Here are the steps to format your hard drive using this command:

  1. First, use the df -h command to list the mounted file systems.
    df-h-ubuntu
  2. Then, use the sudo umount <device> command to unmount the hard drive.
  3. Next, use the sudo mkfs -t <fs> <device> command to format the partition with your preferred file system (ex. ext4, ntfs, vfat).
    sudo-mkfs-t-ntfs
  4. Afterward, you can use the lsblk -f command to verify the changes.

Using Shred

The shred utility is used to overwrite your data repeatedly so that the deleted data can’t be recovered later. The basic syntax for this command is as follows:

  • shred <options> <device>
sudo-shred

The device portion refers to your HDD mount point, but the options will vary depending on the usage case. You can use shred --help for the full list, but here are some useful ones to start with:

-f, --force  change permissions to allow writing if necessary
-n, --iterations=N  overwrite N times instead of the default (3)
-v, --verbose  show progress
-z, --zero add a final overwrite with zeros to hide shredding

Using dd

The dd utility is commonly used in Unix-like systems to copy and convert files. But you can also use this utility to zero-fill, or write random data to your hard drive. Shred is considered more secure as it offers multiple overwrites, but dd is generally faster. Ultimately, it’s up to you to choose which one to use.

With that said, the basic syntax for dd is as follows: 

  • dd if=source of=targetdevice <options>
sudo-dd

If you wanted to write random data to the drive mounted at /dev/sda instead of zeros, you could use the following command instead:

  • dd if=/dev/urandom of=/dev/sda bs=16M
how-to
Anup Thapa
  • LinkedIn

Anup Thapa is a tech writer at TechNewsToday. He mostly writes informative articles, tutorials, and troubleshooting guides related to Windows systems, networking, and computer hardware. Anup has been writing professionally for almost 5 years, and tinkering with PCs for much longer. His love for all things tech started when he got his first PC over 15 years ago. It was a Pentium IV system running Windows XP on a single 256 MB stick. He spent his formative years glued to this PC, troubleshooting any hardware or software problems he encountered by himself. Professionally, Anup has had brief forays into a variety of fields like coding, hardware installation, writing, etc. In doing so, he's worked with people of different backgrounds and skill levels, from average joes to industry leaders and experts. This has given him not just a versatile skillset, but also a unique perspective for writing that enables him to concisely communicate complex information and solve his reader's problems efficiently. You can contact him at anup@technewstoday.com

Related Posts

how to change boot order on linux

How to Change Boot Order on Linux

December 16, 2022
make-command-not-found

How to Fix “Make: Command Not Found” Error

September 20, 2022
linux terminal for windows

How to Install Linux Terminal on Windows

September 19, 2022
How-to-force-Quit-an-app-on-Linux

How to Force Quit an App on Linux

August 30, 2022
best linux for virtualbox

8 Best Linux Distros to Try in VirtualBox

August 30, 2022
ifconfig command not found

How To Fix “ifconfig Command Not Found” Error?

December 18, 2022
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
what-does-collate-mean-on-a-printer

What Does Collate Mean on a Printer?

March 31, 2023
usb-vs-pcie-wifi

USB Vs PCIe Wi-Fi—Which One is Better?

March 31, 2023
how often to replace laptop

How Often Should You Replace a Laptop

March 29, 2023
You may also like
computer suddenly slow

Why is My Computer Suddenly Slow? 11 Ways to Fix It

March 31, 2023
HTTP-Error-431

How to Fix HTTP Error 431

March 31, 2023
scheduled task reboot

How to Create a Reboot Scheduled Task in Windows

March 31, 2023
Recommended
Cookie Clicker Garden Guide

Cookie Clicker Garden Guide to Unlocking Every Seed

September 26, 2021
monitor no signal

Computer Turns On But Monitor Says No Signal (9 Ways To Fix)

November 10, 2022
Facebook Twitter Pinterest
  • Home
  • About Us
  • Our Team
  • Editorial Guidelines
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday, editor@technewstoday.com | Tech Central Pvt. Ltd.

Type above and press Enter to search. Press Esc to cancel.