LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-04-2024, 07:43 PM   #1
Cannondale
Member
 
Registered: Jan 2023
Location: USA
Distribution: Linux Mint
Posts: 39

Rep: Reputation: 1
Get devise name from uuid


Is there an easy way to get a devise name from given uuid?
 
Old 05-04-2024, 08:24 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,361
Blog Entries: 28

Rep: Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148
I don't think so.

As far as I can determine, the two are independent variables. One is not related to the other.

If I am, as my old boss used to say, "in error," I trust someone with straighten me out.
 
Old 05-04-2024, 08:38 PM   #3
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,371

Rep: Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593
maybe this:
sudo blkid |grep uuid
 
Old 05-05-2024, 05:34 AM   #4
Cannondale
Member
 
Registered: Jan 2023
Location: USA
Distribution: Linux Mint
Posts: 39

Original Poster
Rep: Reputation: 1
Thanks for the reply guys.

I actually stumbled onto to a simple solution and wanted to post it here for future reference.

The sample code below will return the device name (/dev/sdXX). Of course, insert your own actual UUID for valid results.


Code:
blkid -U 2a4a9f2e-3233-4936-84d9-3aa507d6b2bd
 
Old 05-05-2024, 05:59 AM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,914

Rep: Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032

findfs UUID=<insert-uuid-here>
 
1 members found this post helpful.
Old 05-05-2024, 09:39 AM   #6
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555
Quote:
Originally Posted by frankbell View Post
If I am, as my old boss used to say, "in error," I trust someone with straighten me out.
Ok, since you asked... a post like that after less than an hour is not constructive.

When a thread has no replies, it stays in the zero reply list - making it easier for people to find threads that have yet to be answered. Threads without replies get auto-bumped twice, to cater for different timezones.

When someone posts with a "I dunno" reply, it takes the thread out of that list and does not help the person asking for help, and - when done within an hour - reduces the number of people who might see it, and thus is even less helpful.

If someone waits a few days and then invokes Cunningham's Law, they can still enjoy looking foolish, but without reducing the number of people who see a thread and thus might be able to help the person asking.

(Hopefully this is all taken in the constructive manner intended, and also encourages other LQ users to consider if they should post immediately or to wait a few days before removing threads from the Zero Reply list.)

-

Anyhow, back to device names and UUIDs there are (at least) three options for getting a block device name from uuid:
Code:
blkid -U YOUR_UUID
findfs UUID=YOUR_UUID
findmnt UUID=YOUR_UUID
blkid - locate/print block device attributes
findfs - find a filesystem by label or UUID
findmnt - find a filesystem (may be specified by device name, major:minor numbers, filesystem label or UUID, or partition label or UUID.)

None of them need grep.
The first two are in /sbin but - depending on permissions - it might be enough to use /sbin/blkid or /sbin/findfs to run as non-root user; or just use findmnt which doesn't

To go in the other direction, and output the UUID give a device name, neither of these options need root/sudo...
Code:
findmnt -o UUID /dev/sdXY
lsblk -o UUID /dev/sdXY
(Consult --help and/or the manpages for formatting and other available options.)


Last edited by boughtonp; 05-05-2024 at 09:41 AM.
 
2 members found this post helpful.
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] UUID booting: tune2fs cannot set uuid of flash thumb? creates virtual box issue X-LFS-2010 Linux - Newbie 6 06-20-2018 09:28 PM
[SOLVED] /dev/disk/by-uuid/<uuid here> does not exist and initramfs shell Mitt Green Linux - Kernel 4 08-03-2015 11:56 AM
[SOLVED] How to mount by-uuid if the device won't show in /dev/disk/by-uuid untill after blkid /dev/sd* ? masmddr Linux - General 4 01-10-2011 07:38 PM
Change UUID - Edit UUID using the dd command GMHilltop Linux - Newbie 10 10-28-2010 07:39 PM
Volume has problems including no uuid in /dev/disk/by-uuid abejarano Linux - Hardware 3 12-31-2008 08:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:33 PM.

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