find disks, disk detach - bus rescan

linux recovery

Find the disk details without udev ( busybox )

cat /proc/scsi/scsi

Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST3250310NS      Rev: MA07
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: ATA      Model: WDC WD2003FZEX-0 Rev: 1A01
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi0 Channel: 00 Id: 02 Lun: 00
  Vendor: ATA      Model: ST2000DM001-1ER1 Rev: CC25
  Type:   Direct-Access                    ANSI  SCSI revision: 05

Then find the associated letter:

ls -ld /sys/block/sd*/device

lrwxrwxrwx    1 root     root             0 Oct 31 13:47 /sys/block/sda/device -> ../../../0:0:0:0
lrwxrwxrwx    1 root     root             0 Oct 31 13:47 /sys/block/sdb/device -> ../../../0:0:1:0
lrwxrwxrwx    1 root     root             0 Oct 31 13:47 /sys/block/sdc/device -> ../../../0:0:2:0

Just match Channel and Id

Rescan the bus

  • Linux, when adding a new disk:

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

  • Linux, when expanding an existing disk:

echo 1 > /sys/class/scsi_device/device/rescan

Detach a disk

  • Delete the disk

echo 1 > /sys/block/$DISK/device/delete

  • Put the disk offline

echo offline > /sys/block/$DISK/device/state

  • After adding a new drive on the tiny linux, launch mdev -s to create the device