How can I know when all scsi disks have been added to /dev/sd*

Issues related to hardware problems
Post Reply
telnet
Posts: 4
Joined: 2017/11/02 03:09:18

How can I know when all scsi disks have been added to /dev/sd*

Post by telnet » 2017/11/02 03:23:39

When system reboots, both the process systemd-udevd and the kernel threads kworker may add scsi disks to /dev/sd*.

When all disks in /etc/fstab (need be mounted) have been found by system, the system will go on and reach multi-user.target in systemd. But at this time, some scsi disks may has not beed added to /dev/sd* yet.

My question is how I can know that all scsi disks have been added to /dev/sd* in systemd or by other method ?

desertcat
Posts: 843
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: How can I know when all scsi disks have been added to /dev/sd*

Post by desertcat » 2017/11/30 23:36:58

telnet wrote:When system reboots, both the process systemd-udevd and the kernel threads kworker may add scsi disks to /dev/sd*.

When all disks in /etc/fstab (need be mounted) have been found by system, the system will go on and reach multi-user.target in systemd. But at this time, some scsi disks may has not beed added to /dev/sd* yet.

My question is how I can know that all scsi disks have been added to /dev/sd* in systemd or by other method ?
Huh?!? :?: If you mean which disk is the SCSI disk vs HDD vs SSD etc. run the df command at the CLI. If you know what is on the SCSI disk it should show up. ie if you know your linux disk is on /dev/sda, and you run df and you see /dev/sda and /dev/sdb, then sdb is your SCSI drive. Alternately use something like Dolphin which will show you all the partitions on all drives and click on all drives. Click on the partition you wish mounted, it will ask you for the Password, enter it, and now run df, it will now show you the current disk (/dev/sda and all the partitions of /dev/sda), but also the mounted partition ex. /dev/sdb12. Alternately you can use the old DOS command fdisk -l to see what other drives can be found besides the currently mounted drive, then use the mount command to mount whatever partitions you want mounted.

telnet
Posts: 4
Joined: 2017/11/02 03:09:18

Re: How can I know when all scsi disks have been added to /dev/sd*

Post by telnet » 2017/12/12 09:46:21

desertcat wrote:
telnet wrote:When system reboots, both the process systemd-udevd and the kernel threads kworker may add scsi disks to /dev/sd*.

When all disks in /etc/fstab (need be mounted) have been found by system, the system will go on and reach multi-user.target in systemd. But at this time, some scsi disks may has not beed added to /dev/sd* yet.

My question is how I can know that all scsi disks have been added to /dev/sd* in systemd or by other method ?
Huh?!? :?: If you mean which disk is the SCSI disk vs HDD vs SSD etc. run the df command at the CLI. If you know what is on the SCSI disk it should show up. ie if you know your linux disk is on /dev/sda, and you run df and you see /dev/sda and /dev/sdb, then sdb is your SCSI drive. Alternately use something like Dolphin which will show you all the partitions on all drives and click on all drives. Click on the partition you wish mounted, it will ask you for the Password, enter it, and now run df, it will now show you the current disk (/dev/sda and all the partitions of /dev/sda), but also the mounted partition ex. /dev/sdb12. Alternately you can use the old DOS command fdisk -l to see what other drives can be found besides the currently mounted drive, then use the mount command to mount whatever partitions you want mounted.
Thanks for your response. But I think you are not clear about my question. I mean I know the dev files /dev/sd* are created by kernel every time system boots, but I do not know when kernel will finished this work that means all dev files /dev/sd* have been created by kernel completely. I want to know whether there is a mechanism to let me know that all dev files /dev/sd* have been created by kernel.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How can I know when all scsi disks have been added to /dev/sd*

Post by TrevorH » 2017/12/12 10:33:48

You can't. Disks could be added at any time so the question is moot.

What is the real problem you're trying to solve?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

telnet
Posts: 4
Joined: 2017/11/02 03:09:18

Re: How can I know when all scsi disks have been added to /dev/sd*

Post by telnet » 2017/12/13 03:04:00

TrevorH wrote:You can't. Disks could be added at any time so the question is moot.

What is the real problem you're trying to solve?
Yes, I know disk can be added at any time, but I just want to check the disks that are in system before system boots.

The real problem is: I have a program and this program will try to use all scsi disks except the disks used by file systems. When system boots, the program will be started automatically by systemd. Then the program will try to get all scsi disks in system, so it will check all "/dev/sd*" files. I found at this time not all scsi disks have been added to /dev/sd* sometimes in some machines (there are total 24 disks, but only about 10 disks have been added at this time). I checked the system log and found after about 10 - 30 seconds, all scsi disks will be added to /dev/sd* completely. So the problem is how the program knows that all static scsi disks in system have been added to /dev/sd*. If there is not a mechanism to do this, my program has to wait for several minutes at begin to hope all disks have been added completely, but I do not know how many minutes are enough...

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: How can I know when all scsi disks have been added to /dev/sd*

Post by pjsr2 » 2017/12/13 14:38:32

Not sure if this is the solution, but would it be enough to wait until the udev event queue is empty? That can be done with the command

Code: Select all

udevadm settle

telnet
Posts: 4
Joined: 2017/11/02 03:09:18

Re: How can I know when all scsi disks have been added to /dev/sd*

Post by telnet » 2017/12/15 01:08:43

pjsr2 wrote:Not sure if this is the solution, but would it be enough to wait until the udev event queue is empty? That can be done with the command

Code: Select all

udevadm settle
It seems this is a solution for me. Thanks a lot

Post Reply