2021-05-12 14:32:11
如何不用重新啟動在CentOS 7/ RHEL 7虛擬機器中新增一塊新硬碟
2020-06-16 18:03:36
通常在你在虛擬機器中新增一塊新硬碟時,你可能會看到新硬碟沒有自動載入。這是因為連線到硬碟的SCSI匯流排需要重新掃描來使得新硬碟可見。這裡有一個簡單的命令來重新掃描SCSI匯流排和SCSI裝置。下面這幾步在CentOS 7 和RHEL 7 中測試過。
-
在ESXi或者vCenter中新增一塊新的20G硬碟:
-
顯示當前磁碟分割區:
[root@centos7 ~]# fdisk -l
Disk/dev/sda:32.2 GB,32212254720 bytes,62914560 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:0x0006b96a
DeviceBootStartEndBlocksIdSystem
/dev/sda1 *2048102604751200083Linux
/dev/sda2 102604862914559309442568eLinux LVM
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/mapper/centos-root:29.5 GB,29536288768 bytes,57688064 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@centos7 ~]# ls /sys/class/scsi_host/
host0 host1 host2
-
重新掃描SCSI匯流排來新增裝置
[root@centos7 ~]# echo "- - -">/sys/class/scsi_host/host0/scan
[root@centos7 ~]# echo "- - -">/sys/class/scsi_host/host1/scan
[root@centos7 ~]# echo "- - -">/sys/class/scsi_host/host2/scan
-
驗證磁碟和分割區並確保20GB硬碟已經新增了。在本例中,出現了下面這行 “
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
” 並且可以確認沒有重新啟動伺服器就新增了新盤:[root@centos7 ~]# fdisk -l
Disk/dev/sda:32.2 GB,32212254720 bytes,62914560 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:0x0006b96a
DeviceBootStartEndBlocksIdSystem
/dev/sda1 *2048102604751200083Linux
/dev/sda2 102604862914559309442568eLinux LVM
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/mapper/centos-root:29.5 GB,29536288768 bytes,57688064 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
本文永久更新連結地址:http://www.linuxidc.com/Linux/2015-03/115619.htm
相關文章