在虚拟机Vmware中我们有时候需要添加新的虚拟磁盘或给已有虚拟磁盘扩容(expand),在新增磁盘或磁盘扩容后,Linux系统并不能马上识别到。也就是说你看不到磁盘空间变化(使用fdisk -l查看),这时我们可以通过重启系统(reboot)解决这个问题,但是很多时候,我们并不想在存储扩容时重启系统,因为这样会影响到现有的业务系统。那么为什么新增磁盘或磁盘扩容后,Linux系统识别不到呢?这个是因为连接存储设备的SCSI总线需要重新扫描,才能识别到这些新的存储设备。下面测试一下在添加新的虚拟磁盘或给已有虚拟磁盘扩容如何操作才能不用重启系统

1:Vmware虚拟磁盘扩容

如下所示,Vmware虚拟磁盘扩容后,使用fdisk -l看不到任何变化

[root@localhost ~]# fdisk -l

 

Disk /dev/sda: 171.7 GB, 171798691840 bytes

255 heads, 63 sectors/track, 20886 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14       15665   125724690   8e  Linux LVM

/dev/sda3           15666       15795     1044225   83  Linux

/dev/sda4           15796       20886    40893457+  83  Linux

 

Disk /dev/dm-0: 126.6 GB, 126600871936 bytes

255 heads, 63 sectors/track, 15391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/dm-0 doesn't contain a valid partition table

 

Disk /dev/dm-1: 2113 MB, 2113929216 bytes

255 heads, 63 sectors/track, 257 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/dm-1 doesn't contain a valid partition table

方法1:echo 1 > /sys/class/scsi_device/device/rescan

[root@localhost ~]# cd /sys/class/scsi_disk/

[root@localhost scsi_disk]# ls

0:0:0:0

[root@localhost scsi_disk]# cd 0\:0\:0\:0/

[root@localhost 0:0:0:0]# echo '1' > device/rescan 

[root@localhost 0:0:0:0]# fdisk -l

 

Disk /dev/sda: 173.9 GB, 173946175488 bytes

255 heads, 63 sectors/track, 21147 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14       15665   125724690   8e  Linux LVM

/dev/sda3           15666       15795     1044225   83  Linux

/dev/sda4           15796       20886    40893457+  83  Linux

 

Disk /dev/dm-0: 126.6 GB, 126600871936 bytes

255 heads, 63 sectors/track, 15391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/dm-0 doesn't contain a valid partition table

 

Disk /dev/dm-1: 2113 MB, 2113929216 bytes

255 heads, 63 sectors/track, 257 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/dm-1 doesn't contain a valid partition table

方法2:重新扫描特定的 SCSI Device

echo 1 > /sys/block/$DEVICE/device/rescan 用sda, sdb, sdc等替换$DEVICE

[root@localhost ~]# echo 1 > /sys/block/sda/device/rescan

2:Vmware新增虚拟磁盘

首先找到您的主机总线编号

[root@localhost ~]# grep mpt /sys/class/scsi_host/host?/proc_name

 

/sys/class/scsi_host/host0/proc_name:mptspi

使用下面命令扫描SCSI总线

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

参考资料:

http://thornelabs.net/2012/08/22/linux-rescan-scsi-bus.html

最新文章

  1. 切分 Tomcat 的 catalina.out 文件,解决日志文件过大的问题
  2. Solr部署到Tomcat
  3. .net使用mvc模式开发web应用 模型与视图间的数据处理
  4. salesforce 零基础开发入门学习(十三)salesforce中JSON的使用
  5. Recovery和Charger模式下屏幕旋转180度
  6. mui记录
  7. [转]pycharm 2016 注册码
  8. Windows2003屏蔽IP
  9. System.Rtti.TRttiObject.GetAttributes 简例
  10. configparser
  11. C#编程规范
  12. jQuery、Ajax分页
  13. 关于非现场审计软件的一些介绍(ACL、IEDA、Teammate)
  14. oracle nvl2函数
  15. 【Python实战】使用Python连接Teradata数据库???未完成
  16. Jmeter名词注解
  17. esay-ui学习笔记(一)
  18. 每帧创建一个item
  19. curl: (6) Could not resolve host: www.baidu.com;
  20. python模块之psutil详解

热门文章

  1. swift 中指针的使用UnsafeMutablePointer
  2. DotNet隐藏敏感信息操作方法
  3. Oracle数据库的SQL分页模板
  4. 【Python实战】Pandas:让你像写SQL一样做数据分析(二)
  5. 加入一个线程:join
  6. C#使用Graphics画圆写字
  7. string转byte[]
  8. asp.net 301重定向代码
  9. (转)内置系统账户:Local system/Network service/Local Service 区别
  10. 解决EP拒绝访问注册表Global键的的问题