Full Guide on How to Format Drive in Linux

Do you want to know which file system is the best for your Linux OS? Follow this guide and learn more including how to format hard disk Linux and the best data recovery.

Apr 14,2020 • Filed to: Hard Drive Recovery • Proven solutions

“I need to format drive Linux terminal and I don’t know the procedure. Any help out there?”

- a question from Quora
linux-format-disk-1

It is undeniable that fdisk is the most common command-line based disk manipulation utility for a Linux system. The utility can view, create, resize, delete, change, copy and format drives in Linux.

And it comes handy when a drive isn’t set to fit Linux use, and you want to make it usable. It might require you to give it a file system compatible with Linux.

So, which is the best file system for a Linux system?

Part 1: Which File System is Best for Linux

When formatting partitions on a Linux PC, you’ll see a plethora of offline system options. They don’t have to overwhelm you. And if you aren’t sure of the system file appropriate for Linux, the best option would be Ext4.

Ext4 is the default file system on most Linux distributions because it is the advanced version of the Ext3 file system. It isn’t the most advanced file system, but it works great—it is rock-solid and stable.

Soon, Linux distributors will gradually shift towards BtrFS, which is a new technology undergoing tons of development. Avoid it for now because the risk of data corruption or other problems isn’t worth the potential improvement in speed.

It is important to note that the Ext4 file system is exclusively for Linux systems. If you’re formatting an external drive you want to share with other operating systems like macOS and Windows, you shouldn’t use the Ext4 file system as the device won’t read it. You might want to consider the exFAT or FAT32 format, which is accessible to any device.

linux-format-disk-2

Part 2: How to Format a Drive in Linux

There are plenty of graphical tools available for disk partitioning and formatting on desktop Linux systems. The most commonly used are the QTParted and the Gparted.

However, many a time you’ll need to format hard drive from the command line, especially when you’re running a server. When done, you’ll have a partitioned hard drive with a Linux file system ready for use.

It is important to note that formatting or reformatting a hard drive on Linux erases all data on the storage media. It is important you back up all your files before proceeding to format.

Step 1 The first step is to set up a new partition.
  1. Open a terminal window and log in as root. To execute this, press Ctrl + Alt + T to open a terminal window. Start your commands with su to become a Root.

  2. To identify your drive, execute the following from the command prompt as root:
    # fdisk -l | grep '^Disk'
    The output should look like this:
    Disk /dev/sda: 251.0 GB, 251000193024 bytes
    Disk /dev/sdb: 251.0 GB, 251000193024 bytes
  3. The device name describes the entire hard disk.

  4. The fdisk will list the current drives on your Linux system. Select the one you want to format.

  5. To partition the disk, on this case /dev/sdb execute the following command:
    # fdisk /dev/sdb
    Here are all the basic fdisk commands you’ll need:
    M – Prints help
    P – Prints partition table
    N—Create a new partition
    D—delete a partition
    Q—quit without saving changes
    W—Write a new partition table and exit
    To create a new partition, hit the N button, and you’re set for the next step.
Step 2 The second step is formatting the new disk using mkfs.ext4 command

To format Linux partition using ex2fs on the new disk, run the following command:

# mkfs.ext4 /dev/sdb1

Step 3 Then mount the new disk using the mount command

First, create a mount point/disk1. Then use the mount command to mount/dev/sdb1. To execute this, enter the following command:

# mkdir /disk1
# mount /dev/sdb1 /disk1
# df -H

Step 4 Update /etc/fstab file

First, open /etc/fstab. To do that, run the following command:

# vi /etc/fstab

In the end, it will append as follows:

/dev/sdb1 /disk1 ext3 defaults 1 2

Step 5 Next, label the partition

You can label the partition using the e2label command. For instance, if you want to label the partition “Programs,” run the following command:

# e2label /dev/sdb1 /programs

Next time you want to mount the partition, you can use the label name instead of the partition name. And that´s all with formatting a hard drive from the Linux command line.

Part 3: Data Recovery from Formatted Linux Disk

In a perfect world, every byte of your data would be backed up to an external drive or a cloud storage service. And we don’t live in a perfect world.

