This article explains how to format a hard drive in Linux using
fsck, mkfs, and standard commands fdisk. You can use the
procedure described, reformat the disk hard from high school or
format the disk before starting the installation of the system.
Instructions and Preparation
1.
When
formatted the hard disk, the disk will be lost. In this sense,
it is very important to make backup of anything, which can
subsequently.
2.
To reformat
the drive, you need access to the root directory. All the
commands used in this tutorial are executed from the
command-line (Terminal) as root. Perhaps you want to also note
the size (capacity in MB) disk.
3.
Linux refers
to the hard disk drive as "hdx" or "sdx", where x is the drive
letter starting, that is the order in which the disc is added or
detected by the team. The prefix "hd" is used for the IDE and
the leg (previously only ATA) and SATA, SCSI and USB is used the
prefix "sd". Usually multiple is also included at the end of "hdx"
or "sdx" to denote the different partitions on the same physical
disk, but formatted, only should know is the drive letter that
you want to format.
4.
The examples
given in the instructions are for a team with two IDE hard disks
connected as master and slave. Disks are 'hda' and 'hdb'. You
will need to specify the drive letter that you want to format
for your own setup. Us hdb disk format. For all examples
regardless of the indication of the disk, replace "hdb".
5.
You can see
all the drives connected to the system through the command "ls/dev/hd
**" or "ls/dev/sd **" as they are the units (all IDE drives and
SATA drives, etc.). The output of this command appears in the
example, such as "/ dev/hda/dev/hda1/dev/sdb/dev/hda2/dev/hdb1".
The operating system is installed on the hda, which has two
partition (hda1 and hda2), and there are sdb1 and hdb for a
partition.
Using Fdisk
6.
First, use
the command fdisk delete all old partitions on the disk and
create a new one. Changes made using fdisk are only made
permanent if the command run "in" before the closing, so feel
free to be... a little, if you wish. If at any time you are
blocked, you can close the program without saving changes by
pressing "Ctrl" and press "c".
7.
At the
command prompt, type "fdisk/dev/sdb", replacing "hdb" with the
drive letter. When it opens, the fdisk can assign a couple of
warnings, which can be ignored. Then gives you a message that
looks like this: command (m aid):
8.
Enter "p",
may show the partition table of the disk. The first line of the
output of the command "p" also specifies the size of the disk.
This is a good way of exactly what they are working with the
correct drive.
9.
If you
already have all the partitions on the disk, it will be
displayed as the last lines of command "p". In our example, this
is seen as "/ dev/sdb1", used by some of the data in the file
system and the size of partition.
10.
To delete
all existing partitions, press the "d" and then "Enter". It
shall request the number of the partition that you want to
delete. The number of partitions is a number that is followed by
the hdb, so in our example, we went to 1. In the case of
multiple partitions, repeat the command "d" for each of them.
You can always display the partition, again with the "p" table.
11.
After
deleting the existing partitions on the drive, you can enter a
new one. Type "n" and press "Enter". Then press "p" to create a
primary partition. The program asks for the number of the
partition; Enter the value "1". You are now asked what partition
of cylinders must begin in. At the beginning of the disk is the
default, so I hit "enter". You are then prompted the last
cylinder. End of the drive is the default setting, can simply
press "Enter" again.
12.
They are now
back at the fdisk command line. "P" is used to verify the
contents of the partition table. You will now see a new
partition at the bottom of the exit. In this example, the list
as "/ dev/sdb1."
13.
Now we need
to define the type of file system for the new partition using
the "t". You will be asked the hexadecimal code of the file
system you want to use. We will use the standard Linux ext2
file, which is the ' 83. "If something unusual and know the
specific file system you want to use, you can press"L"to see all
the codes that are one or two characters of digits 0-9 and
letters (f)."
14.
Now simply
issue the command "in the" write the new partition table and
exit fdisk.
Create new file with mkfs
15.
Now you must
create a file system on the disk. You can do this by using the
command "mkfs".
16.
At the
command prompt, type "mkfs-t ext2 /"
Done!!