首頁 > 軟體

如何不用重新啟動在CentOS 7/ RHEL 7虛擬機器中新增一塊新硬碟

2020-06-16 18:03:36

通常在你在虛擬機器中新增一塊新硬碟時,你可能會看到新硬碟沒有自動載入。這是因為連線到硬碟的SCSI匯流排需要重新掃描來使得新硬碟可見。這裡有一個簡單的命令來重新掃描SCSI匯流排和SCSI裝置。下面這幾步在CentOS 7 和RHEL 7 中測試過。

  1. 在ESXi或者vCenter中新增一塊新的20G硬碟:

  2. 顯示當前磁碟分割區:

    1. [root@centos7 ~]# fdisk -l

    1. Disk/dev/sda:32.2 GB,32212254720 bytes,62914560 sectors
    2. Units= sectors of 1*512=512 bytes
    3. Sector size (logical/physical):512 bytes /512 bytes
    4. I/O size (minimum/optimal):512 bytes /512 bytes
    5. Disk label type: dos
    6. Disk identifier:0x0006b96a
    7. DeviceBootStartEndBlocksIdSystem
    8. /dev/sda1 *2048102604751200083Linux
    9. /dev/sda2 102604862914559309442568eLinux LVM
    10. Disk/dev/mapper/centos-swap:2147 MB,2147483648 bytes,4194304 sectors
    11. Units= sectors of 1*512=512 bytes
    12. Sector size (logical/physical):512 bytes /512 bytes
    13. I/O size (minimum/optimal):512 bytes /512 bytes
    14. Disk/dev/mapper/centos-root:29.5 GB,29536288768 bytes,57688064 sectors
    15. Units= sectors of 1*512=512 bytes
    16. Sector size (logical/physical):512 bytes /512 bytes
    17. I/O size (minimum/optimal):512 bytes /512 bytes
  3. 確定主機匯流排號

    1. [root@centos7 ~]# ls /sys/class/scsi_host/
    2. host0 host1 host2
  4. 重新掃描SCSI匯流排來新增裝置

    1. [root@centos7 ~]# echo "- - -">/sys/class/scsi_host/host0/scan
    2. [root@centos7 ~]# echo "- - -">/sys/class/scsi_host/host1/scan
    3. [root@centos7 ~]# echo "- - -">/sys/class/scsi_host/host2/scan
  5. 驗證磁碟和分割區並確保20GB硬碟已經新增了。在本例中,出現了下面這行 “Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors” 並且可以確認沒有重新啟動伺服器就新增了新盤:

    1. [root@centos7 ~]# fdisk -l
    2. Disk/dev/sda:32.2 GB,32212254720 bytes,62914560 sectors
    3. Units= sectors of 1*512=512 bytes
    4. Sector size (logical/physical):512 bytes /512 bytes
    5. I/O size (minimum/optimal):512 bytes /512 bytes
    6. Disk label type: dos
    7. Disk identifier:0x0006b96a
    8. DeviceBootStartEndBlocksIdSystem
    9. /dev/sda1 *2048102604751200083Linux
    10. /dev/sda2 102604862914559309442568eLinux LVM
    11. Disk/dev/mapper/centos-swap:2147 MB,2147483648 bytes,4194304 sectors
    12. Units= sectors of 1*512=512 bytes
    13. Sector size (logical/physical):512 bytes /512 bytes
    14. I/O size (minimum/optimal):512 bytes /512 bytes
    15. Disk/dev/mapper/centos-root:29.5 GB,29536288768 bytes,57688064 sectors
    16. Units= sectors of 1*512=512 bytes
    17. Sector size (logical/physical):512 bytes /512 bytes
    18. I/O size (minimum/optimal):512 bytes /512 bytes
    19. Disk/dev/sdb:21.5 GB,21474836480 bytes,41943040 sectors
    20. Units= sectors of 1*512=512 bytes
    21. Sector size (logical/physical):512 bytes /512 bytes
    22. I/O size (minimum/optimal):512 bytes /512 bytes

本文永久更新連結地址http://www.linuxidc.com/Linux/2015-03/115619.htm


IT145.com E-mail:sddin#qq.com