Maybe, during the formatting session, you might have forgotten to back up your files. And after formatting your Linux disk, you might need to get your data back.

To facilitate the re-getting process of the file, you'll need a file recovery tool for Linux. And data recovery in Linux shouldn’t cost you a fortune. There are tons of free data recovery tools out there. But not all works accordingly.

However, we’ll focus on one that reliable, 100% free, and is specifically build for Linux -Ddrescue Data Recovery Tool.

Ddrescue is an expert freeware for Linux data recovery tool that retrieves data even in the most extreme extent. The tool is powerful beyond formatted-data recovery—it recovers data despite all sorts of disk errors and bad sectors.

ddrescure-data-recovery

Simple Guide to Use Ddrescue

  1. Connect a storage media that is at least 1.5 times larger than the Linux disk you’ve formatted

  2. Identify the names of the drives—the one you want to rescue and the one you want to recover the data to by executing the lsblk command. Let’s say that GNU ddrescure is on /dev/sda1, the drive you want to rescue is/dev/sdb1, and you are copying it to/dev/sdc1, here is the command to run:
    $ sudo ddrescue -f --no-split /dev/sdb1 /dev/sdc1 logfile
    $ sudo ddrescue -f -r3 /dev/sdb1 /dev/sdc1 logfile

It is important to note that the destination will be overwritten. It is important to ensure the destination is free of important data.

Part 4: Data Recovery from Formatted Windows 10 Hard Drive – Recoverit (IS)

Recoverit (IS)

Best Windows 10 Hard Drive Data Recovery Software:

  • An All-in-one Data Recovery Tool: Recoverit (IS)y software combines powerful features to rescue your data from any loss beyond just formatting. The software stretches a notch higher to retrieve data from accidental deletes, virus infection, and nearly all scenarios of data loss.
  • Super intuitive User Interface: Readily recover your hard drive in mere three clicks. No code required. No user manual. Just a 3-click procedure—Select, Scan, and Recover and you retrieve the data you desire.
  • Recover over 1000 Data Types: This tool can also recover any data type such as documents, videos, graphics, emails, and other files.
  • Recover Data from Any Storage Device: These include recovery of storage devices with the file system FAT32, NTFS, FAT16, among other file systems. Furthermore, it can retrieve data from external devices like USB drive, Cameras, Micro SD Card, Hard Drives, among other devices.
  • It is compatible with both Windows and Mac OS system.
icon_security 3,165,867 people have downloaded it

Conclusion

Managing storage devices is always a tricky task and HDD Linux format is no different. Any slight mistake and all your data may be lost or wrongly formatted. Thanks to the available online recovery tools. Ddrescue can come to your rescue at such times. It’s a freeware tool for Linux data recovery. It’s powerful and can recover any data type that is lost in any loss scenario. And if you need to recover formatted Windows or Mac hard drive, then Recoverit (IS) would be a perfect choice.

Elva

staff Editor

0 Comment(s)

Hot Articles

Easiest Ways to Fix Fatal Hard Disk Not Detected Error
Easiest Ways to Fix Fatal Hard Disk Not Detected Error
Learn the possible reasons why your external hard drive cannot be detected. Also, know how to enable your computer to recognize it.
How to Format Hard Drive to NTFS?
How to Format Hard Drive to NTFS?
How to format HDD to NTFS? Here you’ll find out two of the simplest ways to convert your hard disk from FAT32 to NTFS with slight help from Windows PC.
How to Format Your Drive to FAT32 System using Diskpart?
How to Format Your Drive to FAT32 System using Diskpart?
Formatting your Drive to FAT32 System using Diskpart is very easy. Go through the article and discover the best way to format your Drive to FAT32 System using Diskpart.
How to Fix Hard Drive Failure/Crash
How to Fix Hard Drive Failure/Crash
You might cause hard drive failure or crash. Are there some ways to fix hard drive failure? The answer is totally affirmative. Keep reading to learn more.
Home > > Resource > Hard Drive Recovery > Full Guide on How to Format Drive in Linux