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.178linux.com/24759

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

相关推荐

  • AWK实现求和、平均数、最小值、最大值

    1.简单的按列求和]$ cat test123125126]$ awk ‘{sum += $1}END {print sum}’ test2.对符合某些条件的行,按列求和]$ cat  testaaa 123bbb 125aaa 123aaa 123ccc 126对文件test中 第一列为aaa的行求和]$ awk &#82…

    Linux干货 2017-04-09
  • 马哥教育络班22期-第1周博客作业

    第一周博客作业 1 描述计算机的组成及其功能 计算机由硬件和软件两大部分组成: 1.1 计算机硬件组成与功能 计算机硬件由运算器、控制器、存储器、输入设备、输出设备五大部分组成。 1.1.1 运算器 算术逻辑部件ALU,执行算术运算和逻辑运算。例如:加减乘除,移位,取模。运算器的核心是加法器。 1.1.2 控制器 控制器是计算机的指挥中心,它的主要作用是按照…

    Linux干货 2016-08-14
  • 网络服务之Apache

      互联网这个历史已经不算很短了,它大大方便了人类获取信息,开阔了人类的眼界,使得让这个世界变得小了起来,人与人之间的距离感也不会存在了,娱乐也更加丰富,听音乐、看电影等等这一系列,都能从网上进行,这些功能,都是由www服务器来提供服务,在Linux中,提供网络的服务器有很多种,那么今天我们就讲一个比较老牌,且依然能存活的服务器“阿帕奇”…

    Linux干货 2017-01-13
  • 推荐-运维学习笔记-Puppet应用配置的工作原理

    背景知识 Puppet的核心功能是配置管理。一般来说,用户在master上集中做配置,同时,被管理节点上的agent会定期从master上下载配置数据,再应用(apply)到本地,从而使管理节点的状态(用户,组,文件,安装包,服务等的设置和运行状态)与masters上定义的保持一致。 有时,出于测试的目的,并不希望真的应用配置,那么就需要执行puppet a…

    2016-06-01
  • 分区管理

    分区管理     一.磁盘分类 机械硬盘(HDD):该硬盘是传统的普通硬盘。主要有:盘片,磁头,盘片转轴及控制电机,磁头控制器,数据转换器,接口,缓存等几个部分组成  固态硬盘(SSD):用固态电子存储芯片阵列而制成的硬盘,由控制单元和存储单元组成。 二.特点 1.     &n…

    Linux干货 2017-08-20

评论列表(1条)

  • Aleen
    Aleen 2016-07-26 08:00

    兄弟,我转账了