Linux不重启识别新添加的磁盘

简介:

现网的一台EXSI 下的虚拟机一般在进行配置变更后都会通过重启来识别新增的配置,不过业务侧某台主机因为业务需要无法重启,想通过不重启直接识别护容上去的新磁盘。经和负责ESXi 的兄弟进行测试,发现如下方可以解决。

1、通过exsi 控制台为虚拟机新增磁盘(步骤略)

2、执行如下命令扫盘


样例:echo "- - -" >  /sys/class/scsi_host/host0/scan

[root@node /]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@node /]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@node /]# echo "- - -" > /sys/class/scsi_host/host2/scan


然后再运行fdisk -l 就能发现新添加的硬盘已经被系统识别了,查看系统日志/var/log/messages,发现对SCSI设备进行了一次重新扫描。需要注意的是echo的三个- – -号之间有空隔

以下是执行结果:

[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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        2610    20860402+  8e  Linux LVM

[root@localhost ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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        2610    20860402+  8e  Linux LVM

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table


有没有点似曾相似的感觉,在更换FC HBA卡、存储划LUN和去LUN操作时,也是echo 三个横杠到scan 文件重新描盘。只不过echo的不是host4 、hosts5 。具体参看 Linux更换HBA卡后重新扫盘指令 。

redhat6/centos6 下的硬件控制已由5时代的kudzu 换成了udev管理,大部分的硬件变动可以通过重启udev识别,如新增的网卡。不过磁盘相关略有些特殊,需要通过sys文件扫描,不过和磁盘名称相关的配置,可以通过/etc/udev下的rule文件进行管理配置。


如果是在已有的硬盘上扩展了硬盘容量,例如把硬盘从50G扩展到100G,还需要进行如下操作

[root@his ~]# ls /sys/class/scsi_device/

1:0:0:0  2:0:0:0  2:0:1:0

# echo 1 > /sys/class/scsi_device/1\:0\:0\:0/device/rescan
# echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
# echo 1 > /sys/class/scsi_device/2\:0\:1\:0/device/rescan









本文转自 qq8658868 51CTO博客,原文链接:http://blog.51cto.com/hujizhou/1864882,如需转载请自行联系原作者
目录
相关文章
|
21天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
22天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
23天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
25天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
19天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘 linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
17天前
|
Unix Linux 对象存储
Linux 磁盘管理
Linux 磁盘管理
21 1
|
20天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
26天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
27天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
1月前
|
存储 Linux 5G
Linux 基于 LVM 逻辑卷的磁盘管理【简明教程】
这篇文章介绍了LVM(逻辑卷管理)如何提供灵活的磁盘管理方式,允许动态调整逻辑卷的大小而不会丢失数据。
Linux 基于 LVM 逻辑卷的磁盘管理【简明教程】