CentOS6/7下不關機識別新添加的scsi硬盤

1)需求說明

在虛擬機中,我們在服務器開機的狀態下添加新的磁盤或者說從存儲上映射某個LUN區域給服務器,不重啟系統的情況下,往往不能夠直接識別到磁盤,在遇到這種情況的時候,我們可以讓系統重新掃描讓服務器重新識別到磁盤。

2)處理步驟

下面看一下在系統不重啟的情況,如何讓系統認識新的磁盤,并能對其分區與格式化

1、在開機狀態下新增磁盤

2、執行下面的命令

echo "- – -" >  /sys/class/scsi_host/host0/scan

特別注意

① “- – -” 這三個-之間是有空格的

② 假如 fdisk -l 還是未發現新硬盤,則將上面命令中的host0,替換為host1,host2,….看看

我們再查看系統日志/var/log/messages,發現對SCSI設備進行了一次重新掃描,用fdisk -l也看到了新增加的磁盤了。上面的命令主要的目的就是scan the SCSI bus。


3)操作步驟

a、查看磁盤分區信息(這里我們在虛擬機中已經添加了磁盤)

[root@localhost ~]# fdisk -l
磁盤 /dev/sda:107.4 GB, 107374182400 字節,209715200 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標簽類型:dos
磁盤標識符:0x00039749
   設備 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   105883647    52428800   83  Linux
/dev/sda3       105883648   114010111     4063232   82  Linux swap / Solaris
/dev/sda4       114010112   209715199    47852544    5  Extended
/dev/sda5       114012160   134983679    10485760   83  Linux

disk-01.png

b、執行操作指令

[root@localhost ~]# cd /sys/class/scsi_host/
[root@localhost scsi_host]# ls
host0  host1  host2
[root@localhost scsi_host]# echo "- - -" >  /sys/class/scsi_host/host0/scan

c、再次查看磁盤的分區信息

[root@localhost scsi_host]# fdisk -l
磁盤 /dev/sda:107.4 GB, 107374182400 字節,209715200 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標簽類型:dos
磁盤標識符:0x00039749
   設備 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   105883647    52428800   83  Linux
/dev/sda3       105883648   114010111     4063232   82  Linux swap / Solaris
/dev/sda4       114010112   209715199    47852544    5  Extended
/dev/sda5       114012160   134983679    10485760   83  Linux
磁盤 /dev/sdb:21.5 GB, 21474836480 字節,41943040 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤 /dev/sdc:21.5 GB, 21474836480 字節,41943040 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤 /dev/sdd:21.5 GB, 21474836480 字節,41943040 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤 /dev/sde:21.5 GB, 21474836480 字節,41943040 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節

經過對比,可以發現,磁盤已經被識別了!

d、查看日志相關的信息

[root@localhost scsi_host]# tail -20 /var/log/messages
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Write Protect is off
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Cache data unavailable
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Assuming drive cache: write through
Jul 18 15:49:19 localhost kernel: sdb: unknown partition table
Jul 18 15:49:19 localhost kernel: sd 0:0:2:0: [sdc] Attached SCSI disk
Jul 18 15:49:19 localhost kernel: scsi target0:0:4: Domain Validation skipping write tests
Jul 18 15:49:19 localhost kernel: scsi target0:0:4: Ending Domain Validation
Jul 18 15:49:19 localhost kernel: scsi target0:0:4: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 15:49:19 localhost kernel: sd 0:0:1:0: [sdb] Attached SCSI disk
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Write Protect is off
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Cache data unavailable
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Assuming drive cache: write through
Jul 18 15:49:19 localhost kernel: sdd: unknown partition table
Jul 18 15:49:19 localhost kernel: sde: unknown partition table
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Attached SCSI disk
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Attached SCSI disk
Jul 18 15:50:01 localhost systemd: Starting Session 132 of user root.
Jul 18 15:50:01 localhost systemd: Started Session 132 of user root.
[root@localhost scsi_host]# tail -40 /var/log/messages
Jul 18 15:49:18 localhost kernel: sd 0:0:1:0: [sdb] Write Protect is off
Jul 18 15:49:18 localhost kernel: sd 0:0:1:0: [sdb] Cache data unavailable
Jul 18 15:49:18 localhost kernel: sd 0:0:1:0: [sdb] Assuming drive cache: write through
Jul 18 15:49:18 localhost kernel: scsi 0:0:2:0: Direct-Access     VMware,  VMware Virtual S 1.0  PQ: 0 ANSI: 2
Jul 18 15:49:18 localhost kernel: scsi target0:0:2: Beginning Domain Validation
Jul 18 15:49:19 localhost kernel: scsi target0:0:2: Domain Validation skipping write tests
Jul 18 15:49:19 localhost kernel: scsi target0:0:2: Ending Domain Validation
Jul 18 15:49:19 localhost kernel: scsi target0:0:2: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 15:49:19 localhost kernel: scsi 0:0:3:0: Direct-Access     VMware,  VMware Virtual S 1.0  PQ: 0 ANSI: 2
Jul 18 15:49:19 localhost kernel: scsi target0:0:3: Beginning Domain Validation
Jul 18 15:49:19 localhost kernel: scsi target0:0:3: Domain Validation skipping write tests
Jul 18 15:49:19 localhost kernel: scsi target0:0:3: Ending Domain Validation
Jul 18 15:49:19 localhost kernel: scsi target0:0:3: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 15:49:19 localhost kernel: scsi 0:0:4:0: Direct-Access     VMware,  VMware Virtual S 1.0  PQ: 0 ANSI: 2
Jul 18 15:49:19 localhost kernel: scsi target0:0:4: Beginning Domain Validation
Jul 18 15:49:19 localhost kernel: sd 0:0:2:0: [sdc] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
Jul 18 15:49:19 localhost kernel: sd 0:0:2:0: [sdc] Write Protect is off
Jul 18 15:49:19 localhost kernel: sd 0:0:2:0: [sdc] Cache data unavailable
Jul 18 15:49:19 localhost kernel: sd 0:0:2:0: [sdc] Assuming drive cache: write through
Jul 18 15:49:19 localhost kernel: sdc: unknown partition table
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Write Protect is off
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Cache data unavailable
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Assuming drive cache: write through
Jul 18 15:49:19 localhost kernel: sdb: unknown partition table
Jul 18 15:49:19 localhost kernel: sd 0:0:2:0: [sdc] Attached SCSI disk
Jul 18 15:49:19 localhost kernel: scsi target0:0:4: Domain Validation skipping write tests
Jul 18 15:49:19 localhost kernel: scsi target0:0:4: Ending Domain Validation
Jul 18 15:49:19 localhost kernel: scsi target0:0:4: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 15:49:19 localhost kernel: sd 0:0:1:0: [sdb] Attached SCSI disk
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Write Protect is off
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Cache data unavailable
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Assuming drive cache: write through
Jul 18 15:49:19 localhost kernel: sdd: unknown partition table
Jul 18 15:49:19 localhost kernel: sde: unknown partition table
Jul 18 15:49:19 localhost kernel: sd 0:0:3:0: [sdd] Attached SCSI disk
Jul 18 15:49:19 localhost kernel: sd 0:0:4:0: [sde] Attached SCSI disk
Jul 18 15:50:01 localhost systemd: Starting Session 132 of user root.
Jul 18 15:50:01 localhost systemd: Started Session 132 of user root.

