LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 01-08-2018, 12:24 PM   #1
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,772
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
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
 
Old 01-08-2018, 01:01 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
The best way to do this is with UUID. The link below talks about persistent naming including UUID information:
https://wiki.archlinux.org/index.php...sistent_naming

This link is referenced in the above and shows what you'd need in fstab to use UUID:
https://wiki.archlinux.org/index.php/Fstab#UUIDs
 
1 members found this post helpful.
Old 01-08-2018, 01:05 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
A couple of commands to look at are blkid and lsblk.
 
1 members found this post helpful.
Old 01-08-2018, 01:52 PM   #4
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,772

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by MensaWater View Post
The best way to do this is with UUID. The link below talks about persistent naming including UUID information:
https://wiki.archlinux.org/index.php...sistent_naming

This link is referenced in the above and shows what you'd need in fstab to use UUID:
https://wiki.archlinux.org/index.php/Fstab#UUIDs
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.

Thanks in advance,
~~~ *<;-} Dan
 
Old 01-08-2018, 03:59 PM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 01-08-2018, 04:28 PM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by SaintDanBert View Post
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.
 
Old 01-08-2018, 04:29 PM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by SaintDanBert View Post
I want to use this database to report:
  • this physical drive
  • contains these file systems
That is exactly what "lsblk -f" reports, for all drives if run without specifying a drive, or for whatever drives and/or partitions you specify.
 
Old 01-09-2018, 07:34 PM   #8
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,772

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by hydrurga View Post
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 View Post
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.

Regards,
~~~ 0;-Dan
 
Old 01-10-2018, 03:26 AM   #9
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
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).

For example:

Drive 000012400927BA30
Partition 1: NTFS - 16 GiB - Planning applications
Partition 2: Raw (Unformatted) - 2 GiB
Partition 3: Ext2 - 24 GiB - Atari games

Drive WD-072E4E7FA96
Partition 0 [i.e. not partitioned]: Raw (DBAN Wiped) - 100 GiB - Client 123

Drive NAS56554411B
Partition 1: ...
 
Old 01-29-2018, 03:13 PM   #10
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,772

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by MensaWater View Post
You can use scsi_id to get info on the entire drive - for example:
Code:
prompt$ scsi_id -g -u -d /dev/sda
36d4ae520a7da930017dabe9212770b0b
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 View Post
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.

Thanks in advance,
~~~ 8d;-/ Dan
 
Old 01-30-2018, 12:18 PM   #11
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
1 members found this post helpful.
Old 02-01-2018, 07:38 PM   #12
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,772

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by MensaWater View Post
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.
Found it in /lib/udev/scsi_id

Thanks in advance,
~~~ 0;-Dan
 
1 members found this post helpful.
Old 02-01-2018, 07:40 PM   #13
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,772

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by MensaWater View Post
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.
My Mint 18.3 box reported 'systemd'.

Regards,
~~~ 0;-Dan
 
1 members found this post helpful.
  


Reply

Tags
disk drive, identifier, smart



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
seeking howto -- use CUPS for custom output to same physical printer SaintDanBert Linux - Server 6 08-26-2013 07:26 PM
Partition 1 has different physical/logical beginnings (non-Linux? kirkb00 Linux - Newbie 1 06-14-2008 06:56 AM
Does a linux LVM use up all the physical space in the Hard Drive? chickenjoy Linux - Software 1 01-25-2008 09:57 AM
WinXP on one physical drive and SUSE 10 on another physical drive flanker12k Linux - Newbie 4 05-13-2006 08:36 AM
Installing Linux on a second physical hard drive JediDrunk Linux - General 3 10-27-2003 10:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration