Rescan new disks linux

How do I make Linux recognize a new SATA /dev/sda drive I hot swapped in without rebooting?

Hot swapping out a failed SATA /dev/sda drive worked fine, but when I went to swap in a new drive, it wasn’t recognized:

[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 

I tried a couple things to make the server find the new /dev/sda, such as rescan-scsi-bus.sh but they didn’t work:

[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 

I ended up rebooting the server. /dev/sda was recognized, I fixed the software RAID, and everything is fine now. But for next time, how can I make Linux recognize a new SATA drive I have hot swapped in without rebooting? The operating system in question is RHEL5.3:

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

The hard drive is a Seagate Barracuda ES.2 SATA 3.0-Gb/s 500-GB, model ST3500320NS. Here is the lscpi output:

[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) 

Update: In perhaps a dozen cases, we’ve been forced to reboot servers because hot swap hasn’t «just worked.» Thanks for the answers to look more into the SATA controller. I’ve included the lspci output for the problematic system above (hostname: fs-2). I could still use some help understanding what exactly isn’t supported hardware-wise in terms of hot swap for that system. Please let me know what other output besides lspci might be useful. The good news is that hot swap «just worked» today on one of our servers (hostname: www-1), which is very rare for us. Here is the lspci output:

[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) 

Источник

Читайте также:  Show routing table on linux

Linux: Rescan for new and changes of devices

Additionally , resize the filesystem to the maximum size. 2 steps necessary. Increase the partition and then the filesystem. Be sure your backup is up to date!
Delete (YES DELETE, you just edit the partition table. That is no problem if you do not call mkfs.ext4)the current partition and create a new with the maximum size. Get the old partition info by fdisk especially the start block of the partition.

root@debdev # fdisk -l Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 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: 0x1649ccd6 Device Boot Start End Blocks Id System /dev/sdb1 1 13054 104856223+ 83 Linux

Delete Partition 1 (command d) and create a new primary partition (command n) at the same start block(cylinder). In this example Block 1

root@debdev # umount /deb/sdb1 root@debdev # fdisk /dev/sdb Command (m for help): d Selected partition 1 Command (m for help): n Partition number (1-4): 1 First cylinder (1-26108, default 1): 1 Last cylinder: Command (m for help): p Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 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: 0x1649ccd6 Device Boot Start End Blocks Id System /dev/sdb1 1 26108 209712478+ 83 Linux Command (m for help): w The partition table has been altered! root@debdev # partx /dev/sdb

Or use growpart. This command grows partition 1 (if it is the last partition on the disk) to the maximum size

root@debdev # growpart /dev/sda 1

Check volume integrity and resize the filesystem.

root@debdev # e2fsck -f /dev/sdb1 root@debdev # resize2fs -p /dev/sdb1

Источник

Читайте также:  Arm processor and linux

Rescan SCSI bus on Linux System

SCSI stands for Small Computer System Interface and is a set of standards for transferring data and connecting devices and computers. Sometimes you make changes to disk devices on your Linux box while online which is even more often nowadays using virtual machines. Sometimes you also add a new disk and do not want to restart your Linux system. Wether you need to add a new disk or increase an existing disk size of your virtual machine, the changes will not be instantly visible from the Linux operating system because you need to rescan SCSI bus on Linux to see the change. It is quite easy to rescan SCSI bus on Linux, you can do it with a simple one line command (depending on the number of SCSI devices you have connected).

Rescan SCSI bus on Linux

Follow the steps described below and you will see the new size of your disk.

Rescan SCSI bus on Linux

Please note that the rescan SCSI bus on Linux does not interrupt operating system operation nor remove any of the disks. Rescanning SCSI bus on Linux with the below procedure will add/freshen devices but not remove them.

When Adding a New Disk

When adding a new disk to your Linux system you need to rescan SCSI host.

You can do this with the following command:

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

..where X is the number of SCSI host to scan.

You probably have more than one SCSI host available so to make it right you should repeat the above command for each SCSI host available.

Читайте также:  Linux delete all empty folders

Below is a practical example on how to rescan SCSI bus on Linux and and see the newly added disk:

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

The “- – -” part is where you tell the SCSI host what exactly to rescan and the hyphens are wildcards which tell SCSI host to rescan all controllers, channels and LUNs.

When Increasing Existing Disk Size

If you changed the size of an existing disk you might notice that the operating system can not see the new disk size until you rescan SCSI bus on Linux operating system.

The easiest way i’ve found is to rescan the specific device with the following command:

echo "1" > /sys/class/block/sdX/device/rescan

..where X is the device you increased and want to rescan.

Below is a practical example on how to rescan SCSI bus on Linux and and see the newly added disk:

[root@node-1 ~]# echo "1" > /sys/class/block/sdb/device/rescan

The “1” is a flag which causes the SCSI host to rescan the “sdb” block device and therefore refresh the data about the disk size. Please note that i choose this command due to the human readable “sdb” naming which is really easy to remember.

Otherwise the command could also be triggered as follows:

[root@node-1 ~]# echo "1" > /sys/class/scsi_device/2:0:1:0/device/rescan

..but in the last case you should know which device you want to rescan by the SCSI bus ID.

Источник

Оцените статью
Adblock
detector