UUID confusion revisited

SYNass IT Ubuntu / Linux i-ubux at synass.net
Mon Mar 24 23:34:41 UTC 2008


On Mon, 2008-03-24 at 14:25 -0700, NoOp wrote:
> On 03/21/2008 06:53 AM, JosephK wrote:
> > Following the recent posts regarding UUIDs I thought I'd take a look at
> > mine as I'm forever installing and deleting different Linux distros. I
> > have 3 drives with Gutsy on sda as my main distro for the moment.
> > However, if I instal another distro on sdb or sdc and after a few months
> > use I decide I like it then it may be that my main distro is on sdc and
> > at a later date sda could house something else.
> > 
> > The upshot of this is that when I checked my /etc/fstab against
> > /dev/disk/by-uuid I found that none of the 3 swap partitions (one on
> > each drive) were labelled correctly so I was using no swap space.
> > 
> > I've knocked together a quick script to compare the UUIDs in
> > /dev/disk/by-uuid with the mounted disks in /etc/fstab. If it of any use
> > to you please feel free to use, modify or what you will. Any
> > constructive criticism is welcomed as I am just starting to learn bash
> > shell scripting.
> > 
> > #!/bin/sh
> > 
> > ls -l /dev/disk/by-uuid/ |\
> > awk '{print $10, "UUID="$8}' | sort |\
> > awk -F"/" '{print $3}' > drives.tmp
> > 
> > cat /etc/fstab |\
> > sed -e '/.*\/dev.*$/N;s/\n */ /' |\
> > sed -e 's;^# *;;' |\
> > sed -e 's/\(^\/dev\/[a-z0-9]* UUID=[a-z0-9]\{8\}-[a-z0-9]\{4\}-[a-z0-9]\{4\}-[a-z0-9]\{4\}-[a-z0-9]\{12\}\).*/\1/' |\
> > sed -e '/^\/dev\/.*UUID.*/!d' |\
> > sed -e 's/^\/dev\///' > mounts.tmp
> > 
> > join -a 1 drives.tmp mounts.tmp
> > 
> > 
> 
> Cool! I just saved as uuidcompare and:
> 
> sh uuidcomare
> 
> Works great, thanks.
> 
> Thanks

Hi Joseph and NoOp
Your topic and script interests me too !

The topic:
As a newbie I am preparing my Ubuntu 8.04 LTS to be better than my first
installation.
Thinking of 2 Ubuntu's (one PROD & the other TEST) with sharing the
common data i.e. /BOOT, /HOME and SWAP !?

Your recommendations / suggestions and warnings are very appreciated !

The script:
As newbie I am struggling with these helpful commands and scripts and 
would like to understand better how to save a script like yours !

I have already saved it as UUIDcomp on desktop and checked for /bin/sh
location 
assuming that sh is a folder under bin !? I seem to be wrong !!

Can you help me little better ? ;-)

TIA and cheers, svobi





More information about the ubuntu-users mailing list