how to mount new disk drive to Centos VPS Server

Mount Your new Drive to VPS Server

in this tutorial we are using fdisk . you can create only up to 2TB partitions with fdisk. Nowadays you may use parted instead. 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 no hardware RAID controller present in a system . Also this way should be applied to the fully virtualized servers using KVM or XEN-fullHV virtualisation technology.

Steps to attach and mount your drive:

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

First 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 fdisk /dev/sdb

fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel 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):
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

 

Now to be sure 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.

1,204 total views, 1 views today

how to mount new disk drive to Centos VPS Server
5 (100%) 1 vote

Leave a Reply

Your email address will not be published. Required fields are marked *

*