AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 5336
In Process
Philip Durbin
Philip Durbin
Asked: 2009-05-07 06:47:37 +0800 CST2009-05-07 06:47:37 +0800 CST 2009-05-07 06:47:37 +0800 CST

如何让 Linux 识别我热插拔的新 SATA /dev/sda 驱动器而无需重新启动?

  • 772

热交换出故障的 SATA /dev/sda 驱动器工作正常,但是当我去交换一个新驱动器时,它无法识别:

[root@fs-2 ~]# tail -18 /var/log/messages
May 5 16:54:35 fs-2 kernel: ata1: exception Emask 0x10 SAct 0x0 SErr 0x50000 action 0xe frozen
May 5 16:54:35 fs-2 kernel: ata1: SError: { PHYRdyChg CommWake }
May 5 16:54:40 fs-2 kernel: ata1: link is slow to respond, please be patient (ready=0)
May 5 16:54:45 fs-2 kernel: ata1: device not ready (errno=-16), forcing hardreset
May 5 16:54:45 fs-2 kernel: ata1: soft resetting link
May 5 16:54:50 fs-2 kernel: ata1: link is slow to respond, please be patient (ready=0)
May 5 16:54:55 fs-2 kernel: ata1: SRST failed (errno=-16)
May 5 16:54:55 fs-2 kernel: ata1: soft resetting link
May 5 16:55:00 fs-2 kernel: ata1: link is slow to respond, please be patient (ready=0)
May 5 16:55:05 fs-2 kernel: ata1: SRST failed (errno=-16)
May 5 16:55:05 fs-2 kernel: ata1: soft resetting link
May 5 16:55:10 fs-2 kernel: ata1: link is slow to respond, please be patient (ready=0)
May 5 16:55:40 fs-2 kernel: ata1: SRST failed (errno=-16)
May 5 16:55:40 fs-2 kernel: ata1: limiting SATA link speed to 1.5 Gbps
May 5 16:55:40 fs-2 kernel: ata1: soft resetting link
May 5 16:55:45 fs-2 kernel: ata1: SRST failed (errno=-16)
May 5 16:55:45 fs-2 kernel: ata1: reset failed, giving up
May 5 16:55:45 fs-2 kernel: ata1: EH complete

我尝试了一些方法来使服务器找到新的 /dev/sda,例如rescan-scsi-bus.sh,但它们没有工作:

[root@fs-2 ~]# echo "---" > /sys/class/scsi_host/host0/scan
-bash: echo: write error: Invalid argument
[root@fs-2 ~]#
[root@fs-2 ~]# /root/rescan-scsi-bus.sh -l
[snip]
0 new device(s) found.
0 device(s) removed.
[root@fs-2 ~]#
[root@fs-2 ~]# ls /dev/sda
ls: /dev/sda: No such file or directory

我最终重新启动了服务器。/dev/sda 被识别,我修复了软件 RAID,现在一切都很好。但是下一次,我怎样才能让 Linux 在不重新启动的情况下识别我热插拔的新 SATA 驱动器?

有问题的操作系统是 RHEL5.3:

