How to Add a New Hard Disk Without Rebooting VM Guest on RHEL 6/CentOS 6

In web server administration, there are instances where you might need to increase the storage capacity of your Linux RHEL 6 server. This could be due to a variety of reasons, such as the need for more space to store data or to improve the performance of your server. However, rebooting the server to add a new hard disk is not always feasible, especially in a production environment.

This tutorial will guide you on how to add a new hard disk to your server without having to reboot it. This process is particularly applicable if your server is running on a VMware ESXi machine. The steps outlined here have been tested on Red Hat Enterprise Linux 6 (RHEL 6), but they may also work on RHEL 5 and CentOS 5.

Adding a New Hard Disk Without Rebooting

The first step in this process is to add a new disk to the VM Guest through VMware vCenter Server/VMware vSphere. In this tutorial, we will be adding a 12 GB space to the second hard disk space, which is on the raw device /dev/sdb.

Once you’ve added the new disk, the next step is to find the scsi_host value. This can be done using the following command:

[root@rhel6 ~]# ls /sys/class/scsi_host
host0  host1  host2

In this RHEL 6 server, there are three scsi_host values: host0, host1, and host2.

See also  How to Install and Configure NTP Server On CentOS 6.2

The third step is to rescan the SCSI Bus to add the SCSI Device without rebooting the VM. This can be done using the following commands:

[root@rhel6 host0]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@rhel6 host0]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@rhel6 host0]# echo "- - -" > /sys/class/scsi_host/host2/scan

The final step is to check the new hard disk /dev/sdb. This can be done using the following command:

<root@rhel6 ~># fdisk -l

After running this command, you should be able tosee the details of the new hard disk /dev/sdb, along with other disks on your server.

Example:

[root@rhel6 ~]# fdisk -l

Disk /dev/sda: 12.9 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 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: 0x0000690f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1567    12069888   8e  Linux LVM

Disk /dev/dm-0: 10.2 GB, 10242490368 bytes
255 heads, 63 sectors/track, 1245 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/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 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/dm-1 doesn't contain a valid partition table

Disk /dev/sdb: 12.9 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 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/sdb doesn't contain a valid partition table

Commands Mentioned

  • ls /sys/class/scsi_host – This command is used to list the scsi_host values on your server.
  • echo “- – -” > /sys/class/scsi_host/hostX/scan – This command is used to rescan the SCSI Bus to add a SCSI Device without rebooting the VM. Replace ‘X’ with the number of the host.
  • fdisk -l – This command is used to list the details of the disks on your server.
See also  Install MySQL, Apache and PHP on CentOS 6.5

Conclusion

Adding a new hard disk to your Linux RHEL 6 server without having to reboot it is a valuable skill for any web server administrator. It allows you to increase your server’s storage capacity without causing any downtime, which is crucial in a production environment. By following the steps outlined in this tutorial, you can easily add a new hard disk to your server.

Remember, the type of hosting you choose, be it a dedicated, or VPS server, can also influence how you manage your server. Therefore, always ensure to choose the hosting type that best suits your needs.

With the knowledge gained from this tutorial, you are now better equipped to manage your server effectively and efficiently. Keep exploring and learning, and you’ll become a web server administration expert in no time.

See also  Configure Network Time Protocol (NTP) on CentOS 6.3

FAQs

  1. What is the purpose of adding a new hard disk without rebooting?

    Adding a new hard disk without rebooting is essential in a production environment where downtime can lead to significant losses. It allows for increased storage space without disrupting the server’s operations.

  2. What does the command ‘ls /sys/class/scsi_host’ do?

    The command ‘ls /sys/class/scsi_host’ is used to list the scsi_host values on your server. These values are essential when rescanning the SCSI Bus to add a SCSI Device.

  3. What does the command ‘fdisk -l’ do?

    The command ‘fdisk -l’ is used to list the details of the disks on your server. It’s useful for verifying the addition of the new hard disk.

  4. Can this process be used on other Linux distributions?

    This process has been tested on Red Hat Enterprise Linux 6 (RHEL 6). It may also work on RHEL 5 and CentOS 5, but it’s always recommended to refer to the specific documentation of your Linux distribution.

  5. What is the significance of the VMware ESXi machine in this process?

    The VMware ESXi machine is the virtualization server in this context. It’s where the VM Guest, to which the new hard disk is being added, is hosted.

Comments

Leave a Reply

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