CentOS在不重啟的情況下為其虛擬機器添加新硬碟的教程

來源:互聯網
上載者:User

   通常在你在虛擬機器中添加一塊新硬碟時,你可能會看到新硬碟沒有自動載入。這是因為串連到硬碟的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

  Device Boot Start End Blocks Id System

  /dev/sda1 * 2048 1026047 512000 83 Linux

  /dev/sda2 1026048 62914559 30944256 8e Linux 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

  Device Boot Start End Blocks Id System

  /dev/sda1 * 2048 1026047 512000 83 Linux

  /dev/sda2 1026048 62914559 30944256 8e Linux 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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.