原創文章,作者:Net21-冰凍vs西瓜,如若轉載,請注明出處:http://www.www58058.com/24759

(4)
Net21-冰凍vs西瓜Net21-冰凍vs西瓜
上一篇 2016-07-22 10:10
下一篇 2016-07-22 10:10

相關推薦

  • 第二周練習與作業

    第二周作業 1、Linux上的文件管理類命令有哪些,其常用的使用方法及其相關示例演示          文件管理類命令:cp,mv,rm cp: 源文件;目標文件          [root@loc…

    Linux干貨 2017-08-09
  • 馬哥教育網絡班第21期+第一周課程作業

    一、 描述計算機的組成及其功能     計算機主機包括:運算器,控制器,存儲器,輸入設備,輸出設備 1、運算器:功能是對程序規定的控制信息進行解釋,根據其要求進行控制,調度程序、數據、地址,協調計算機各部分工作及內存與外設的訪問等。 2、控制器:運算器的功能是對數據進行各種算術運算和邏輯運算,即對從控制器取來…

    Linux干貨 2016-07-12
  • 搭建簡單的ftp和http

    搭建簡單的ftp和http 我們主要嘗試光盤和編譯兩種方式安裝 ftp 首先我們先安裝ftp ftp可以用來做文件傳輸,也可以搭建ftp作為我我們的網絡yum源 首先我們要先把鏡像連接到我們的Linux中 進入/etc/yum.repos.d/創建一個.repo結尾的文件,在里面配置自己的yum源 [base] baseurl=file:///misc/cd…

    2017-06-15
  • 分布式文件系統之MogileFS

    MogileFS是一個開源的分布式文件存儲系統,由LiveJournal旗下的Danga Interactive公司開發。Danga團隊開發了包括 Memcached、MogileFS、Perlbal 等多個知名的開源項目。目前使用MogileFS 的公司非常多,如日本排名先前的幾個互聯公司及國內的yupoo(又拍)、digg、豆瓣、1號店、大眾點評、搜狗和…

    Linux干貨 2017-06-16
  • 三劍客之一sed命令

    sed sed ‘2p’ /etc/passwd  打印paswwd的第二行 這樣執行結果看能看出第二行顯示兩次 sed -n ‘2p’ /etc/passwd -n 執行后 會取出當前行顯示. n是關閉打印  例如[root@cent7 ~]#ifconfig ens33|sed -n &…

    Linux干貨 2017-08-13
  • 用戶和組的相關配置文件

      用戶,是計算機識別使用者身份的一種唯一使用標識。 而現實生活中為了方便人類記憶使用等,用戶名往往是用便于人類識別的語言來記錄的。但事實上計算機并不對人類語言敏感,所以有必要把人類語言跟機器語言對應上。于是,linux給每一個創建用戶提供了一個UID。當使用用戶名登錄時,系統換自動對應UID來識別該用戶身份。 而用戶名與UID的對應信息就儲存在一…

    Linux干貨 2016-10-23

評論列表(1條)

  • Aleen
    Aleen 2016-07-26 08:00

    兄弟,我轉賬了

欧美性久久久久