Linux服务器不关机新增硬盘的方法

在开机状态下,插入磁盘之后,执行如下命令:

 ls /sys/class/scsi_host/
host0 host1 host2

echo "- - -" > /sys/class/scsi_host/host0/scan

echo "- - -" > /sys/class/scsi_host/host1/scan

echo "- - -" > /sys/class/scsi_host/host2/scan

查看步骤1的命令是否生效,可以在/var/log/messages中进行验证
执行fdisk -l命令看是否能看到新增的磁盘,如果看不到,可以把上面的host0换成host1或者host2等再试一次

fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3a1a

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 325 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 325 2089 14167040 83 Linux

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

发现已经看到sdb了

fdisk /dev/sdb

mkfs.ext4 /dev/sdb1

posted @ 2018-11-15 10:30  chillax1314  阅读(795)  评论(0编辑  收藏  举报