Chinaunix首页 | 论坛 | 博客
  • 博客访问: 750731
  • 博文数量: 179
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1536
  • 用 户 组: 普通用户
  • 注册时间: 2015-01-27 11:05
个人简介

MySQL工程师 QQ:1815357042

文章分类

全部博文(179)

文章存档

2015年(179)

分类: LINUX

2015-04-01 09:52:30

有时候我们在服务器或者虚拟机中添加了一块新硬盘,但是用fdisk -l 却看不到新添加的硬盘,这时候就需要重启服务器来识别新添加的硬盘
但是大家知道服务器是不能随便重启的,那么有什么好的方法可以不用重启就能识别新的硬盘吗?
答案是有的

步骤
在线添加一块磁盘

至于详细的虚拟机添加磁盘细节这里就不说了,都很简单,New Hard Disk就是新添加的磁盘



这时我们用fdisk -l 是看不到新添加的磁盘的
  1. [root@steven ~]# fdisk -l

  2. Disk /dev/sda: 21.5 GB, 21474836480 bytes
  3. 255 heads, 63 sectors/track, 2610 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x0009a3b5

  8.    Device Boot Start End Blocks Id System
  9. /dev/sda1 * 1 64 512000 83 Linux
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/sda2 64 2611 20458496 8e Linux LVM

  12. Disk /dev/sdb: 1073 MB, 1073741824 bytes
  13. 255 heads, 63 sectors/track, 130 cylinders
  14. Units = cylinders of 16065 * 512 = 8225280 bytes
  15. Sector size (logical/physical): 512 bytes / 512 bytes
  16. I/O size (minimum/optimal): 512 bytes / 512 bytes
  17. Disk identifier: 0xf27bd8ef

  18.    Device Boot Start End Blocks Id System
  19. /dev/sdb2 1 65 522081 5 Extended
  20. /dev/sdb5 1 26 208782 8e Linux LVM

  21. Disk /dev/mapper/VolGroup-lv_root: 19.0 GB, 19042140160 bytes
  22. 255 heads, 63 sectors/track, 2315 cylinders
  23. Units = cylinders of 16065 * 512 = 8225280 bytes
  24. Sector size (logical/physical): 512 bytes / 512 bytes
  25. I/O size (minimum/optimal): 512 bytes / 512 bytes
  26. Disk identifier: 0x00000000


  27. Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
  28. 255 heads, 63 sectors/track, 257 cylinders
  29. Units = cylinders of 16065 * 512 = 8225280 bytes
  30. Sector size (logical/physical): 512 bytes / 512 bytes
  31. I/O size (minimum/optimal): 512 bytes / 512 bytes
  32. Disk identifier: 0x00000000

确定主机总线号,磁盘是有总线连接着的
  1. [root@steven ~]# ls /sys/class/scsi_host/
  2. host0 host1 host2


重新扫描SCSI总线来添加设备,因为添加的是SCSI磁盘,所以扫描的是SCSI总线
  1. [root@steven ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
  2. [root@steven ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
  3. [root@steven ~]# echo "- - -" > /sys/class/scsi_host/host2/scan

验证
  1. [root@steven ~]# fdisk -l

  2. Disk /dev/sda: 21.5 GB, 21474836480 bytes
  3. 255 heads, 63 sectors/track, 2610 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x0009a3b5

  8.    Device Boot Start End Blocks Id System
  9. /dev/sda1 * 1 64 512000 83 Linux
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/sda2 64 2611 20458496 8e Linux LVM

  12. Disk /dev/sdb: 1073 MB, 1073741824 bytes
  13. 255 heads, 63 sectors/track, 130 cylinders
  14. Units = cylinders of 16065 * 512 = 8225280 bytes
  15. Sector size (logical/physical): 512 bytes / 512 bytes
  16. I/O size (minimum/optimal): 512 bytes / 512 bytes
  17. Disk identifier: 0xf27bd8ef

  18.    Device Boot Start End Blocks Id System
  19. /dev/sdb2 1 65 522081 5 Extended
  20. /dev/sdb5 1 26 208782 8e Linux LVM

  21. Disk /dev/mapper/VolGroup-lv_root: 19.0 GB, 19042140160 bytes
  22. 255 heads, 63 sectors/track, 2315 cylinders
  23. Units = cylinders of 16065 * 512 = 8225280 bytes
  24. Sector size (logical/physical): 512 bytes / 512 bytes
  25. I/O size (minimum/optimal): 512 bytes / 512 bytes
  26. Disk identifier: 0x00000000


  27. Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
  28. 255 heads, 63 sectors/track, 257 cylinders
  29. Units = cylinders of 16065 * 512 = 8225280 bytes
  30. Sector size (logical/physical): 512 bytes / 512 bytes
  31. I/O size (minimum/optimal): 512 bytes / 512 bytes
  32. Disk identifier: 0x00000000


  33. Disk /dev/sdc: 1073 MB, 1073741824 bytes
  34. 255 heads, 63 sectors/track, 130 cylinders
  35. Units = cylinders of 16065 * 512 = 8225280 bytes
  36. Sector size (logical/physical): 512 bytes / 512 bytes
  37. I/O size (minimum/optimal): 512 bytes / 512 bytes
  38. Disk identifier: 0x00000000

可以看到,Disk /dev/sdc就是新添加的磁盘 ,这样就实现了不重启在CentOS / RHEL 虚拟机中添加一块新硬盘


阅读(2226) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~