Thursday 2 April 2015

Linux: Add a New HDD to a VM Without Rebooting

While working at a client site I needed to add a new hard drive to a Centos ESXi VM without rebooting the server.

After adding the harddrive in ESXi for the VM ran ls /dev/sd* but it did not show the new hard drive.

I found THIS site where I used the following commands to add the hard drive without rebooting.

echo "- - -" > /sys/class/scsi_host/host0/scan
fdisk -l
This showed:
[root@centos-teste ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0001b288

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    83886079    41430016   8e  Linux LVM

Disk /dev/mapper/centos-root: 40.2 GB, 40227569664 bytes, 78569472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
I then ran ls /dev/sd* again and it showed the new drive as sdb.

***EDIT***

On one of my servers the new disk wasnt showing up.

I ran the command below which I got from THIS site:

ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
This found the hard drive.

No comments:

Post a Comment