Add, partition, format and mount hard disks on linux. Fast and simple step by step guide

By neokrates, written on November 12, 2011


  • Join date: 11-30-99
  • Posts: 224
View Counter:
Rate it
  • Which virtualization do you like most?

    View Results

    Loading ... Loading ...
  • bodytext bodytext bodytext

New hard disk was attached to the Linux PC. Now it is time to find it, add partitions, format and make available for the system.Here is a simple step by step guide with some explanation of the process.

👉 Warning. Process of adding new storage devices to Linux naturally means the risk of data loss. If you are not sure what you do, you may fdisk or format the wrong device. You may loose your data. Depending on what is gone wrong data loss may be repaired or not. So, think twice before each step, double check.

Works for:

✔ newer Debian, Ubuntu, CentOS distros

Should work for:

✔ most other common newer Linux distros


Become root

You will need super user privileges, do and enter authorize as needed

 su - 


Where on Linux is my new hard disk?

One way to find new, avalaible but not partitioned device, is to use ls /dev/s*

[root@thinkplexx ~]# ls /dev/s*
/dev/sda   /dev/sda2  /dev/sdb1  /dev/sg1  /dev/snapshot  /dev/stdin   /dev/systty
/dev/sda1  /dev/sdb   /dev/sdc   /dev/sg0   /dev/sg2  /dev/stderr    /dev/stdout

Here, we can see that /dev/sda, /dev/sdb etc all have been partitioned:


/dev/sdc is available as a phisical device but has no partitions like /dev/sdc1, /dev/sdc2 etc.


Use fdisk to make partitions


Start fdisk

fdisk /dev/sdc :

[root@thinkplexx ~]# fdisk /dev/sdc
The number of cylinders for this disk is set to 33418.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Message is common for newer disks and selfexplaining. Says that you might have problems with older LILO’s and double booting systems.


Get disk info

You are inside fdisk now

Command (m for help): [type p]

Disk /dev/sdc: 274.8 GB, 274877906944 bytes
255 heads, 63 sectors/track, 33418 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Yep, disk is there, but no partitions.


Add a primary partition

We just take all space for one partition:

Command (m for help): [type n]
Command action
   e   extended
   p   primary partition (1-4)
[type p]
Partition number (1-4): [type 1]
First cylinder (1-621, default 1): [type RETURN]
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-33418, default 33418):  [type RETURN]
Using default value 33418

Verify new partition table, in my case it would be:

Command (m for help): p
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       33418   268430053+  83  Linux


Write table to disk and exit

After you verified that your changes are ok, use w to write new partition table.
If you don’t use “w”, no changes will happen, no new partitions will be creted.


Format disk

now, if you try ls /dev/s* , there will be /dev/sdc1 partition available:

[root@thinkplexx ~]# ls /dev/s*
/dev/sda   /dev/sda2  /dev/sdb1  /dev/sdc1 /dev/sg1  /dev/snapshot  /dev/stdin   /dev/systty
/dev/sda1  /dev/sdb   /dev/sdc   /dev/sg0   /dev/sg2  /dev/stderr    /dev/stdout

Run mkfs.ext3 to format using ext3 filesystem.

[root@thinkplexx ~]# mkfs.ext3 /dev/sdc1
mke2fs 1.39 (8-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Writing inode tables: done
Creating journal (268430053 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.



Create a new mount point
mkdir /mnt/storage

Now edit fstab so that mounted device will be available after reboot and mount command may be applied on mount point.

vim /etc/fstab

You are in vim, type [e].

State that /dev/sdc1 partition should be mounted to /mnt/storage :

/dev/sdc1               /mnt/storage            ext3    defaults        1 2

After line is added, use key combination [esc][:wq!]. Vim saves new fstab.

Mount now:
mount /mnt/storage


Done, new hard disk partition can be used

[root@thinkplexx ~]# cd /
[root@thinkplexx ~]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdc1            264218344         0  89411780  0% /mnt/storage

device is ready to be used.

Have fun!

Be Sociable, Share!
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: +4 (from 4 votes)
4 votes 'YES'  0 votes 'NO'


Be Sociable, Share!


Leave a Reply