+5 votes
92 views
in Linux by (242k points)
reopened
Linux: Format hard drive

1 Answer

+3 votes
by (1.6m points)
 
Best answer

Format hard drive with Gparted
Format the hard disk in the terminal

You format hard drives in Linux almost always in the same way, either graphically or in the terminal..

image image

You can format hard drives under Linux with a wide variety of tools. We present two options below: This is the easiest way to get to your destination with the Terminal and Gparted.

Format hard drive with Gparted

Gparted is the quasi-standard for partitioning hard drives under Linux. And so, of course, it also masters formatting. Gparted is already preinstalled on many distributions and can otherwise be installed using the command " sudo apt-get install gparted " or via the respective software center. After starting the program, the first thing you need to do is select the correct hard drive . You can find the selection in the upper right corner. By default, on Linux, drives are labeled sda, sdb, and so on. The back letter simply counts the drives.

If it is a brand new disk, you must first create a partition . You can find detailed instructions on partitioning hard drives under Linux here. The short version: Call the context menu of the only entry on the hard disk ("not allocated") and select " New " to create a partition. And in the following dialog box the item " File System " appears: Here you select the appropriate system with which the partition is to be formatted. For a Linux-internal drive this will often be EXT4 , for drives that should also run on Windows computers it will be more like FAT32 .

image
Partitioning and formatting is done in one step.

It is even easier if old, already partitioned data carriers are to be reformatted. In this case you will find entries for each individual partition in the main view of Gparted and you can format them with the desired file system directly via the context menu. By the way: You can of course also process external data carriers such as USB sticks with Gparted..

image
Existing partitions can be formatted directly from the context menu.

Format the hard disk in the terminal

Of course, formatting can also be done very easily in the terminal. The procedure is divided into two parts: First , list all drives and their partitions in order to find the correct name. This is followed by formatting. So open a terminal and list the partitions with the command " sudo fdisk -l ". Here you will find the same notation as in Gparted: The system partition is usually "sda", a second hard disk starts as "sdb". Here you can also see the individual partitions, which are counted in turn, i.e. sda1, sda2 and so on.

Assuming that the second hard disk is occupied by only one large partition and you want to format it with "EXT4",how to use the command " mkfs.ext4 / dev / sdb1 ". mkfs stands for" Make Filesystem ", the desired file system is simply appended with a dot . And since everything, including partitions, are treated as files under Linux, the path to the partition " sdb1 " simply follows. , to be found in the standard "dev" folder. If you want to know which filesystems are still available and how these are exactly written, simply call up help with the usual " man mkfs ".

image
Not pretty, but very quick and easy: formatting in the terminal.

...