How To Add a Disk To a RHEL/CentOS/Fedora Server

Run these commands (with sudo in front of them or, less preferably, as the root user):
1) fdisk -l > /tmp/saveOfOutput   # This creates a baseline for step #3 below.

2)  With a physical server:  Turn off the server and connect the physical disk, and turn it back on.
With a virtual server:  Add the disk in vSphere

3)  As root, issue these commands:
fdisk -l #find added device in the output of this command
#If it is not seen, reboot.  You can compare the output with the /tmp/saveOfOutput file above.
# In this example, we'll assume that the newly added disk is called /dev/sdc

4)  fdisk -l /dev/sdc
5)  pvcreate /dev/sdc
6)  vgcreate vgpoolci /dev/sdc    #Replace "vgpoolci" with an arbitrary name throughout these directions.
7)  lvcreate -L 229.8G -n lvci vgpoolci   
#229.8G should be replaced with the desired size of the logical volume. 
#Replace "lvci" with an arbitrary name of a logical volume throughout these directions.  
8)  mkfs -t ext3 /dev/vgpoolci/lvci
9)  mkdir /newdirname     # Replace newdirname with the desired name of a new directory throughout these directions. 
10)  mount -t ext3 /dev/vgpoolci/lvci /newdirname

To have the file system mount every time (after rebooting), you can modify the /etc/fstab.  However, mistakes in this file can prevent the system from booting again.  To recover the system, you may need to log into maintenance mode.  If the file system is read only, please see this link.  If you want to be conservative and avoid modifying the /etc/fstab, do these steps instead (to have the new disk and file system mount automatically):
i. cd /etc/profile.d/
ii.  vi custom.sh
iii.  Enter these two lines of text and save the changes (change "/dev/vgpoolci/lvci' to what you used in step #8):
#!/bin/bash
mount -t ext3 /dev/vgpoolci/lvci /newdirname

Leave a comment

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