CentOS a tutorial on adding a new hard disk to its virtual machine without rebooting

Source: Internet
Author: User
Tags centos

Usually when you add a new hard drive to the virtual machine, you may see that the new hard drive is not loaded automatically. This is because the SCSI bus connected to the hard disk needs to be rescan to make the new hard drive visible. Here is a simple command to rescan the SCSI bus and SCSI devices. The following steps have been tested in CentOS 7 and Rhel 7.

Add a new 20G hard drive to ESXi or vcenter:

Displays the current disk partition:

The code is as follows:

[Root@centos7 ~]# Fdisk-l

disk/dev/sda:32.2 GB, 32212254720 bytes, 62914560 sectors

Units = sectors of 1 * the bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk label Type:dos

Disk identifier:0x0006b96a

Device Boot Start End Blocks Id System

/DEV/SDA1 * 2048 1026047 512000 Linux

/dev/sda2 1026048 62914559 30944256 8e Linux LVM

disk/dev/mapper/centos-swap:2147 MB, 2147483648 bytes, 4194304 sectors

Units = sectors of 1 * the bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

disk/dev/mapper/centos-root:29.5 GB, 29536288768 bytes, 57688064 sectors

Units = sectors of 1 * the bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Determine the host bus number

The code is as follows:

[Root@centos7 ~]# ls/sys/class/scsi_host/

Host0 host1 Host2

Re-scan the SCSI bus to add devices

The code is as follows:

[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 disks and partitions and make sure that the 20GB hard drive has been added. In this example, the following line, "disk/dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors", is available and confirms that a new disk has been added without restarting the server:

The code is as follows:

[Root@centos7 ~]# Fdisk-l

disk/dev/sda:32.2 GB, 32212254720 bytes, 62914560 sectors

Units = sectors of 1 * the bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk label Type:dos

Disk identifier:0x0006b96a

Device Boot Start End Blocks Id System

/DEV/SDA1 * 2048 1026047 512000 Linux

/dev/sda2 1026048 62914559 30944256 8e Linux LVM

disk/dev/mapper/centos-swap:2147 MB, 2147483648 bytes, 4194304 sectors

Units = sectors of 1 * the bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

disk/dev/mapper/centos-root:29.5 GB, 29536288768 bytes, 57688064 sectors

Units = sectors of 1 * the bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

disk/dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1 * the bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.