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

相关推荐

  • 简述Linux那些年–发展史

    Linux发展史 作者:任飞鹏          日期:2016-10-13 Linux简介: Linux同Windows一样,都是一套OS(操作系统)。Linux是一套开源的类Unix操作系统,可以免费使用和自由传播。是一个基于POSIX和UNIX的多用户、多任务、支…

    Linux干货 2016-10-19
  • 二、(3)Linux的文件与数据之:元数据

    文件的元数据 在Linux的文件系统中,数据可分为两大类:数据和元数据 数据:泛指普通文件中的实际数据 元数据:用来描述一个文件的特征的系统数据 这样抽象的描述并不能很清楚地表示元数据的定义,所以下面将借助stat命令进行举例说明: stat命令 stat – display file or file system status(用于展示文件或文…

    2018-01-11
  • man的用法

    man的使用 man命令是Linux下的帮助指令,通过man指令可以查看Linux中的指令帮助、配置文件帮助和编程帮助等信息。 语法 man(选项)(参数) 选项 -a:在所有的man帮助手册中搜索; -f:等价于whatis指令,显示给定关键字的简短描述信息; -P:指定内容时使用分页程序; -M:指定man手册搜索的路径。 参数 数字:指定从哪本man手…

    Linux干货 2018-03-04
  • N22-love cat第19周 – 基于Apache + Tomcat +2种模式实现负载均衡以及配置集群seesion服务

      基于Apache+Tomcat实现负载均衡和集群服务 一、概念     从Tomcat权威指南中的测试数据,我们不难发现,对于静态页面的数据,Tomcat的处理速度比Apache要快很多,所以为什么要整合apache虽然在处理静态页面速度上比Apache快,但是Tomcat经不起大的并发量容易死。为此,我们就需要A…

    Linux干货 2016-08-29
  • 马哥linux0726课程内容

    课堂内容笔记   使用几个符号可以使用原始命令 \,’’,绝对路径运行 这三种方法都可以使用到原始命令,不使用别名   别名-内部命令-缓存-外部命令 使用命令的优先级   man帮助具体用法 makewhatis老版本安装whatis mandb新版本安装whatis man的具体路径在/usr/share/man whati…

    Linux干货 2016-08-04
  • 第一周作业:计算机的组成及其功能

    第一周作业 主要是对应了马哥视频前两天共八节课的内容,作业一共有六道题 01.描述计算机的组成及其功能 02.按系列罗列Linux的发行版,并描述不同发行版之间的联系与区别 03.描述Linux的哲学思想,并按照自己的理解对其进行解释性描述 04.说明Linux系统上命令的使用格式;详细介绍ifconfig、echo、tty、startx、export、pw…

    2017-09-12

评论列表(1条)

  • Aleen
    Aleen 2016-07-26 08:00

    兄弟,我转账了