[root@fs-2 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.3 (Tikanga)

硬盘是 Seagate Barracuda ES.2 SATA 3.0-Gb/s 500-GB,型号 ST3500320NS。

这是 lscpi 输出:

[root@fs-2 ~]# lspci
00:00.0 RAM memory: nVidia Corporation MCP55 Memory Controller (rev a2)
00:01.0 ISA bridge: nVidia Corporation MCP55 LPC Bridge (rev a3)
00:01.1 SMBus: nVidia Corporation MCP55 SMBus (rev a3)
00:02.0 USB Controller: nVidia Corporation MCP55 USB Controller (rev a1)
00:02.1 USB Controller: nVidia Corporation MCP55 USB Controller (rev a2)
00:04.0 IDE interface: nVidia Corporation MCP55 IDE (rev a1)
00:05.0 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:05.1 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:05.2 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:06.0 PCI bridge: nVidia Corporation MCP55 PCI bridge (rev a2)
00:08.0 Bridge: nVidia Corporation MCP55 Ethernet (rev a3)
00:09.0 Bridge: nVidia Corporation MCP55 Ethernet (rev a3)
00:0a.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0b.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0c.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0d.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0e.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0f.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
00:19.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:19.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:19.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:19.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
03:00.0 VGA compatible controller: Matrox Graphics, Inc. MGA G200e [Pilot] ServerEngines (SEP1) (rev 02)
04:00.0 PCI bridge: NEC Corporation uPD720400 PCI Express - PCI/PCI-X Bridge (rev 06)
04:00.1 PCI bridge: NEC Corporation uPD720400 PCI Express - PCI/PCI-X Bridge (rev 06)

更新:在十几个案例中,我们被迫重新启动服务器,因为热交换还没有“正常工作”。感谢您提供更多有关 SATA 控制器的答案。我已经包含了上面有问题的系统的 lspci 输出(主机名:fs-2)。在该系统的热交换方面,我仍然可以使用一些帮助来了解硬件方面究竟不支持什么。请让我知道除了 lspci 之外的其他输出可能有用。

好消息是热插拔今天在我们的一台服务器(主机名:www-1)上“刚刚工作”,这对我们来说非常罕见。这是 lspci 输出:

[root@www-1 ~]# lspci
00:00.0 RAM memory: nVidia Corporation MCP55 Memory Controller (rev a2)
00:01.0 ISA bridge: nVidia Corporation MCP55 LPC Bridge (rev a3)
00:01.1 SMBus: nVidia Corporation MCP55 SMBus (rev a3)
00:02.0 USB Controller: nVidia Corporation MCP55 USB Controller (rev a1)
00:02.1 USB Controller: nVidia Corporation MCP55 USB Controller (rev a2)
00:04.0 IDE interface: nVidia Corporation MCP55 IDE (rev a1)
00:05.0 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:05.1 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:05.2 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:06.0 PCI bridge: nVidia Corporation MCP55 PCI bridge (rev a2)
00:08.0 Bridge: nVidia Corporation MCP55 Ethernet (rev a3)
00:09.0 Bridge: nVidia Corporation MCP55 Ethernet (rev a3)
00:0b.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0c.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0f.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:18.0 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] HyperTransport Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] Miscellaneous Control
00:18.4 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] Link Control
00:19.0 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] HyperTransport Configuration
00:19.1 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] Address Map
00:19.2 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] DRAM Controller
00:19.3 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] Miscellaneous Control
00:19.4 Host bridge: Advanced Micro Devices [AMD] K10 [Opteron, Athlon64, Sempron] Link Control
03:00.0 VGA compatible controller: Matrox Graphics, Inc. MGA G200e [Pilot] ServerEngines (SEP1) (rev 02)
04:00.0 PCI bridge: NEC Corporation uPD720400 PCI Express - PCI/PCI-X Bridge (rev 06)
04:00.1 PCI bridge: NEC Corporation uPD720400 PCI Express - PCI/PCI-X Bridge (rev 06)
09:00.0 SCSI storage controller: LSI Logic / Symbios Logic SAS1064ET PCI-Express Fusion-MPT SAS (rev 04)
linux sata linux-kernel scsi hotswap
  • 12 12 个回答
  • 222611 Views

