LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-29-2014, 01:45 PM   #1
Jake7
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Rep: Reputation: Disabled
bash take known uuid and feed to fsarchiver as /dev/sdwhateveritisnow


I'm using fsarchiver to backup my system to 1 of 3 volumes.

The problem I'm having is that two of the volumes are external SATA drives that I don't have on unless I'm backing up. When they are off my system shows:

root /dev/sda1
data /dev/sdb2
stor /dev/sdb3
...

However when I startup with one of external SATA backup volumes on the devs get shifted:

sync1 /dev/sda1
root /dev/sdb1
data /dev/sdc2
stor /dev/sdc3
...

It gets even more convoluted if I turn on both the SATA volumes.

I'm writing multiple backup sripts that backup certain volumes and I don't want to keep playing "guess the /dev" with each script.

I have a list of all of the UUID for my volumes. What I need is a way to get the current /dev from the UUID so I can feed that to fsarchiver. I imagine it to look something along the lines of:

MYROOTDISK=`something that takes uuid for root system volume and outputs it as /dev/sdwhateveritisnow`
MYDESTDISK1=`something that takes uuid for root system volume and outputs it as /dev/sdwhateveritisnow`

fsarchiver -z4 -j2 savefs ${MYDESTDISK1}/backup.fsa ${MYROOTDISK}

Any ideas on how to take the uuid and find its current /dev/s?? so that I can feed it to fsarchiver?

Thanks In Advance!
 
Old 05-29-2014, 02:08 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,147

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
Do
Code:
ls -l /dev/disk/by-id
The readlink command should help in translating symbolic links to sd names.
 
Old 05-29-2014, 08:14 PM   #3
Jake7
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Original Poster
Rep: Reputation: Disabled
Hmmm, OK. This isn't what I'm looking for. I'm not working with symbolic links, I'm backing up entire file systems (using fsarchiver).

What I need is a way to take my UUIDs (which don't change) and find out what /dev/sd?# they are at the time of my backups. I need that information in a string that I can plug into fsarchiver.

ex.
mount /dev/sdb9 /media/sdb9
fsarchiver savefs /media/sdb9/foobackup.fsa /dev/sda1

This mounts the destination volume /dev/sdb9 as /media/sdb9 and then creates the backup of the target file system /dev/sda1 to destination "foobackup.fsa" on /media/sdb9.

My problem is the destination "sdb9" isn't always the same. My external SATA drives vs my external USB drives vs my SDHC cards. But the UUID of the destination volume I intend to use is always the same. I need a way to find out what the /dev/sd?# is from the destinations UUID.

Thanks anyway!

Anyone else?
 
Old 05-29-2014, 08:25 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Had you taken the previous advice seriously and done some looking you might have found /dev/disk/by-uuid

There is also blkid - probably requires root/sudo depending on distro.
 
Old 05-29-2014, 08:47 PM   #5
Jake7
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Original Poster
Rep: Reputation: Disabled
[SOLVED] bash take known uuid and feed to fsarchiver as /dev/sdwhateveritisnow

OK, I figured it out!

smallpond you were sooo close. You should use: ls -l /dev/disk/by-uuid/
which gives the example result:

lrwxrwxrwx 1 root root 10 May 29 17:13 5e02d4ae-5476-471c-bec1-529801e35941 -> ../../sdb2
lrwxrwxrwx 1 root root 10 May 29 17:13 9da321dc-f08c-456a-b6f4-66b559893994 -> ../../sda1
lrwxrwxrwx 1 root root 10 May 29 17:13 BB75-CADC -> ../../sdb3
lrwxrwxrwx 1 root root 10 May 29 17:13 c508ff5e-fe52-447a-a66c-92e8f63db180 -> ../../sdb1

But that's still not what I'm looking for. While it connects the UUID to the /dev/sd?# I'd have pipe together a bunch of cuts to get the result I want. Also notice that /dev/sdb3 isn't the same length as the other UUIDs. That means even more has to be done to get the result I need.

That's when I went back to blkid where I got my UUIDs in the first place. I RTFM for blkid and found: blkid -U <UUID> (BTW, that option is a capital U). So, lets say for example that I know my destination UUID is 9da321dc-f08c-456a-b6f4-66b559893994, but I don't know what the current /dev/sd?# is for it.

blkid -U 9da321dc-f08c-456a-b6f4-66b559893994
gives me the example result:

/dev/sda1

And that is exactly what I'm looking for!
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
df - rootfs twice /dev/disk/by-uuid/ techux Debian 1 07-10-2013 12:29 PM
[SOLVED] uuid to dev amboxer21 Arch 10 07-24-2012 11:23 PM
[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
UUID device versus /dev abd_bela Debian 1 02-08-2009 02:13 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 > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:57 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