How do I add a new hard drive in Linux?

Important Notes:

  • This guide is for customers who have purchased an additional hard drive from us, and need help configuring it to work with their Linux Server.

Getting Started:

  1. Check to see how many drives are installed: You can do this using the fdisk command. 

     


    [root@default]# fdisk -l | grep '^Disk'


    You should output similar to the following:

     


    Disk /dev/sda: 251.0 GB, 251000193024 bytes
    Disk /dev/sdb: 251.0 GB, 251000193024 bytes


    A device name refers to the entire hard disk. For more information see 
    Linux partition naming convention and IDE drive mappings .




  1. To partition the disk - /dev/sdb, enter:


[root@default root]# fdisk /dev/sdb

  • For help using the partitioner, use the “m” command:


    Command (m for help): m
    Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       l   list known partition types
       m   print this menu
       n   add a new partition
       o   create a new empty DOS partition table
       p   print the partition table
       q   quit without saving changes
       s   create a new empty Sun disklabel
       t   change a partition's system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)
    
    Command (m for help): 
  • partitions using the command “p”:


    Command (m for help): p
    
    Disk /dev/sdb: 50.0 GB, 50019202560 bytes
    255 heads, 63 sectors/track, 6081 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
       Device Boot    Start       End    Blocks   Id  System
    
    Command (m for help):


  • To create a new partition, issue the command “n” and then select “p” for primary and 1-4 depending on which partition on the drive this is (first, second, third, or fourth):

    n(creates a new partition)

    p(creates a primary partition)

    1(the number 1 denotes the partition will be /dev/sdb1)


    Command (m for help): 
    Command (m for help): n
    Command action
      e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-6081, default 1): 1
    Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): 6081



  • To save the partition, use the “w” command:


    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@default root]# 


  1. Format the new disk using mkfs.ext3 command:

    To format Linux partions using ext2fs on the new disk, issue the following command:

     


    [root@default]#mkfs.ext3 /dev/sdb1


  2. Mount the new disk using the mount command: 

    First, you'll need to create a mount point. We'll use /disk1. This is where we'll mount /dev/sdb1. Enter the following commands:

     


    [root@default]# mkdir /disk1
    [root@default]# mount /dev/sdb1 /disk1
    [root@default]# df -H


  3. Edit /etc/fstab so the new drive will automatically mount to /disk1 on reboot

    This step can be complicated, if you need assistance at this step, please call Dedicated Server Support at: 877-999-2750






Related Articles

No related articles were found.

Attachments

No attachments were found.

Visitor Comments

No visitor comments posted. Post a comment

Post Comment for "How do I add a new hard drive in Linux?"

To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.

   Name:
   Email:
* Comment:
* Enter the code below:

 

Article Details

Last Updated
8th of October, 2010

See also:
Getting started with your server.

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF


User Opinions

50% thumbs up 50% thumbs down (2 votes)

How would you rate this answer?




Thank you for rating this answer.

Continue