12 个回答

  • Voted
  1. user1797
    2009-05-07T07:01:00+08:002009-05-07T07:01:00+08:00

    如果您的 SATA 控制器支持热插拔,它应该“正常工作(tm)”。

    要强制重新扫描 SCSI BUS(每个 SATA 端口显示为 SCSI BUS)并查找新驱动器,您将使用:

    echo "0 0 0" >/sys/class/scsi_host/host<n>/scan
    

    在上面,<n>是 BUS 号。

    • 55
  2. Noah
    2009-12-07T19:10:21+08:002009-12-07T19:10:21+08:00
    echo "- - -" >/sys/class/scsi_host/host<n>/scan
           ^ ^
            \_\_______ note spaces between the dashes.
    
    • 23
  3. karora
    2013-04-29T14:57:39+08:002013-04-29T14:57:39+08:00

    当驱动器在某些情况下发生故障时,Linux 不会意识到您实际上已经从阵列中物理地取出了它。如果您有这个问题(就像我今天早上所做的那样),您可以执行以下操作:

    echo 1 > /sys/block/<devnode>/device/delete
    

    例如,就我而言,/dev/sda 失败了,我不想重新启动服务器,所以我这样做了:

    echo 1 > /sys/block/sda/device/delete
    

    在我这样做之后,新驱动器(实际上已经物理添加)立即可见。

    如果此时它不可见,您也可以执行此操作以强制重新扫描:

    echo "- - -" > /sys/class/scsi_host/host<n>/scan
    

    “- - -” 分别是通道、id 和 LUN 的通配符,因此您可以通过指定数字来限制扫描到某个子集。

    在开始之前,您还可以:

    readlink /sys/block/<devnode>
    

    这将向您显示具有正确主机号的路径,以检查 /proc/scsi/scsi 在删除后是否消失。

    • 16
  4. Peter
    2015-08-14T10:09:00+08:002015-08-14T10:09:00+08:00

    我不敢相信还没有人提到 AHCI……你的 SATA 控制器必须处于 AHCI 模式才能启用热插拔。通过查看您正在使用的驱动程序来检查这一点:

    root@peter:~ # find /sys -name sdk
    /sys/devices/pci0000:00/0000:00:11.0/ata5/host4/target4:0:0/4:0:0:0/block    /sdk
    /sys/block/sdk
    /sys/class/block/sdk
    
    root@peter:~ # readlink /sys/devices/pci0000:00/0000:00:11.0/driver
    ../../../bus/pci/drivers/ahci
    
    root@peter:~ # lspci -k | less
    [... big long output... search for ahci or your pci address, or use the awk below ...]
    
    root@peter:~ # lspci -k | awk '$1 == "00:11.0" {x=1}; x && /in use/ {print $0; exit}'
        Kernel driver in use: ahci
    

    看看那里怎么说“ahci”。

    如果没有,那么只需在您的 BIOS 中启用它。此外,某些 BIOS,尤其是在服务器或 UEFI 上的每个磁盘都有一个“热插拔 = 启用/禁用”设置,如果存在,您也应该启用它。

    • 11
  5. user59282
    2010-11-06T01:06:22+08:002010-11-06T01:06:22+08:00

    这个怎么样(似乎在Ubuntu中工作):

    须藤部分探针

    • 8
  6. Peter
    2011-03-05T02:52:29+08:002011-03-05T02:52:29+08:00

    这就是为什么我需要重新启动计算机...

    我刚刚热交换了我的 /dev/sdc。我使用 scsiadd -r 3 0 0 关闭旧磁盘,然后再将其拉出。然后在安装新磁盘后,新磁盘不会显示为 /dev/sdc,而是显示为 /dev/sdd。重新启动后,磁盘将再次显示为 /dev/sdc。

    所以看起来热插拔工作正常,可能只是 /dev/sd* 不再相同了。

    这可以解决您的问题吗?

    • 2
  7. STW
    2014-12-31T10:57:49+08:002014-12-31T10:57:49+08:00

    在某些情况下,可能需要在主板和/或 SATA 控制器的 BIOS 上启用热插拔。这完全取决于两者的品牌和型号,但如果您有支持热插拔的板载 SATA 控制器,那么值得通过主板 BIOS 进行梳理。SATA 卡可能有也可能没有自己的 BIOS 设置,许多低端卡没有,但服务器级卡通常有。

    如果我没记错的话,我需要使用许多技嘉主板,也许还有其他一些品牌。我需要它来让热插拔 SATA 托盘工作;禁用该功能后,移除驱动器不会导致问题,但新驱动器在重新启动之前不会注册。启用设置按预期工作,放置在托盘中的驱动器立即启动并可供操作系统使用。

    • 2
  8. nox
    2012-02-25T06:16:40+08:002012-02-25T06:16:40+08:00

    要使热插拔工作,您必须加载 acpiphp 模块。

    [root@example ~]# modprobe acpiphp
    

    显然,如果您希望它在启动时工作,则必须将其配置为在启动时加载 - 一种方法是创建/编辑 /etc/rc.modules(由 rc.sysinit 调用)并添加以下行:

    modprobe acpiphp
    

    请记住,如果您将此文件创建为 chmod +x 它,因为它是以这种方式调用的。

    • 1
  9. Stuart Edge
    2012-03-13T20:01:11+08:002012-03-13T20:01:11+08:00

    我的 Fedora 16 机器上的 DVD 连接到 SATA 接口。它被锁起来,不会打开或关闭。以 root 身份运行partprobe让我的 cdrom/DVD 再次工作。我认为它会在我偶尔遇到热插拔问题的另一台机器上有所帮助。谢谢!

    • 1
  10. aij
    2014-01-21T17:14:27+08:002014-01-21T17:14:27+08:00

    您拥有的 Fusion-MPT SAS 控制器是低端 RAID 控制器。如果您不将它用于 RAID,它可能仍会提供无用的阻塞/抽象层。

    您可能需要使用 mpt-status 或 lsiutil 戳 RAID 控制器以使其实际扫描总线。

    http://hwraid.le-vert.net/wiki/LSIFusionMPT有大量的文档,但我不能说我已经验证过了。

    • 1

相关问题

  • 多操作系统环境的首选电子邮件客户端

  • 你最喜欢的 Linux 发行版是什么?[关闭]

  • 更改 PHP 的默认配置设置?

  • 保护新的 Ubuntu 服务器 [关闭]

  • (软)Ubuntu 7.10 上的 RAID 6,我应该迁移到 8.10 吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve