This article covers using fdisk to mount disk drive to your server. You can apply this steps on VPS and Dedicated servers too. The user create only up to 2TB partitions with fdisk. In these days it is possible to use parted instead.
What is fdisk
FDISK stands for Fixed Disk Editor, which means it edits the Fixed Disk (hard drive, floppy disks are removable data and are NOT fixed). FDISK is a tool that allows you to change the partitioning of your hard disks – for example: preparatory to defining file systems. FDISK has its limitations. You can’t move applications from one partition to another without uninstalling and reinstalling the software.
Mount your new Drive to VPS Server
Steps to attach and mount your drive:
Execute the following command:
- login to your server using SSH as root administrator privileges.
- First Let us 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
- Here we are adding 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 execute 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):
- Then enter n to add a new partition.
n
- Now you have to run mkfs -t ext3 /dev/sdb then confirm the message.
mkfs -t ext3 /dev/sdb
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
- Create a directory with name and map the name to the device in the example “DIRECTORY” is the name what we need , execute these commands:
mkdir /DIRECTORY
e2label /dev/sdb /DIRECTORY
echo “LABEL=/DIRECTORY /DIRECTORY ext3 defaults 1 2” >> /etc/fstab
mount LABEL=/DIRECTORY /DIRECTORY
- Run the following command to test your drive listed and usable
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
- You can access your new drive by run cd /DIRECTORY and use your new drive.