Hey everyone! I've got a backup server set up with a SAS tape library and everything usually runs smoothly. However, I've noticed that if there's a power outage or a system crash, the SCSI tape drive sometimes switches its device node from /dev/sg3 to /dev/sg2, which is probably due to the order of device discovery. This doesn't seem to affect functionality, but I really want to make sure the drive always comes back up at the same node after a reboot or power cycle. I'm looking into udev rules to give it a static device name, but I'm running into issues with the scsi_id command giving me errors, and I can't seem to find the right WWID for my tape drive. Has anyone successfully set up a static name for their SCSI devices?
3 Answers
You're definitely on the right track with udev, but it can be pretty picky. Just remember that depending on the application you’re interfacing with, you might specifically need that SCSI level access. Using /dev/st nodes might not do the trick if you're sending commands that the st driver doesn't handle. It may help to investigate the major and minor device numbers from the `lsscsi` output, which indicate if there's a race condition with drivers claiming the device. If the major stays the same but the minor keeps changing, you might be forced to rely on more stable identifiers for creating those udev rules.
Correct me if I’m wrong, but you can also get some hints on what device files are stable using sysfs, right?
You could indeed set up a udev rule that assigns a consistent name for your tape drive, like /dev/tapelib/lunX/driveX if you want it to be a bit more descriptive. Alternatively, you might want to check out the /dev/disk/by-path option, which could provide a more stable reference as long as your tape library presents it consistently. Also, running `lsscsi -dgi` can help you identify the correct device entry for your rules since it gives you detailed information about your connected SCSI devices. The /dev/s* nodes aren't the best for stability since they depend on the order of discovery, which can change with various factors like boot sequences or hardware differences.
I ran the lsscsi command and got some useful info, but I specifically need to point to the /dev/sg1 node for my SCSI commands, not /dev/st0 which is just the block device.
Yeah, the sequence can definitely flip around after a power cycle. Ideally, you want to catch the SCSI device with a method that won't change, like using its WWID.
It sounds like you might need to tweak the spin-up delay in your hardware settings. Sometimes, if devices don't power up in the right order, it can lead to such issues. If you're using a Dell PowerVault TL2000, check if there are jumpers that control the spin-up timing. That might help in stabilizing the connection after an outage.
Interesting, I’ll have a look at those jumpers and see if adjusting them makes a difference.
Totally, and I have been trying to understand why these identifiers would shift. I'm currently focusing on keeping my udev rules precise, but they haven't clicked yet.