Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On linux, name disks by ID #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rkarlsba
Copy link

On linux, name disks by /dev/disk/by-id/xxx instead of /dev/xxx, since the latter may change after a reboot.

On linux, name disks by /dev/disk/by-id/xxx instead of /dev/xxx, since the latter may change after a reboot.
@fliker09
Copy link

Thank you for this! Exactly what I needed, constant change of the name is a very annoying issue.

@tschaerni
Copy link

tschaerni commented Jan 24, 2020

If my understanding of regex is correct, ^ata- only searches for ata attached drives (SATA/IDE), as far as I know, SCSI attached drives should use ^scsi-. That is consistent with SCSI and SAS drives. I don't know much about perl, if I would know, I would fix that my self. But maybe @rkarlsba can fix that and send another push request to @v-zhuravlev?

Cheers

  • tschaerni

EDIT:
I don't have NVMe drives to test it, but I would think they also have something other than ATA or SCSI, because they use a different protocol as far as I know.

@tschaerni
Copy link

I've tested it with a different regex, to also incorporate SCSI devices, a friend of mine made the regex, just replace it with: /^(?:ata|scsi)\-/ or /^(?:ata-|scsi-)/ both work, but I find the second one a bit more clear ;)

Cheers

  • tschaerni

@rkarlsba
Copy link
Author

The code is/was

if ($devlink =~ /^ata-/) {

This can easily be replaced with

if ($devlink =~ /^(ata|scsi)-/) {

Don't know why you'd want ?: in front of that, or escaping -, it's a perfectly valid character in regex unless it's in []

@tschaerni
Copy link

tschaerni commented Jan 29, 2020

I don't know that much about regex, I asked a friend of mine (perl dev with a lot of knowledge about regex) who gave me that regex, and it works after testing it.

btw. there are USB Harddrives with functional S.M.A.R.T, like the WD My Passport series. They identify as for example: usb-WD_My_Passport_25E1_XXXXXXXXXXXXXXXXXXXXXXXX-0:0 so, for USB Attached disks, the regex should also include USB: /^(?:ata-|scsi-|usb-)/

Cheers

  • tschaerni

@rkarlsba
Copy link
Author

Sure - all we're waiting for is a pull…

@Phlogi
Copy link

Phlogi commented Feb 27, 2020

@rkarlsba Can you implement the proposed change (/^(?:ata-|scsi-|usb-)/) in this pull request with another commit?

Allow for scsi and usb things as well
@rkarlsba
Copy link
Author

I beleive that should do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants