How can I add a new hard disk to the CentOS7 virtual machine without restarting?

Source: Internet
Author: User
When you add a new hard disk to a VM, you may see that the new hard disk is not loaded automatically. This is because the SCSI bus connected to the hard disk needs to be scanned again to make the new hard disk visible. Here is a simple command to re-scan the SCSI bus and SCSI devices. The following steps have been tested in CentOS7 and RHEL7. Add a new 20 GB hard disk in ESXi or vCenter: displays the current disk partition: [root @ c

When you add a new hard disk to a VM, you may see that the new hard disk is not loaded automatically. This is because the SCSI bus connected to the hard disk needs to be scanned again to make the new hard disk visible. Here is a simple command to re-scan the SCSI bus and SCSI devices. The following steps have been tested in CentOS 7 and RHEL 7.

Add a new 20 GB hard disk in ESXi or vCenter:

 

Display the current disk partition:

[root@centos7 ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0006b96a   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048     1026047      512000   83  Linux/dev/sda2         1026048    62914559    30944256   8e  Linux LVMDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes

Confirm host bus number

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

Re-scan the SCSI bus to add devices

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

Verify the disk and partition and make sure that the 20 GB hard disk is added. In this example, the following line "Disk/dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors" appears and you can confirm that a new Disk is added without restarting the server:

[root@centos7 ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0006b96a   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048     1026047      512000   83  Linux/dev/sda2         1026048    62914559    30944256   8e  Linux LVMDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.