Anything in Linux is awalys slightly more taxing but is not that hard once you know how.
So first up you need to know whether you are working with a IDE and PATA (formerly just ATA) drive or a SCSI, SATA and USB drive.
Linux refers to IDE and PATA drives with “hdx” and SCSI, SATA and USB drives with “sdx“. Usually, a number is also put at the end of “hdx” or “sdx” to denote different partitions on the same physical drive, but for the purpose of formatting, you only need to know which letter the drive you want to format is.
To see all the drives attached to your system use the following commands.
[sourcecode language=”sh”]ls /dev/hd*[/sourcecode]
[sourcecode language=”sh”]ls /dev/sd*[/sourcecode]
In my case I have installed a new SATA hard drive so I am working with ‘/dev/sdb‘
First we will use ‘fdisk‘ to erase any old partitions on the drive, if you have a fresh new hard drive you wont need to do this.
[sourcecode language=”sh”]fdisk /dev/sdb[/sourcecode]
Now we can type ‘p‘ to see a partition table of the drive. The first line of output from the “p” command will also tell you the size of the drive. This is a good way to double-check that you are working with the correct drive.
To delete any existing partitions, press “d” and then “Enter.” It will ask you which partition number you wish to delete. The number of the partition is the number that follows ‘sdb‘. You can always view the partition table again with the “p” command.
Type “n” and hit “Enter.” Then press “p” to create a primary partition. It asks you for a partition number; enter “1” Now you are asked which cylinder the partition should start at. The beginning of the drive is the default, so just hit “Enter.” Then, you are asked for the last cylinder. The end of the drive is the default, so you can just press “Enter” again.
Now you are back at fdisk’s command prompt. Use the “p” command to check the partition table. You should now see your new partition at the bottom of the output. In the example, it lists as “/dev/sdb1”
You now need to set the filesystem type for your new partition with the “t” command. You are asked for the Hex code of the file system you wish to use. We will use the standard Linux ext2 file system, which is “83”
Now just issue the “w” command to write your new partition table and exit ‘fdisk‘
Finally we need to create the file system on the drive. We use the ‘mkfs‘ command.
[sourcecode language=”sh”]mkfs -t ext2 /dev/sdb1[/sourcecode]
Its good practise to now run a file system check on the new drive, we do this with the following command.
[sourcecode language=”sh”]fsck -f -y /dev/sdb1[/sourcecode]
Last but not least we need to mount the drive at boot. We do this by adding an entry into the ‘/etc/fstab‘ file.
[sourcecode language=”sh”]vi /etc/fstab[/sourcecode]
In my case the I want to mount the drive at ‘/meat‘ so we enter the follwing line in the ‘fstab‘ file.
[sourcecode language=”sh”]/dev/sdb1 /meat ext2 defaults 0 0[/sourcecode]
Thanks to http://www.ehow.com/how_1000631_hard-drive-linux.html