感谢支持
我们一直在努力

如何不用重启在CentOS 7/ RHEL 7虚拟机中添加一块新硬盘

通常在你在虚拟机中添加一块新硬盘时,你可能会看到新硬盘没有自动加载。这是因为连接到硬盘的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

更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

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

赞(0) 打赏
转载请注明出处:服务器评测 » 如何不用重启在CentOS 7/ RHEL 7虚拟机中添加一块新硬盘
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