[clue-tech] Detecting media change

David L. Anselmi anselmi at anselmi.us
Thu May 1 23:00:32 MDT 2008


David L. Willson wrote:
[...]
> Found it.  'blkid' is my friend.
> 
> The sed command is awful.  I'm sure it's the wrong way to do it, but it seems to have
> worked.  The sed bit looks for some stuph, then 'UUID="', then some stuph that isn't the
> closing quote, which it stores in a pattern buffer, then the closing quote, followed by
> more stuph, and replaces everything with whatever it stored in the first pattern buffer.
> 
> blkid /dev/sda1 | sed -e 's/^.*UUID="\([^"]*\)".*$/\1/'

If you really like sed, this may be a little cleaner:

sed -e 's/^.*UUID="//' -e 's/".*$//'

but

blkid -o value /dev/sda1 | head -1

works for me.

Bacula doesn't give me any hassle about detecting or blanking media.  It 
just does the right thing with what is there and complains if there 
isn't anything.

Dave


More information about the clue-tech mailing list