I'm using Oracle Linux 7.6, which is a distribution based on RHEL 7.6. The following testing should be the same on RHEL 7.6 or other RHEL 7.6 based distributions.
I'm running the Oracle Linux 7.6 server in VMware Workstation on Windows 10. What I'm trying to do is to add a disk to the Linux guest virtual machine without rebooting the Linux server. I googled around and found this page: https://rahsupport.wordpress.com/2017/08/10/vmware-add-disk-to-linux-without-rebooting-the-vm/. Basically, what it does is:
- Add the disk from VMware Workstation to the Linux VM
- Go to
/sys/class/scsi_host/ - Run
echo '- - -' > host1/scan - Then by running
fdisk -l, you can see the newly added disk
I tested it on in my environment. There are three such host directories and each of them has a scan file in it:
root:[/sys/class/scsi_host]# ls -la total 0 drwxr-xr-x. 2 root root 0 Aug 24 22:49 . drwxr-xr-x. 54 root root 0 Aug 24 22:49 .. lrwxrwxrwx. 1 root root 0 Aug 24 22:49 host0 -> ../../devices/pci0000:00/0000:00:07.1/ata1/host0/scsi_host/host0 lrwxrwxrwx. 1 root root 0 Aug 24 22:49 host1 -> ../../devices/pci0000:00/0000:00:07.1/ata2/host1/scsi_host/host1 lrwxrwxrwx. 1 root root 0 Aug 24 22:49 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2 root:[/sys/class/scsi_host]# root:[/sys/class/scsi_host]# ls -la */scan --w-------. 1 root root 4096 Aug 24 22:50 host0/scan --w-------. 1 root root 4096 Aug 24 22:50 host1/scan --w-------. 1 root root 4096 Aug 24 22:50 host2/scan root:[/sys/class/scsi_host]# Originally, the Linux server can't recognize the disk:
root:[/sys/class/scsi_host]# fdisk -l Disk /dev/sda: 1099.5 GB, 1099511627776 bytes, 2147483648 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: 0x000d3e78 Device Boot Start End Blocks Id System /dev/sda1 * 2048 976895 487424 83 Linux /dev/sda2 976896 2059401215 1029212160 83 Linux /dev/sda3 2059401216 2101344255 20971520 83 Linux /dev/sda4 2101344256 2147483647 23069696 5 Extended /dev/sda5 2101348352 2143289343 20970496 83 Linux /dev/sda6 2143291392 2147483647 2096128 82 Linux swap / Solaris But when I run echo '- - -' > host0/scan, the disk showed up:
root:[/sys/class/scsi_host]# echo '- - -' > host0/scan root:[/sys/class/scsi_host]# fdisk -l Disk /dev/sda: 1099.5 GB, 1099511627776 bytes, 2147483648 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: 0x000d3e78 Device Boot Start End Blocks Id System /dev/sda1 * 2048 976895 487424 83 Linux /dev/sda2 976896 2059401215 1029212160 83 Linux /dev/sda3 2059401216 2101344255 20971520 83 Linux /dev/sda4 2101344256 2147483647 23069696 5 Extended /dev/sda5 2101348352 2143289343 20970496 83 Linux /dev/sda6 2143291392 2147483647 2096128 82 Linux swap / Solaris 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 root:[/sys/class/scsi_host]# I reverted my Linux VM to its original state to test again. This time it showed that echo '- - -' > host1/scan doesn't work, but echo '- - -' > host2/scan works.
root:[/sys/class/scsi_host]# fdisk -l Disk /dev/sda: 1099.5 GB, 1099511627776 bytes, 2147483648 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: 0x000d3e78 Device Boot Start End Blocks Id System /dev/sda1 * 2048 976895 487424 83 Linux /dev/sda2 976896 2059401215 1029212160 83 Linux /dev/sda3 2059401216 2101344255 20971520 83 Linux /dev/sda4 2101344256 2147483647 23069696 5 Extended /dev/sda5 2101348352 2143289343 20970496 83 Linux /dev/sda6 2143291392 2147483647 2096128 82 Linux swap / Solaris root:[/sys/class/scsi_host]# echo '- - -' > host1/scan root:[/sys/class/scsi_host]# fdisk -l Disk /dev/sda: 1099.5 GB, 1099511627776 bytes, 2147483648 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: 0x000d3e78 Device Boot Start End Blocks Id System /dev/sda1 * 2048 976895 487424 83 Linux /dev/sda2 976896 2059401215 1029212160 83 Linux /dev/sda3 2059401216 2101344255 20971520 83 Linux /dev/sda4 2101344256 2147483647 23069696 5 Extended /dev/sda5 2101348352 2143289343 20970496 83 Linux /dev/sda6 2143291392 2147483647 2096128 82 Linux swap / Solaris root:[/sys/class/scsi_host]# echo '- - -' > host2/scan root:[/sys/class/scsi_host]# fdisk -l Disk /dev/sda: 1099.5 GB, 1099511627776 bytes, 2147483648 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: 0x000d3e78 Device Boot Start End Blocks Id System /dev/sda1 * 2048 976895 487424 83 Linux /dev/sda2 976896 2059401215 1029212160 83 Linux /dev/sda3 2059401216 2101344255 20971520 83 Linux /dev/sda4 2101344256 2147483647 23069696 5 Extended /dev/sda5 2101348352 2143289343 20970496 83 Linux /dev/sda6 2143291392 2147483647 2096128 82 Linux swap / Solaris 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 root:[/sys/class/scsi_host]# My question is, what's these host directories? Why echo '- - -' > host0/scan and echo '- - -' > host2/scan will make Linux server recognize the disk, but echo '- - -' > host1/scan can't?
Btw, I'm pretty new in Linux and still learning it.