seeking physical drive ID vs. partition ID vs. filesystem ID on Linux Mint18.xx
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
seeking physical drive ID vs. partition ID vs. filesystem ID on Linux Mint18.xx
Given a connected external (typically USB) drive, which command(s) will report a unique, machine readable identifier for:
the entire drive
each partition on that drive
each file system on that drive
Also, which command(s) will enable me to assign my own identifying string to a drive, partition, or filesystem? I know about touch {filename} and similar. I'm hoping that I can add the identifier into the meta-data somehow.
FOLLOW-UP:
Which command(s) will report if a given disk drive is SATA or PATA (or ATAPI or EIDE or similar)?
I know about the device names such as /dev/sda and /dev/sdb3. I also know about UUID. and volume label.
I have a large number (blush) of external drives covering a lot of years of digital landfill. I'm working to create a database and want to store the DRIVE_ID, PARTITION_ID, and FILESYSTEM_TYPE along with other machine readable details from 'smartctl' and similar.
Thanks in advance,
~~~ *<;-} Dan
Last edited by SaintDanBert; 01-08-2018 at 02:09 PM.
Reason: added details and clarification
Your posting was very helpful and definitely helped to move my project along. However, I don't see any identifier for the physical drive as a whole -- aka, /dev/sdx vs. /dev/sdxN.
I want to use this database to report:
this physical drive
contains these file systems
and
this file system
contains these folders and files
Are there any other command(s) besides this one that will identify the physical drive?
Code:
prompt$ sudo smartctl --info /dev/sda | grep -i serial
Serial Number: WD-WXF1AC6606P7
Is there any way that I might assign my own persistent identifier to a physical drive?
Is there some way that I might set my own values -- strings that make sense to me -- to the UUID of a filesystem? I know that I can set volume labels.
You can use scsi_id to get info on the entire drive - for example:
scsi_id -g -u -d /dev/sda
36d4ae520a7da930017dabe9212770b0b
That seems to equate with the LUN ID rather than S/N for Smartctl output as for the same disk I see:
smartctl --info /dev/sda
smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-279.14.1.el6.x86_64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
Vendor: DELL
Product: PERC H710
Revision: 3.13
User Capacity: 299,439,751,168 bytes [299 GB]
Logical block size: 512 bytes
Logical Unit id: 0x6d4ae520a7da930017dabe9212770b0b
Serial number: 000b0b771292beda170093daa720e54a
Device type: disk
Local Time is: Mon Jan 8 16:53:30 2018 EST
Device does not support SMART
It is the scsi_id output by the way that is often used in udev rules.
Given a connected external (typically USB) drive, which command(s) will report a unique, machine readable identifier for:
the entire drive
each partition on that drive
each file system on that drive
Out of interest, given that a partition can't contain more than one filesystem (on a practical accessible basis), why do you need unique identifiers for both partitions and filesystems? Unless you have raw non-filesystem data on a partition, or use a filesystem somewhere that doesn't include a user-settable label field, I would just assign your own unique identifier to each filesystem and work with that.
Out of interest, given that a partition can't contain more than one filesystem (on a practical accessible basis), why do you need unique identifiers for both partitions and filesystems?
I have physical drives that have some partitions with files systems and some partitions that exist but lack file systems. A typical origin for these is retired/salvaged boot drives from laptops. A SWAP partition or RECOVERY partition got wiped but not removed and the drive held as "archival". One motive for this project involves a catalog of what is worth keeping and bleachbit for the rest. I could simply data-landfill the contents but where is the fun in that?
Quote:
Originally Posted by hydrurga
Unless you have raw non-filesystem data on a partition, or use a filesystem somewhere that doesn't include a user-settable label field, I would just assign your own unique identifier to each filesystem and work with that.
What are your thoughts on where/how to set the identifier "somewhere that doesn't include a user-settable label field?" A cheep approach could 'touch' a file at the top of the filesystem folder tree. Then 'chown' and 'chmod' to make it hard to zorch that file. The filename or the file contents or both could then supply the "identification."
I'd like to avoid open-read-process-close against each file system in my utility. Then again, any command -- eg, 'lsblk' or 'smartctl' -- does exactly that (*nix "everything is a file"). So my utility could initialize the contents of this file as a set of XML statements about the filesystems. I'd have the physical drive serial number from 'smartcl' and the UUID with LABEL from 'lsblk' as records in my magic file. Hmmm.
Thanks for the ideas. Your comments and suggestions are welcome and encouraged.
Perhaps I am being naive, but if you don't plan to change the partitioning on those disks, why don't you just grab the device identifier and partition info from each device for your database. That way you don't need to bother writing or setting anything within the actual partitions or filesystems themselves - each "data block" is identified by the device it's on and the sequential number of the partition on that device. If you want, you can add in any additional info that you can read, such as filesystem types and labels, and add personal identifiers, notes and other info (but only to the database, not to any of the devices).
My linux Mint 18.3 scsitools page provided 'scsiinfo' instead of 'scsi_id'.
Code:
prompt$ sudo scsiinfo -i /dev/sdb
Inquiry command
---------------
Relative Address 0
Wide bus 32 0
Wide bus 16 0
Synchronous neg. 0
Linked Commands 0
Command Queueing 1
SftRe 0
Device Type 0
Peripheral Qualifier 0
Removable? 0
Device Type Modifier 0
ISO Version 0
ECMA Version 0
ANSI Version 6
AENC 0
TrmIOP 0
Response Data Format 2
Vendor: WDC WD10
Product: JPVX-22JC3T0
Revision level: 0108j561
Quote:
Originally Posted by MensaWater
That seems to equate with the LUN ID rather than S/N for Smartctl output as for the same disk I see:
Code:
prompt$smartctl --info /dev/sda
smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-279.14.1.el6.x86_64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
Vendor: DELL
Product: PERC H710
Revision: 3.13
User Capacity: 299,439,751,168 bytes [299 GB]
Logical block size: 512 bytes
Logical Unit id: 0x6d4ae520a7da930017dabe9212770b0b
Serial number: 000b0b771292beda170093daa720e54a
Device type: disk
Local Time is: Mon Jan 8 16:53:30 2018 EST
Device does not support SMART
It is the scsi_id output by the way that is often used in udev rules.
How do I get this information for a USB connected drive?
When I try to get this information about a USB connected drive, all I can get is:
Code:
prompt$ sudo smartctl --info /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-109-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
/dev/sdb: Unknown USB bridge [0x152d:0x0561 (0x108)]
Please specify device type with the -d option.
Use smartctl -h to get a usage summary
Trying again:
Code:
prompt$ sudo smartctl --info --device usbjmicron /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-109-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Smartctl open device: /dev/sdb [USB JMicron] failed: No device connected
== and ==
Code:
prompt$ sudo smartctl --info --device usbcypress /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-109-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Read Device Identity failed: Unknown error
A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.
== and ==
Code:
prompt$ sudo smartctl --info --device usbprolific /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-109-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Read Device Identity failed: scsi error unsupported scsi opcode
A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.
NOTE -- Any use of the --tolerance(-T) option as suggested results in mostly gibberish output.
scsi_id is actually used by udev rules so I'd expect it to be available on most modern distro versions. From what I just read Mint is derived from Debian/Ubuntu which do use udev so I'd expect Mint would have it as well.
I don't use Mint but did find recently that scsi_id which was /sbin/scsi_id on RHEL6 move to /lib/udev/scsi_id on RHEL7. You might want to check both those locations. Failing that doing "find / -name scsi_id" should find it if it exists.
You might look in /dev/disk/by-id for the disk.
What version of Mint are you running? I had a hard time finding a man page for scsiinfo and the one I did find on line is from 1997. It may be there is no such thing as WWID and/or scsi_id on your Mint if it is very old.
EDIT: Never mind the version question. I see the title of the thread says Mint 18. Reading just now shows that is fairly recent and is based on Ubuntu and uses systemd instead of init. In that case I suspect /lib/udev/scsi_id is the location.
Interestingly I learned that "cat /proc/1/comm" on some systems will show what it is using. On RHEL7 that confirms it uses systemd and on RHEL6 confirms it uses init. If you type it on your Mint 18 it should confirm it uses systemd.
Last edited by MensaWater; 01-31-2018 at 07:56 AM.
scsi_id is actually used by udev rules so I'd expect it to be available on most modern distro versions. From what I just read Mint is derived from Debian/Ubuntu which do use udev so I'd expect Mint would have it as well.
I don't use Mint but did find recently that scsi_id which was /sbin/scsi_id on RHEL6 move to /lib/udev/scsi_id on RHEL7. You might want to check both those locations. Failing that doing "find / -name scsi_id" should find it if it exists.
Interestingly I learned that "cat /proc/1/comm" on some systems will show what it is using. On RHEL7 that confirms it uses systemd and on RHEL6 confirms it uses init. If you type it on your Mint 18 it should confirm it uses systemd.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.