Today i was adding some disk on virtual linux Guest machine. But i found it’s not showing on machine. So we have to reboot to rescan it again. But there is one way through which could rescan linux machine and new disk will appear on machine.

I was working for Virtual machine Guest on Ubuntu 16.04.2. So I added it with virsh console.In below commands we can see that we added three disk in srv6 virtual machine.

Adding of Disk

virsh # attach-disk srv6 /data/vmware_images/CentOS6/Vdisk1 sda --type disk
Disk attached successfully

virsh # attach-disk srv6 /data/vmware_images/CentOS6/Vdisk2 sdb --type disk
Disk attached successfully

virsh # attach-disk srv6 /data/vmware_images/CentOS6/Vdisk3 sdc --type disk
Disk attached successfully

Rescan of Disk

But when we login on machine and try for those disk. i found there were no disk on machine. So I used below command for rescan disk.

echo "- - -" > /sys/class/scsi_host/host1/scan

we need to check “/sys/class/scsi_host/host” directory that need to rescan, in our case host2 need to rescan, below output for same.

# echo "- - -" > /sys/class/scsi_host/host   
host0/ host1/ host2/ 
# echo "- - -" > /sys/class/scsi_host/host0/scan 
ata1: soft resetting link
ata1: EH complete
# echo "- - -" > /sys/class/scsi_host/host1/scan 
ata2: soft resetting link
ata2: EH complete
# echo "- - -" > /sys/class/scsi_host/host2/scan
scsi 2:0:0:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
scsi target2:0:0: tagged command queuing enabled, command queue depth 16.
scsi target2:0:0: Beginning Domain Validation
scsi target2:0:0: Domain Validation skipping write tests
scsi target2:0:0: Ending Domain Validation
scsi 2:0:1:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
scsi target2:0:1: tagged command queuing enabled, command queue depth 16.
scsi target2:0:1: Beginning Domain Validation
scsi target2:0:1: Domain Validation skipping write tests
scsi target2:0:1: Ending Domain Validation
scsi 2:0:2:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
scsi target2:0:2: tagged command queuing enabled, command queue depth 16.
scsi target2:0:2: Beginning Domain Validation
scsi target2:0:2: Domain Validation skipping write tests
scsi target2:0:2: Ending Domain Validation
sd 2:0:0:0: [sda] 4194304 512-byte logical blocks: (2.14 GB/2.00 GiB)
sd 2:0:1:0: [sdb] 4194304 512-byte logical blocks: (2.14 GB/2.00 GiB)
sd 2:0:0:0: [sda] Write Protect is off
sd 2:0:1:0: [sdb] Write Protect is off
sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 2:0:2:0: [sdc] 4194304 512-byte logical blocks: (2.14 GB/2.00 GiB)
sd 2:0:1:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 2:0:2:0: [sdc] Write Protect is off
 sda:
 sdb: unknown partition table
 unknown partition table
sd 2:0:2:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 2:0:1:0: [sdb] Attached SCSI disk
sd 2:0:0:0: [sda] Attached SCSI disk
 sdc: unknown partition table
sd 2:0:2:0: [sdc] Attached SCSI disk
sd 2:0:0:0: Attached scsi generic sg0 type 0
sd 2:0:1:0: Attached scsi generic sg1 type 0
sd 2:0:2:0: Attached scsi generic sg2 type 0

We can see write protected off on new disk, but we can easily able to write, partition and work on these new disk.