Technical Support

how to mount new disk drive to Centos VPS Server

In this tutorial we are using fdisk  to mount disk drive to your server , this tutorial can be applied for VPS and Dedicated servers too. you can create only up to 2TB partitions with fdisk. Nowadays you may use parted instead.

What is fdisk

fdisk command-line utility provides disk-partitioning functions – for example: preparatory to defining file systems.

Mount Your new Disk Drive to VPS Server

Note that Your OS also should support GPT support in kernel in order to use partitions more than 2TB.

So in this case we use parted and partitions less than 2 TBs. Also please note that in case you are using HW RAID you most likely should rather differ way to manage your partitions. In current case we suppose that there is no hardware RAID controller present in a system . Also this way should be applied to the fully virtualized servers using VPS KVM or XEN-fullHV virtualization technology.

Steps to attach and mount your Disk drive:

First Login to your server using SSH as root privileges.And run the following command :

Lets see the devices in the system

    
     df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 239G 879M 226G 1% /
none 3.9G 0 3.9G 0% /dev/shm

    
   
In this scenario we are going to add the Disk /dev/sdb
    
     fdisk -l
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
Disk /dev/sda: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00083ede
 
Device Boot Start End Blocks Id System /dev/sda1 1 31592 253755392 83 Linux /dev/sda2 31592 32636 8387584 82 Linux swap / Solaris
    
   
Now You will need to run the following command fdisk /dev/sdb
    
     fdisk /dev/sdb
    
   

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disk label Building a new DOS disk label with disk identifier 0x5bac3a50. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won’t be recoverable. Command (m for help):
Now we need to enter n to add a new partition

    
     n
Command action e extended p primary partition (1-4)
#type p for primary partition , 
#then form Partition number (1-4): 
#type 1 and press Enter; 
#and for First cylinder (1-13054, default 1): 
#just press Enter;
#and for the Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): 
#Press Enter again for default value;

p
Partition number (1-4):1
First cylinder (1-13054, default 1):#Enter
Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Command (m for help):
#Now  type w to write and sync the disk

w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
    
   

The next step is to run mkfs -t ext3 /dev/sdb and confirm the message

    
     mkfs -t ext3 /dev/sdb
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
    
   
The next step is creating directory with name and map the name to the device in the example “DIRECTORY” is the name what we need , start run the following commands:
    
     mkdir /DIRECTORY
e2label /dev/sdb /DIRECTORY
echo “LABEL=/DIRECTORY /DIRECTORY ext3 defaults 1 2” >> /etc/fstab
mount LABEL=/DIRECTORY /DIRECTORY
    
   

To confirm that your drive listed and usable, simply run the following command

    
     df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 239G 879M 226G 1% /
none 3.9G 0 3.9G 0% /dev/shm
/dev/sdb 99G 188M 94G 1% /DIRECTORY

    
   

after all of those commands you can simply access your new drive by run cd /DIRECTORY and use your new drive.

XsoftHost Support

Share

Recent Posts

Add Extra IP addresses to server configuration On Ubuntu 17.10 and later

Each failover IP address will need its own line in the configuration file. The configuration…

3 years ago

Create RAID Arrays with mdadm on Ubuntu

What is mdadm? The mdadm utility can be used to create and manage storage arrays…

4 years ago

How to change the maximum upload file size for PHP

There are several scenarios that you might need to increase or decrease your php maximum…

6 years ago

How to install Let’s Encrypt Plugin in WHM/cPanel

What is Let’s Encrypt? Let’s Encrypt is a free certificate authority provided by the Internet…

6 years ago

How to install python in my cPanel and add py extension

Python normally installed on all cPanel hosting server because most of Centos/red hat update system…

6 years ago

How to install and enable GUI GNOME Desktop on centos 7

Usually CentOS 7 comes in a numbers of variants, For most users, there are two…

6 years ago